Enumerating Wild Card Hands

by Cactus Kev

The distribution of all possible 5-card poker hands is well known. With a standard deck of 52 cards, there are C(52,5), or 2,598,960 ways to select five distinct cards (where order does not matter). If we determine the hand value for each of those approximately 2.6 million poker hands, we get the following table:

Five Card Poker Hands
40 Straight Flush
624 Four of a Kind
3,744 Full House
5,108 Flush
10,200 Straight
54,912 Three of a Kind
123,552 Two Pair
1,098,240 One Pair
1,302,540 High Card
2,598,960 TOTAL

It is this table that initially gave us our poker hand rankings. Notice that the fewer the ways available to make a particular poker hand, the higher its value. That's why a Straight Flush beats a Four-of-a-Kind. There are only 40 ways to make a Straight Flush, but 624 ways to make a Four-of-a-Kind. I have sometimes seen the above table given where a Royal Flush is listed separately, and ranked directly above a Straight Flush. In my opinion, this is unnecessary, since a Royal Flush is simply a special case of a Straight Flush (it just happens to be the highest Straight Flush possible). We don't single out Four Aces with a King kicker as being the highest possible Four-of-a-Kind hand, so there is no need to single out the Royal Flush hand either. But some tables list it that way, so just be aware that I've have combined the Royals with the other Straight Flushes.

Now, recently I got to thinking about wild card games, and I wondered what the frequency table looked like when you counted Deuces as being wild. Since the rules for wild card games are numerous and definately not standardized, I used the following stipulations:

  1. Five-of-a-Kind hands are allowed.
  2. Wild cards can represent any card (no restrictions).
  3. If a hand contains one or more wild cards, that hand's value is the highest possible it can be.
  4. Double-Ace and Triple-Ace Flushes are not allowed.
Rule 1 is included because most players like to have Five-of-a-Kind hands when playing with wild cards. Rule 2 means that a wild card can be anything -- it is not restricted in its value like the Joker is in some games (i.e. can only be used as an Ace, or to complete a Flush or Straight). Rule 3 is required because hands with wild cards can have multiple values. For example, if you hold two Kings, two wild Deuces, and a Jack, you can claim you have the following five hands: Since the highest hand wins in most poker games, it makes sense to count wild card hands as their highest possible value. So in the above example, that hand would be counted as a Four-of-a-Kind. Rule 4 is included so that a hand like A983 (all Spades) with a wild Deuce will be counted as an AK983 Flush, and not an AA983 Flush (a double Ace-High Flush, which is allowed in some home games).

My first thought was to search the internet and check poker books to see if such a table already existed. The internet turned up nothing, but the book "Scarne's Guide to Modern Poker" had the table I was looking for. However, I never take such tables as gospel, and I wanted to compute and verify the values myself (which is a good thing, as I soon learned that Scarne's table was incorrect!) I also posted this question in the rec.gambling.poker newsgroup, and a number of RPG'ers posted results they had either found or computed. Even then, some of the figures given were incorrect or inconsistant; so I decided to determine the hand frequencies myself.

There were a couple of ways I could tackle this problem. One way would be to use math theory and combinatorics to enumerate all the hand rank frequencies. Another would be to write some poker code to loop over all 2,598,960 possible five card poker hands, and determine each hand's value if Deuces were wild. I decided to do both, since I should get the same results using either method, and it would act as a sanity check.

I had already written some 'C' code that determined the value of a specific five card poker hand. It required just a little massaging to get it to work with Deuces being wild. After lots of debugging and code checking, I finally obtained the following results:

Poker Hand Frequencies
with Deuces Wild
672 Five of a Kind
2,552 Straight Flush
31,552 Four of a Kind
12,672 Full House
14,472 Flush
62,232 Straight
355,080 Three of a Kind
95,040 Two Pair
1,225,008 One Pair
799,680 High Card
2,598,960 TOTAL

Now the question was whether or not these figures were correct. Although I was fairly certain my code was correct, I'd been burned before by making invalid assumptions in my coding logic. This meant to be absolutely sure, I needed to validate my results by using math and combinatorics.

Before we start, a quick note about combinatorics. There are often multiple ways to obtain the same answer. In the tables given below, I will give the combinatoric method I used to obtain my answer. You, however, may come up with a completely different way to compute the same answer. That is okay. It all depends on how you "count" your objects. For example, let's say we remove all four Deuces from the deck, and we wish to figure out how many ways we can select five cards of differing ranks. One person might look at the problem this way:
There are 48 cards to choose from for our first card. Let's say we select the King of Spades. For our next card, we only have 44 to choose from (because we can't select another King). We select the Six of Diamonds. For the third card, we only have 40 to choose from (because we can't select any Kings or Sixes), and so on. So selecting all five cards gives us 48 x 44 x 40 x 36 x 32 possible permutations. However, we don't care about the order -- we want combinations instead. In order to remove all duplicates, we must divide by 5! (that's 5 factorial, i.e. 5x4x3x2x1). This gives a final answer of 811,008.
Now, a second person might come along and reason as thus:
Okay, there are twelve ranks to choose from since the Deuces have been removed. I need to choose five ranks out of the possible twelve, so that's C(12,5), or 792 combinations. Now that I have chosen my five distinct ranks, each of those five cards can be one of four possible suits. So I need to multiply 792 by 45. This gives a final answer of 811,008.
See? Two different ways to tackle the problem, but they both come up with the same result.

Okay, enough talk. Let's start enumerating. First off, I determined how many five card poker hands contained zero Deuces, one Deuce, two Deuces, three Deuces, or all four Deuces. Combinatorics made this very easy, and the following table shows the results:

Breakdown of Deuce Counts
48 hands with four Deuces C(4,4) x C(48,1)
4,512 hands with three Deuces C(4,3) x C(48,2)
103,776 hands with two Deuces C(4,2) x C(48,3)
778,320 hands with one Deuce C(4,1) x C(48,4)
1,712,304 hands with zero Deuces C(4,0) x C(48,5)
2,598,960 TOTAL

Next, I tackled each of the five possibilities shown above. The first case was easy. If you have all four Deuces in your five card poker hand, then you obviously have a Five-of-a-Kind. So out of the 48 possible hands that contain four Deuces, all of them are Five-of-a-Kinds.

Hands with Four Deuces
48 Five of a Kind C(48,1)

Next, I took a look at the hands with three Deuces. After some thought, you should realize that if you hold three Deuces, then the absolute minimum hand you could hold is Four-of-a-Kind. If the other two non-wild cards happen to be a pair, then you have a Five-of-a-Kind. If they are the same suit and close enough in rank, you have a Straight Flush. Otherwise, you must have a Four-of-a-Kind. No other hands are possible with three wild Deuces. Since there are four Deuces in a deck, but we only need to choose three of them, each of the counts will have a factor of C(4,3) for the various combinations of three Deuces. For Five-of-a-Kind hands, there are 12 ranks to select from (Ace through Trey) for the pair, and C(4,2) ways to form that pair once the rank has been selected. That gives us 288 Five-of-a-Kind hands. Straight Flush hands are more tricky to compute. We must enumerate all ways to form a Straight Flush using two non-wild cards. It turns out there are 41 such ways, as shown in the table below. Note that when Deuces are wild, Six-High Straight Flushes are verboten since one can always make a higher Straight Flush.

Straight Flushes with Three Deuces  (41 ways)
Royal Flush AK222AQ222 AJ222AT222 KQ222
KJ222KT222QJ222 QT222JT222
King-High Straight Flush K9222Q9222J9222T9222
Queen-High Straight Flush Q8222J8222T822298222
Jack-High Straight Flush J7222T72229722287222
Ten-High Straight Flush T6222962228622276222
Nine-High Straight Flush 95222852227522265222
Eight-High Straight Flush 84222742226422254222
Seven-High Straight Flush 73222632225322243222
Five-High Straight Flush 5A2224A2223A222

With that table, I can now calculate how many Three Deuce Straight Flush hands there are. There are C(4,3) ways to choose three of the four Deuces, times 41 ways to make a Straight Flush, times 4 different suits, giving a total of 656. Once I've eliminated all Five-of-a-Kind and Straight Flush hands, only Four-of-a-Kind are left remaining. I now know the totals for hands with three Deuces.

Hands with Three Deuces
288 Five of a Kind C(4,3) x 12 x C(4,2)
656 Straight Flush C(4,3) x 41 x 4
3,568 Four of a Kind 4,512 - 288 - 656
4,512 TOTAL

Next, I worked on the hands containing two Deuces. Note that when holding two wild Deuces, the minimum hand possible is Three-of-a-Kind. Also observe that it is impossible to have a Full House when holding two wild cards. The combinatorics used to calculate the hand frequencies are similar to how we computed them for the three Deuce hands. It turns out there are 55 ways to make a Straight Flush this time (rather than 41 as before). For Flush hands, we select any three cards (except the Deuce) of the same suit, but then subtract off the Straight Flush hands since those would be included. For Straights, we use the same 55 ways to make Straight Flushes, but this time we make sure the suits don't all match. Three-of-a-Kinds would be a real bear to compute, so we take the easy way out. Once we've computed all the other hand frequencies, anything left remaining has to be a Three-of-a-Kind.

Straight Flushes with Two Deuces  (55 ways)
Royal Flush AKQ22AKJ22 AKT22AQJ22 AQT22
King-High Straight Flush KQ922KJ922KT922QJ922QT922JT922
Queen-High Straight Flush QJ822QT822Q9822JT822J9822T9822
Jack-High Straight Flush JT722J9722J8722T9722T872298722
Ten-High Straight Flush T9622T8622T7622986229762287622
Nine-High Straight Flush 985229752296522875228652276522
Eight-High Straight Flush 874228642285422764227542265422
Seven-High Straight Flush 763227532274322653226432254322
Five-High Straight Flush 54A2253A2243A22

Hands with Two Deuces
288 Five of a Kind C(4,2) x 12 x C(4,3)
1,320 Straight Flush C(4,2) x 55 x 4
19,008 Four of a Kind C(4,2) x C(4,2) x 12 x 44
0 Full House not possible
3,960 Flush C(4,2) x C(12,3) x 4 - 1,320
19,800 Straight C(4,2) x 55 x 43 - 1,320
59,400 Three of a Kind 103,776 - 288 - 1,320 - 19,008 - 3,960 - 19,800
103,776 TOTAL

Almost done. Next, I compute the frequencies for hands containing just a single wild Deuce.

Hands with One Deuce
48 Five of a Kind 4 x 12
544 Straight Flush 4 x 34 x 4
8,448 Four of a Kind 4 x C(4,3) x 12 x 44
9,504 Full House 4 x C(4,2) x C(4,2) x (12x11/2!)
7,376 Flush 4 x C(12,4) x 4 - 544
34,272 Straight 4 x 34 x 44 - 544
253,440 Three of a Kind 4 x C(4,2) x 12 x (44x40/2!)
0 Two Pair not possible
464,688 One Pair 4 x C(12,4) x 44 - 544 - 7,376 - 34,272
0 High Card not possible
778,320 TOTAL

Lastly, we handle all the cases where a hand has no wild cards.

Hands with No Deuces
0 Five of a Kind not possible
32 Straight Flush 8 x 4
528 Four of a Kind 12 x 44
3,168 Full House C(4,3) x 12 x C(4,2) x 11
3,136 Flush 4 x C(12,5) - 32
8,160 Straight 8 x 45 - 32
42,240 Three of a Kind 12 x C(4,3) x (44x40/2!)
95,040 Two Pair (12 x C(4,2) x 11 x C(4,2))/2! x 40
760,320 One Pair 12 x C(4,2) x (44 x 40 x 36)/3!
799,680 High Card (48 x 44 x 40 x 36 x 32)/5! - 32 - 3,136 - 8,160
1,712,304 TOTAL

Okay, that was a lot of work, but we have used raw math to enumerate all the various hand frequencies. The final test was to see if the totals obtained from my poker code matched the totals obtained emperically. In other words, if my poker code states that there are 672 Five-of-a-Kind hands, then if I add up all the various ways to make a Five-of-a-Kind using from one to four Deuces, they should be equal.

Breakdown of Five Card Poker Hands
with Deuces Wild
Hand Rank No
Five of a Kind 0 48 288 288 48 672
Straight Flush 32 544 1,320 656 0 2,552
Four of a Kind 528 8,448 19,008 3,568 0 31,552
Full House 3,168 9,504 0 0 0 12,672
Flush 3,136 7,376 3,960 0 0 14,472
Straight 8,160 34,272 19,800 0 0 62,232
Three of a Kind 42,240 253,440 59,400 0 0 355,080
Two Pair 95,040 0 0 0 0 95,040
One Pair 760,320 464,688 0 0 0 1,225,008
High Card 799,680 0 0 0 0 799,680
TOTAL 1,712,304 778,320 103,776 4,512 48 2,598,960

At this point, it might be interesting to see how the "normal" distribution of poker hands changes when we introduce four wild Deuces. As expected, most of the hand count frequencies increase, with the exception of the Two Pair and High Card hands.

Five Card Poker Hands
Nothing Wild Deuces Wild Hand Rank
0 672 Five of a Kind
40 2,552 Straight Flush
624 31,552 Four of a Kind
3,744 12,672 Full House
5,108 14,472 Flush
10,200 62,232 Straight
54,912 355,080 Three of a Kind
123,552 95,040 Two Pair
1,098,240 1,225,008 One Pair
1,302,540 799,680 High Card
2,598,960 2,598,960 TOTAL

One might be tempted to re-order the poker hands based on the new frequency counts. If you did so, the Four-of-a-Kind hand would be placed between the Flush and Straight hands, the Three-of-a-Kind and Two Pair hands would swap places, and so would the One Pair and High Card hands. However, in every home game that I've played in that allows wild cards, I have never seen the hand rankings rearranged based on the "true" frequencies. In other words, a Flush still loses to a Four-of-a-Kind, even thought it is actually harder to get a Flush than a Four-of-a-Kind when Deuces are wild. There are a number of reasons for keeping the poker hand rankings order unchanged. First, every poker player has already committed the "correct" ordering of poker hands to memory. Everyone just knows that a Four-of-a-Kind is a powerful hand. Nobody wants to be forced to remember another ordering just for wild card games. Plus, some player would inevitably forget the new ordering, bet his Four-of-a-Kind heavily, and then get extremely angry when he loses to a Flush or a Full House. Second, one could always "cheat" by changing the value of your hand. For example, suppose you hold three wild Deuces along with the Six and Jack of Spades. Logic would tell you that you have Four Jacks with a Six kicker. However, since Full Houses are supposedly harder to get than Four-of-a-Kinds, you would instead say that you have a Full House, Jacks over Sixes. It's sort of a Catch-22. If you rearrange the poker hand orders, then players will just start calling their hands differently to circumvent the new ordering, which in turn will screw up the frequencies again, which sort of defeats the purpose of re-ordering the hands in the first place! I guess one could get around this trickery (of a hand having multiple values) by enforcing a "rule" that a player with wild cards must call his hand as high as possible based on the "normal" frequencies, even if that means having a losing hand; but that also would be hard to remember and cause lots of frustration at showdown. Third, one of the main reasons of having wild card games is the chance to gleefully announce that you have a Four-of-a-Kind or a Straight Flush. Let's face it, that doesn't happen too often in regular poker. It's great fun to be able to lay down and win with one of these "power" hands, which wouldn't happen as often if we put the Four-of-a-Kind in its "proper" place. Lastly, consider the game of Seven Card Stud (nothing wild). Each player at showdown will have seven cards, of which they each make the best five card hand possible. If you calculate the hand frequencies of all possible C(52,7) combinations, and order them based on their likelihood of appearing, you get the exact same order as we did with just five cards, except that One Pair is easier to get than a High Card hand. It's actually easier to get a pair than seven crappy cards (which explains why the game Razz is so much fun), but the poker community didn't try to reverse the hand rankings of those two hands when playing Seven Card Stud. They remained the same. So likewise, even though wild cards throw the hand rankings all out of whack, the "normal" ordering is maintained.

Well, I hope you enjoyed this geeky and math-laden journey into the world of poker. I doubt if this information will make you a better poker player, and unless you play in a home game, you probably won't be playing too many games containing wild cards.

Cactus Kev, copyright 2003