Comparing poker hands is complicated. Knowing which hand is better than another can be tricky.
I think the way to go about this is by having each hand have two arrays:
1 Array of up to 5 cards will hold the final cards in the players hand.
the second array will be a set of values. Starting with the best feature of your hand (say a set) and it's value and then moving down to the tie breakers. With the last few slots in your set being 0 if you have already used your cards.
Example:
P1: A A K K 4 [ PAIR + ACE , PAIR + KING, 4, 0, 0 ]
P2: A A K K 5 [ PAIR + ACE, PAIR + KING, 5, 0, 0 ]
P3: K K K 5 4 [ SET + KING, 5, 4, 0, 0]
P4: A K 8 5 2 [ ACE, KING, 8, 5, 2]
To compare two hands, begin by comparing the first item in your arrays, if they match move to the next.
Comparing poker hands is complicated. Knowing which hand is better than another can be tricky.
I think the way to go about this is by having each hand have two arrays: 1 Array of up to 5 cards will hold the final cards in the players hand. the second array will be a set of values. Starting with the best feature of your hand (say a set) and it's value and then moving down to the tie breakers. With the last few slots in your set being 0 if you have already used your cards.
Example: P1: A A K K 4 [ PAIR + ACE , PAIR + KING, 4, 0, 0 ] P2: A A K K 5 [ PAIR + ACE, PAIR + KING, 5, 0, 0 ] P3: K K K 5 4 [ SET + KING, 5, 4, 0, 0] P4: A K 8 5 2 [ ACE, KING, 8, 5, 2]
To compare two hands, begin by comparing the first item in your arrays, if they match move to the next.