1. ## card ranking

i am making a card game(texas hold em) and so far this is what i have:

creates a deck with all the suits and values(52 cards) and is stored in an array.
picks cards at random and deals each player(9) two cards, also stored in an array.
picks five community cards at random and stores them into an array.

now this is the part where i am having a bit of trouble. finding the ranks of the hands. now all the suits and values are stored as integers like this:

values(on the left is the stored number and on the right is what it represents):

0=ace
1=2
2=3
3=4
4=5
5=6
6=7
7=8
8=9
9=10
10=J
11=Q
12=K

suits:

0=club
1=diamond
3=heart

a player may use 5 of the 7 cards to make up their hand. im not quite sure how to go about checking for this. a sample array of the community cards plus the players cards would look something like this:

4 9 2 12 11 4 8

if someone could point me in the right direction of give me a sample on how to do it i would appreciate it. thanks.

2. Just take the max score of every combination of five cards. If you have a function that calculates the score of a five card hand, this becomes almost trivial...

3. as an update, i made another array that puts all the cards into ascending order to better find the hand rankings.

happy, thanks for the reply. do you think you could explain this concept a little better? seems a little vague to me. also, there are 7 cards to deal with and the player doesn't actually have to use any cards in their hand to make a hand they can use the board.

4. There are 7 cards, so there are 7 choose 5 possible hands per player. For each possible hand, evaluate the hand on a numerical scale and take the largest score as that players hand. The player with the overall largest score wins.

There are a finite number of hands with a finite number of card combinations to build each of those hands. Choose a method for quantifying each on a linear scale and use this method for your evaluation. Alternatively, you could categorize hands first, then quantify only in the case of a tie between categories (ex. full house, straight,...).

5. Doesnt' matter, there are still only 7 choose 5 combinations, since order doesn't matter (21 to be exact).

So to do this, you can proceed systematically. I'll show you how to do this with 2 choose 4.
You have 4 objects : 1 2 3 4. The first combination of 2 is (1,2). The next one is (1,3). After, (1,4). Next is (2,3) (not (2,1), you already picked that one, remember ?). Then (2,4). Then, finally (3,4).

Do you notice the trend develloping here ?

EDIT : Beaten to the thread, it would seem...

6. i get what you said, so basically there is no way to get around having a ton of if statements?