My tool will make you a Texas Hold’em expert

Easily determine how good your hand is

Max Mann
9 min readJan 3, 2017

tl;dr: Calculate poker hand strength at http://pokerpower.herokuapp.com

What is the probability that I will win, given the board state? I’ve seen:

  1. Tables listing the likelihood of hand types
  2. Formulas for the likelihood to complete a flush or straight

The table doesn’t help because the shared cards change the odds. If there are three aces on the table (shared), the likelihood of getting a two pair is 0, since three of a kind is better. What we need is some way to recalculate all those odds when some of the cards are given.

The formulas are helpful only when you are close to completing one of those fancy hands. They provide less support in the high card or one pair scenarios, which are common.

The naive solution:

For each of the 133,784,560 distinct 7-card hands, I computed the best 5-card hand you can make. I used Mathematica on an Inspiron 15 laptop. Storing all the 7-card hands caused a memory error, so I stored only the 5-card hands. Each 7-card hand would just increment the number of ways to get a 5-card hand. The computation took three days.

This produced a table like Wikipedia’s, except more detailed. Now I could say exactly how many hands are beaten by a specific hand, such as 5♠ 6♠ 8♦ 8♣ 10♦. Dividing that number by the total number of possible hands, gives the hand power, a number between 0 and 1. The hand power is the likelihood that a player holding that hand would beat an opponent with a random hand. But in Texas Hold’em your opponent does not have a random hand. He is sharing some cards with you.

Instead we need two of these tables: one for us and one for an opponent. The opponent’s table takes into account the cards he is sharing with you, which is zero, three, four, or five cards depending on the betting round. Our table takes into account those same shared cards, plus the two we hold in our hand. With these two tables we can calculate the chance to beat our opponent. It is a weighted average. Take each hand in our table and see what percentage of enemy hands it beats. Weight that score by the probability that we end up with that hand, and total it all up.

For example, say we have a 30% chance to get a flush, which beats 80% of our opponent’s hands, and a 70% chance to get high card, which beats 5% of our opponent’s hands. Then our overall score is 0.3*0.8+0.7*0.05 = 0.275. In reality the hands are not grouped into categories like “flush”; instead it is a complete list of all possible flushes and high cards and so on.

To get those numbers, we need to narrow down the general table to accommodate the fact that certain cards are shown. First I tried picking a single card. I totaled up the expected power of entries from the table that had my card. The results showed that holding a three was more valuable than holding a king. What?!

It’s selection bias. If a three ends up in the final 5-card hand, then it must be a great hand, like a flush or a four of a kind. Bad 5-card hands which contain a 3 are unlikely in Texas Hold’em because the 3 will usually end up in one of the two unused cards out of the seven. To correctly evaluate the likelihoods, we need a master table of 7-card hands, not 5-card hands. And I don’t have enough RAM for that.

The final goal is a quick lookup table with the finished computed result for each possible board state. Since I can’t store the 7-card table in RAM, I would have to recompute all 100 million hands for every 100 million possible board state. Making the lookup table this way would take 800 thousand years, and it would also be annoyingly large on disk.

The solution:

There are only about 50,000 unique 7-card hands ignoring suits. For each of these hands I calculated the number of ways it could be achieved simply by imagining that a single Jack could be any of four suits, with two Jacks there are 6 combinations of suits, and so on. I verified that this represented all possible hands by totaling the number of ways for all 50,388 unique hands, and I got exactly 133,784,560.

To account for flushes, I calculated the number of different ways to get a flush for each 7-card hand. The key thing to look for here was unique cards, since all the cards in a flush have unique values. With fewer than 5 unique values, a flush is impossible. With 7 unique values, there are 21 possible flushes. Unused cards increase the number of ways to get a given 5-card hand. Unused cards which match cards used in the flush have one fewer possible suits. A tricky edge case is that cards which are not used in the flush but match the flush suit must be smaller than the smallest card in the flush; otherwise they must be a different suit. This check avoids double-counting.

For each 7-card hand there can be born up to 21 possible new hands which are flush versions or straight flushes. This brings the total number of unique 7-card hands to 167,505. Sorted and listed by power, these hands form this plot:

The blue line is actually made of 167,505 points, each representing a unique hand. The vertical position of the point indicates the likelihood that it will win against a random hand. The grid lines delineate transitions between hand types.

The “Hand Number” stops at 167,505 because there can be multiple ways to get each hand. If you total all those ways you will get 133,784,560 correctly. When the slope of the line is shallow, it means there are fewer ways to get each hand. Note that a series of cards is listed as being a flush even though the suits of the individual cards are not stored.

The best high card hand beats about 20 percent of other hands. The best one pair hand beats about 60 percent of other hands. The best two pair beats about 85 percent of other hands. Much of the time, your hand power will depend on the different ways of getting specific low-scoring hands. It’s necessary that our table lists all the specific hands (each point on the plot), not just the types (the gridded sections High Card, One Pair, etc.).

In summary, the table is made manageable by not storing suits specifically. We can calculate the number of ways to get each 7-card hand conditioned on existing cards. It gets a little tricky with the flushes, but we can simplify it by calculating the chance to complete a flush and treat it as a unique single category. Using this method we can get a table for us and for the opponent, and calculate our chance to win, in under half a second on my laptop. Let’s evaluate some situations and try to tell a story explaining the hand power.

Hole card powers

Here are the powers of some hole cards according to the algorithm, when no shared cards have been dealt yet. This table is nothing special; the new part comes later, when there are shared cards.

Observe,

  • A pair is good; everything else‘s power ~ 0.5, meaning 50/50 odds
  • Matched suits improves a hand by .02 (not much!)
  • Adjacent cards improves a hand by .06, assuming the same high card
  • The apparently good matched K A is worse than a pair of 4’s.

Knowing the power of a hand, when do we bet?

Critical hand power vs number of opponents

The expected value of participating in a hand depends on your hand power and also on the number of opponents. Suppose there are four players, and none have folded. If you win, you will have 4x the money you bet. If you have a 0.5 chance to win, then your expected vaue is 4x*0.5=2x. We can calculate the chance to win against N opponents. Suppose your hand power is 0.6, the chance to beat one opponent. The chance to beat two opponents is 0.6² = 0.36. Three opponents is 0.6³=0.216. And so on. Graphing this function looks like this:

The yellow-orange line labeled “1x” shows the hand power you need for even odds in a game with N players. For example, in a game with 6 players, you need a hand power of about .7 for 1x odds. Your chance of winning is .7⁵ ~ .17, and if you win you will get 6 times the chips. The expected winning is therefore .17*6, which is about 1. In this example, if your hand power is above .7, then you can expect to gain money. If your hand power is below .7, then you should not bet on this hand.

If some players have folded, then there will be non-integer pot odds from that extra cash in the pot. That’s why the plot allows for “4.5 players”. there may be $10 from each player who is still playing, plus $5 from a player who folded. Then, for your $10 you stand to win $45. So really I should have written “Pot Odds” instead of “Number of Players,” but that jargon may be confusing, too.

If you’re playing a game of 8 people and four fold, you could argue that now you’re only playing against 4 players, and that your chance of winning has increased. However, at the same time, it is the players with the lousy hands who typically fold. In my opinion it is still a good approximation to select the number of players regardless of how many have folded. Using the plot above, we can select the number of players and, knowing how much money we want to win, we know what hand power we need to proceed.

The recipe for success:

First, enter the board state into the online calculator. It spits out a number describing the power of the hand to be one opponent. It also produces an estimate of your winnings against N opponents, using the same concept as the graph above. Now you know how much you can expect to make (or lose). Let’s do a few examples together.

My hand: 4♣4♦
Shared cards: none
Plug into algorithm, Power = 0.583

Looking at the chart, a hand power of .60 can face off against up to 3 players and still have good expected value, greater than 1x. Suppose I’m playing against 3 players, so I stay in to see the flop. Now the situation is this:

My hand: 4♣4♦
Shared cards: 2♥5♥7♥
Plug into algorithm, Power = 0.480

My hand got worse compared to other peoples’ possible hands. Anyone could match a 5 or a 7 and beat my pair of 4s. Or someone could be holding a flush, or most of a straight. In this case, I would only stay in the game if I had already bet most of my chips and I only needed to put in a small amount to stay in. Let’s play it out. Another shared cared is drawn, so we have this:

My hand: 4♣4♦
Shared cards: 2♥5♥7♥7♣
Plug into algorithm, Power = 0.532

Strange, my hand power went way up again! Here’s my explanation. The likelihood of other players completing a flush went down. The likelihood of other players completing a straight went down. The likelihood of other players matching a high card, like one shared Jack plus one Jack they are holding, went down. The likelihood of the players having a 7 went down. So now there are a fewer ways for the opponent to beat us, even though our hand hardly seems any better than before. Let’s draw another card.

My hand: 4♣4♦
Shared cards: 2♥5♥7♥7♣10♠
Plug into algorithm, Power = 0.598

Now it’s very unlikely for an opponent to get a flush and impossible for them to get a straight. They can still beat us with a 5, a 10, or a pocket pair better than 4. Earlier we would have tried to read our opponents on the flop to see if they had a flush at that point. Just for the fun of it, I’ll draw two opponents’ hands now.

My hand: 4♣4♦ (two pair, 7s and 4s)
Opponent 1: 6♠10♣ (two pair, 10s and 7s)
Opponent 2: A♠Q♣ (high card, ace)

It turns out opponent 1 beats us, although it is likely that he would have folded before the 10 appeared. Before that 10 appeared, his hand power was:

His hand: 6♠10♣
Shared cards: 2♥5♥7♥7♣
Plug into algorithm, Power = 0.254

So it would be foolish for him to stay in the game at that point, if any additional money were wagered. Anyway, we didn’t win, but we had a decent chance to win. Losing does not indicate bad strategy! Use the web tool and the pot odds chart, and see where it gets you.

You may still lose money at poker when you bet by the numbers. Maybe your performance was too transparent or you didn’t spend time reading your opponents. I worked on this problem not to gain an advantage over my opponents, but to make poker less about arithmetic and more about people. Is it working? Try it out and tell me what you think.

--

--