Video Poker Video Poker Articles Online Casinos Online Gambling Video Poker Games Tools Video Poker Strategies

Analyzing Video Poker Hands


Play Video Poker at iNetBet CasinoAnalyzing a video poker hand requires, at its core, the following steps for each of the 32 ways to play the hand:
  1. Count the number of times each type of winning/losing hand can occur on the draw
  2. Multiply each count by the payout for that respective hand
  3. Sum each of the results obtained in step 2
  4. Divide this sum by the total number of hands possible on the draw
The result of step 4 yields the average value for that way to play. The best play is the one which has the highest average value.

Without any sort of optimization, it would take even today's computers a very long time to perform the above steps for all 32 ways to play all 2,598,960 (or more) possible starting hands. By using some creativity and shortcuts, the steps can be modified to run faster, but still arrive at the same result. Step 1 is the most critical and time-consuming step. Fortunately there are multiple ways to complete it, as I will explain below.

Determining Possible Replacement Hands


Brute Force


The simplest but slowest method uses "brute force", which involves looping through the unused cards and combining them with the held cards to determine the possible outcomes. On my website, when you analyze an individual hand, this is the method I use because it's fast enough for the purpose of analyzing an individual hand. When analyzing an entire game, however, this method is unacceptably slow. Depending on the game and whether or not a simplified deck model is used, it could take anywhere from one day to three months to finish.

Game-Specific Formulas


Another method is to use formulas that determine the number of ways a particular hand can be made on the draw based on the cards held and the cards that were discarded. I believe this is the method that the Wizard of Odds uses, and I also believe that the formulas change from game to game, meaning that it would not be possible to use the Jacks or Better formulas for Deuces Wild, for example. I have never tried to implement this method, so I can't offer much insight into it.

Generic Formulas


The shortcut I use involves formulas also, but for the most part they do not change based on the game. Before I begin analyzing each unique hand, I prepare some data about the game using a few arrays:
  1. One array to hold the total number of combinations of each hand type
  2. One array to hold the total number of combinations of each hand type for each individual card
  3. One array to hold the total number of combinations of each hand type for each combination of two cards
  4. One array to hold the total number of combinations of each hand type for each combination of three cards
  5. One array to hold the total number of combinations of each hand type for each combination of four cards
  6. One array to hold the total number of combinations of each hand type for each five-card hand (each value is a zero or a one)
The arrays are populated by looping through all 2,598,960 (or other number of) hands and doing the following for each:
  1. Score the hand to determine what type it is. Call this value H.
  2. Update the total number of hands of type H (Array #1).
  3. For each of the 5 individual cards, update the total number of hands of type H which include that card (Array #2).
  4. For each of the 10 combinations of 2 cards, update the total number of hands of type H which include both cards (Array #3).
  5. For each of the 10 combinations of 3 cards, update the total number of hands of type H which include all 3 cards (Array #4).
  6. For each of the 5 combinations of 4 cards, update the total number of hands of type H which include all 4 cards (Array #5).
  7. Array #6 will contain a one, since H is the only type of hand possible which includes all 5 cards.
Preparing this data takes about one second. Using the data, the number of possible replacement hands for any given starting hand can be derived using a series of additions and subtractions. The diagram below illustrates the formulas used for each of the 32 ways to play. The numbers 00 through 31 correspond to the way to play. Convert these numbers to binary to figure out which cards were held. For example, 13 converts to 01101 in binary, indicating that the cards being looked at are those in positions 2, 3 and 5 in the hand.

The numbers on the top are the "input" numbers, and correspond to the total number of hands in the entire game that include the designated cards, including those hands which contain the discards. The numbers on the left are the "output" numbers, and correspond to the total number of hands that are possible on the draw after the discards have been taken into consideration. The plus and minus signs on each row indicate whether the corresponding "input" number is to be added or subtracted. You may notice that the visual representation of the formulas yields a Sierpinski Triangle Opens in a new window:

Formulas

There are actually two ways to execute these formulas:
  1. Calculate from left to right, using the input totals which correspond to each plus or minus sign on that row. For example, to calculate hold #25 you would use the following formula:

    Input25 − Input27 − Input29 + Input31

  2. Calculate from the bottom up, starting with the input total and subtracting the sum of all previously-calculated output totals which correspond to each plus or minus sign on that row. For example, to calculate hold #25 you would use the following formula:

    Input25 − (Output27 + Output29 + Output31)

When I first started this site I was using the left-to-right method, where each formula (except for hold #31) uses the same number of additions and subtractions. In an attempt to try to further improve the formulas, I discovered the bottom-up method. Both formulas use the same number of calculations, but I switched to the bottom-up method because it results in cleaner code.

Hurry Up and Weight


Of the four basic mathematical operations, division is the one that takes humans the longest to perform. With some exceptions, the same holds true for computers. Division is what programmers refer to as an "expensive operation", because it requires more time to process than addition, subtraction, or multiplication.

Additionally, computers can handle integers faster than they can handle decimals (floating-point numbers). Instead of dividing the total payout for each way to play by the number of hands that can be achieved on the draw, it is faster to multiply the total by a weighting factor which will "equalize" the results for all 32 ways to play. Doing this saves time in two ways: multiplication is used instead of division, and floating-point numbers are avoided.

The first step involved in finding the ideal weighting factor is figuring out the number of possible outcomes for each number of discards:

Number
of
Discards
Number of Cards in Deck
52 53 54 55 56 57 58 65
0 1 1 1 1 1 1 1 1
1 47 48 49 50 51 52 53 60
2 1,081 1,128 1,176 1,225 1,275 1,326 1,378 1,770
3 16,215 17,296 18,424 19,600 20,825 22,100 23,426 34,220
4 178,365 194,580 211,876 230,300 249,900 270,725 292,825 487,635
5 1,533,939 1,712,304 1,906,884 2,118,760 2,349,060 2,598,960 2,869,685 5,461,512

The next step is determining the least common multiple (LCM) of all six numbers for each deck size:

Number of Cards in Deck
52 53 54 55 56 57 58 65
7,669,695 8,561,520 3,813,768 21,187,600 11,745,300 12,994,800 28,696,850 27,307,560

The final step is dividing the least common multiple by the number of possible outcomes. The result is the ideal weighting factor for the corresponding number of discards:

Number
of
Discards
Number of Cards in Deck
52 53 54 55 56 57 58 65
0 7,669,695 8,561,520 3,813,768 21,187,600 11,745,300 12,994,800 28,696,850 27,307,560
1 163,185 178,365 77,832 423,752 230,300 249,900 541,450 455,126
2 7,095 7,590 3,243 17,296 9,212 9,800 20,825 15,428
3 473 495 207 1,081 564 588 1,225 798
4 43 44 18 92 47 48 98 56
5 5 5 2 10 5 5 10 5

By multiplying the total payout for each way to play by the appropriate weighting factor, it is then possible to identify the best play as the one whose weighted payout is the highest, with no division necessary. For more information about weighting factors, I recommend The Wizard of Odds' Video Poker FAQ Opens in a new window, which is where I learned about them.

Copyright © 2007-2009 Video Poker Genius. All rights reserved.

Free Video Poker | Mac Video Poker | Online Blackjack | Video Poker | Slot Machines | Privacy Policy & Disclaimers | Video Poker Websites | Contact