Est. 1997 | Last Update: 17 May, 2008


Get the Wizard's free newsletter!

Monthly, 100% spam-free

Methodology for Video Poker analysis

Last update: Oct. 3, 2007

One question I get asked from time to time is how I got my video poker program to evaluate a pay table in under one minute. This page will attempt to answer that question.

My original program used a brute force method to loop through all 2,598,960 starting hands and then play all 32 possible ways to discard, including looping through all 1,533,939 replacements cards when discarding all five. This was about the year 1998 and on my computer at the time I determined it would take over a year to finish. Such a program today would only take about a month. Over the years I developed a number of short cuts to get the time down to three seconds. Here is how I did it.

Step 1: To cut down the running time to a few days you can avoid analyzing similar hands on the deal. For example if the starting hand were four aces and a king it would not make any difference what suit the king was. It would save some time to assign an arbitrary suit to the king and multiply the results by four. Using this same logic to all hands I narrowed down the starting hands to just 134,459 kinds. It was a fun exercise doing so. This cut down the running time by 94.83%.

Step 2: To cut down the running time to a few hours avoid scoring the same hands on the draw over and over. It would save lots of time to score each hand just once. At the very beginning score all 2,598,960 hands and put the score of each hand in a big array. This only takes about one second. Now, note that any hand is possible on the draw. Think of the cards on the deal as a set of 5 cards and the possible draw cards as a set of the other 47. You can construct any poker hand using both sets. For any hand on the deal I cycle through all 2,598,960 hands. As I go I record the results in a 32 by 10 array for simple Jacks or Better. The 32 for the 25 ways to play any hand and the 10 for the 10 possible hands in the pay table. As I go I keep a counter going to look up the score of a hand in the array I created at the beginning. When finished I will have an array of each possible outcome for each possible play. Then I take the expected value of each possible play and go with the highest one. This will cut down the run time to about five hours (based on 2004 computers).

Step 3: To get the run time down to about one minute, create a precalculated file of results in a file for each type of game. To create the file will still take a few hours, but to read it will only take about a minute. There should be one line in the file for all 134,459 classes of hands. Each line should have the weighting of the hand, and the number of combinations of all possible hands on the draw crossed by all 32 ways to play the hand. For example, in Jacks or Better there are 10 possible hands on the draw. So each line in the file will have 1 + 10×32 = 321 numbers.

When you read the file, take the dot product of the pay table to the probability of each hand, for all 32 ways to play the hand, which will give you 32 expected values. The maximum expected value is the best play. Multiply that by the weighting and go onto the next line in the precalculated file.

Step 4: To get the run time down to three seconds, save the precalculated file mentioned in step 3 in a binary file. In C/C++ you should use the fwrite comand to do that. Then use the fread command to read the file. The precalculated binary files will be about 236 MBs in size. My thanks to Eliot Jacobson for help with this step.

Links

This site explains how the author speeded up his video poker analzyer from a year to seven seconds.

VP Genius has an outstanding page on programming video poker.

©1998-2008 Wizard Of Odds Consulting, Inc. All rights reserved.   Terms & Conditions   Contact   Advertise   About Us   Links