john1571 / RoboPoker

Arena for poker playing computer programs to play against each other.
1 stars 2 forks source link

Add value array to Hand class #1

Closed john1571 closed 2 years ago

john1571 commented 2 years ago

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.

john1571 commented 2 years ago

We don't handle 4 of a kind correctly. Come on man.

john1571 commented 2 years ago

Add a couple more unit tests and close this out.

john1571 commented 2 years ago

Good enough to close!