Raw Hand Odds
Welcome to holdemkiller, my poker bot blog and guide to writing your own pokerbot.
I thought that to kick things off, I’d lay some groundwork and terminology for the art of software poker analysis. There has been a lot of speculation recently about bots playing hold’em online, and how feasible or powerful such a bot might be. Before getting into any of the “human level” qualifications for playing good poker, the bot has to compute basic odds for the hand. This is the very lowest requirement, and so it’s a good place to begin understanding how complex this is in the presence of incomplete information. I hope we can all take part in refining and building on these ideas, creatively and with specificity. More topics will follow.
Raw hand odds:
Before we start talking about any kind of opponent modeling or hand reading, we need to establish basic hand odds. This is harder than it sounds. Most players establish raw hand odds by “putting the opponent on a hand”, and then counting their “out cards”, assuming both are correct and absolute. No player can calculate his exact hand odds in a typical hand. Let’s look at how to do it rigorously.
For raw hand odds, we assume a simple sort of hold’em game where the cards are dealt, there is no betting or folding, and we’re simply computing our expectation of coming out at the top against n opponents.
Below I’ve outlined a process for computing the raw hand odds, starting with your hole cards, the board, and n opponents with unknown hole cards. I’m going into graphic detail here so we can all appreciate the problem.
1. Starting info
- Your hole (2 cards)
- Current Board (0-5 cards)
- (opponents …)
2. Possible 7-card hand spectrum
There are about 133million 7-card hands total (52C7 i.e. "52 choose 7" =~ 133million). Giving the starting info, you can trivially come up with the possible final 7-card possibilities for you and an opponent. I call this a hand spectrum. It has a dot for each possible final 7-card hand for the user and opponent. There are thousands of times more opponent dots than user dots, because you only know the board cards for the opponent. All 7-card final hands are equally likely.
[_._......_...._.._..._..._._..._......._......_...._.._._.._..._.._.._..._..._......_.._..._] 133million
The diagram above is of course conceptual and doesn't represent the immense number of hands involved. It represents all possible specific 7-card hands that can be made by you or an opponent. Blue dots represent ones you can make. Red dots represent ones the opponent can make. Note lots more red than blue dots (because there are fewer known cards for the opponents). All are equally likely (for raw hand odds).
3. Possible 5-card “best hand” spectrum
Each of the 7-card hands maps to a 5-card “best hand”. People can eyeball this, but computationally it’s pretty intensive, and you have to pre-generate the required tables to do it in real time. So now you can produce a 5-card hand spectrum, sorted by hand rank. Multiple 7-card hands (up to thousands) can map to the same 5-card hand, so each possible 5-card hand has a “weight” associated with it. Note that adjacent hands may have equal rank.
[__...._..__....._..__....__._..__...___.__...__.___._....___....__..__] 2.7 million
This diagram represents the ~2.7million specific 5-card hands (ordered worst to best). Blue dots represent "best hands" taken from the possible 7-card user hands. Red dots represent best hands taken from the possible 7-card opponent hands (there are also some red/blue dots in cases where both play the board; we'll ignore that for now). Multiple 7-card hands can map to the same best 5-card hand. So all are not equally likely (for analysis, each must be weighted by the number of equally-likely 7-card hands that map to it).
“Having the nuts” looks like this: your min is greater than the opponents’ max:
[__...._..__....._..__....__._..__...___.__...__.___._..___....__..__ ]
What does it mean to have a better partial hand than 1 opponent? It means that in the 5-card spectrum, the average blue dot (applying “weight” for the number of 7-card hands that map to it) is to the right of most of the red dots.
4. Raw Hand Odds vs. 1 Opponent
What does “Having a winning hand” against 1 opponent mean? Looking at the top spectrum in #3, it’s tempting to just compare average ranks for red and blue. But that’s flawed, as illustrated by the following spectrum:
[ _..___......._______________________________________._]
Here, you have an expected loss, but the average rank (pulled up by the rightmost dot), would make you think you have a likely win. Remember, for raw hand odds, we’re not talking about betting power or anything like that -- just the raw likelihood of winning the hand.
So the right answer, for the simple case of 1 opponent, is to compare the medians of the red and blue hand ranks. That answers the boolean question of which are more to the right of the others.
But, as we all know, at the end of the day we’re going to need odds (to compare with pot odds), not just a boolean "is better than" metric. So what are the raw hand odds against 1 opponent? (Think about this before reading on …)
Well, it’s the probability that, for random red and blue dots from the 7-card spectrum, the blue dot maps to the right of the red dot in the 5-card spectrum. You can do this with a brute-force count. There are accelerated methods, but I won’t go into perf here.
5. Raw Hand Odds vs. n Opponents
So, given the raw hand odds against 1 opponent, what are the raw hand odds against 2 opponents?
Opponent hole cards are almost independent, and you may recall the formula that for independent events A and B, p(A and B) = p(A)*p(B). So you may think that raw hand odds against 2 opponents is simply the square of the raw hand odds against one opponent; and that for n opponents, you raise the raw hand odds against one opponent to the power n.
Although this is sometimes close (if the dots are evenly distributed), it is not so in many cases (especially in draw hands against many opponents, in which case it is way off). Let’s see an illustration of why:
Suppose you are on a 1-card draw for the nut flush. If you don’t make your flush, you have nothing. The 5-card spectrum looks something like this:
[__...________........____....___...___...._______......._______.]
The opponent’s expected hand is roughly in the 50th percentile of rank, and yours is somewhere around the 25th percentile. Your odds against 1 opponent are exactly the odds of making your nut flush, i.e. 25%.
Now, applying the raise-to-the-power-n idea for n opponents above, you would calculate that against 2 opponents, your raw hand odds are 25%^2 = 6%, and against 3 opponents they’re 25%^3 = 1.5% . But that’s clearly wrong! If you make your nut flush, you’ll beat all opponents no matter how many there are; and if you don’t, you’ll lose.
This effect, due to the uneven distribution of the dots, comes up in subtle ways all the time. Therefore, even if they knew their raw hand odds against 1, and could exponentiate fractions in their head, no one can calculate their odds against n players accurately in their head.
The solution is to exponentiate the odds for each possible final user hand separately, before taking the median. That way, the high-rank possible hands don’t lose value in the exponentiation:
- for 2 opponents: (3/4)*(~0%)^2 + (1/4)*(~100%)^2 = ~25%
- for 3 opponents: (3/4)*(~0%)^3 + (1/4)*(~100%)^3 = ~25% …
With messier dot distributions, it gets more interesting and the effects are more chaotic.
---------------
Ervin Peretz is a software engineer at a major web search company.
He is author of HoldemKiller, a free online poker bot.
He is author of BibleCodex, a free Bible Codes research tool.
He is founder of Terra Bite Lounge, a voluntary-payment cafe/restaurant chain.
0 Comments:
Post a Comment
<< Home