Closed Allybag closed 2 months ago
Also one other thing, is that every hand in poker is actually exactly 5 cards, even hands like a pair.
So, for example KKJQ8 beats KKJQ7, are both one pair of Kings, but the first hand beats the second hand on the fifth card.
Hands like straights, flushes, and full house already contain five cards, but high card, pairs, two pairs, three of a kind and four of a kind all also include as many of the highest cards on the board or in the hand as required to make up to five cards, and all of these cards are also used as tie breakers.
This is super helpful thank you! I asked a poker player about flushes and seem to have received bad advice, so I'll have to fix this.
As to your second comment, I should already have that implemented if you want to double check it. The kicker logic could be cleaned up, but it's located here:
I put it in the Texas holdem logic because I hadn't checked if it was specific to Texas hold em or could be applied broadly to all poker games. This is an area I'd definitely like to clean up a bit if I have time in the future. Or feel free to make a PR yourself if you find it interesting enough!
Ah cool, looks legit!
Great catch on your end! I had a faulty test I wrote on my misunderstanding above that made it look like things were working ok. The test in question:
This test checked that if players had the fifth card in their hand to make a Flush, they both pushed. I now understand that is an impossible situation since both players cannot have identical cards in their hand. Therefore, the player with the higher card in their hand should have the winning Flush.
I'm working on a fix for this now.
Hey Winston, this is Alex from RC.
It looks like in casino_poker/src/hand_rankings.rs:193 you rank all flushes the same.
When tie breaking flushes, the logic is the same as for High Card, for example K9752 beats Q9732, and K9753 beats K9752 (https://www.888poker.com/how-to-play-poker/hands/flush-poker-hand-ranking/)
The only way for two flush hands to tie is if the board is a complete flush, and players each either have none of that suit, or only cards below the lowest rank on the board.
You're right though that in Texas Hold'em there can only ever be a flush of one suit.
Cool project!