Video Poker Analyzer

This page holds an applet I wrote to help me learn the best strategies to use while playing video poker.  I was telling a friend about this and he told me that the best way to win was to be the house.  :-)

Barring that you own the casino, if you like to play video poker you should at least have some fair idea of strategy.  It can greatly increase your money return at casinos and poker sites.  Some games, if played perfectly, can give you odds of just over 100% return.  I won't go into those here, because there are other pages devoted to this information.  Some resources I've collected:

Scroll to bottom for translations

This page is geared towards people who are already familiar with how to play video poker and want to use my applet to practice and learn how to play best.  For example, if you are dealt a face card and a pair of fives and two useless cards-what do you hold?  Do you hold the face card?  Or the pair of fives?  I used to wonder this same question until I wrote this program and started playing with it.  The answer may depend on the payscale on the particular machine, but generally here's the deal: the face card has the best chance of being part of a winning hand because you have a fair chance of getting "jacks or better", however the pair of fives has the best return on investment. This is because the pair of fives has a greater chance of being part of a "three of a kind", "four of a kind", or "full house" than the single face card.  So, if you play a lot of hands, holding the fives is the best long term strategy.  If this doesn't make sense, play with the applet below, wait until you get a face card and a pair under jacks in one hand and then look at the odds.

NOTE: this applet uses the OBJECT tag format. It should run on IE and Netscape on Windows and Solaris platforms. It might ask you to download a plug-in if you don't have java 1.3 plug-in enabled on your system, unfortunately this plug-in is about 5Megs and can take a while to download over a modem.  I'm sorry about this, but my applet wouldn't run on Microsoft's Java Virtual Machine with IE5.5, so I did it this way so everyone would be able to run the applet.  If this doesn't run on your system, please email me at jesse_pangburn@yahoo.com, tell me what OS you have(like Windows 98, etc) and what browser version you have and what the error message was, and I'll try to either help you fix it or modify my page if required.

How to Use the Program:

Here's a screenshot for referencing during this explanation:

The top left box shows the pay scale for this video poker game, this tells you how much money you get for a given hand.  The top right box shows the current cash you have (you start with 20 credits, and pay 1 for your first hand so it says 19) and tells you what kind of a hand you have.  The hand type indicator turns red when you have a hand worth money so that it catches your eye, and black when your hand is worth "zilch".

Obviously, the middle box is your hand.  Clicking on a card with your mouse tells the game that you want to "hold" this card, then when you click the "draw" button the other cards are thrown away and you get dealt replacements for them.  Sometimes when you click it doesn't select the card, just click again.  This seems to depend on the user, some people have no trouble, others do.  I'll try to fix this so it works better, but it's certainly usable as is.  

The bottom left box contains the "draw/deal" and "Switch Game" buttons.  The "draw/deal" button indicates what state the online poker game is in.  If it says "draw" then you want to select the cards you want to keep, then hit it.  After the game gives you your new cards, it evaluates your hand and adds your winnings (if any) to your cash amount.  At this point, this hand is over so the button now says "deal".  Clicking on it will take one credit and deal you a new hand.  The "Switch Game" button allows you to switch to the poker game selected in the selection box below ("Double Bonus" poker in my screenshot).  This will also reset your cash to 20.  
UPDATE May 2009- The bottom left box now contains a "choose your own hand" text field to allow you to specify your own hand.  This allows you to analyze specific scenarios you may be curious about without waiting for the game to randomly come up with a similar card set while playing.  There is no substitute for practice to get good at Video Poker, as with anything else, but enough people sent me a request for this feature because they came across certain hands and weren't sure of the best course of action. To play the game normally and get that good practice in, just leave it blank. Specify a hand by entering two characters for all 5 cards. First choose the value (using 0 for 10, 3 for 3, J for Jack, etc.) then the suit (H-hearts, D-diamonds, S-spades, and C-clubs). See the screenshot above for an example. After you hit the "deal" button, these cards will show up. Then you can try your various holding options and analyze them to see which is best.

The bottom right panel is the Odds Analysis panel.  This is where, after you've been dealt a hand, you can select different cards to hold and analyze your odds.  In this hand I held the "Ace of spades" and "Queen of hearts" and clicked the "Run Analysis" button.  You can hold any number of cards when analyzing, including all cards or none (warning: if your computer is slow, analyzing with no cards selected may take a while!).  The two important parts are the "Payout / number of Hands" part and the "Winning hands / num Hands".  The "Payout / number of Hands" tells you the total payout for all possible hands you could be dealt holding the cards you have chosen.  In my example, holding the Ace and Queen, the total payout amount of all possible hands that I could get is 7755.  This is divided by the total possible number of hands (16215) to arrive at a figure of "0.4782".  This means that from this hand, I am likely to get back 43 cents on the dollar.  This number is an average, it doesn't mean that I couldn't get a royal flush and get 800 coins back.  If you don't understand what I mean, then understand this: the higher this number is, the better.  The other figure is "Winning hands / num hands" which tells you how many of the possible hands you could be dealt are winners out of the total possible possible hands.  This number is a percentage which tells you how likely you are to win any amount at all from this hand.  In my case, holding the ace and queen means that I have a 37.60% chance to win something on this hand.  

Clearly, the "Payout / number of Hands" figure is the most important.  If you play with this applet for a while, and learn how to hold your cards to maximize this number, then over the long run you will have a better return of money.  NOTE: this only applies to games with THIS PAYSCALE, this is very important.  If a game has a payscale different from the one shown on the applet, then the best strategy is probably slightly to very different for that game.  For example, some games have different payouts for different "four of a kind" hands, and this could affect your best holding choices significantly.

The "Winning hands / num Hands" figure is interesting, because it tells you how likely you are to win something with this hand, but if you choose to maximize it over the"Payout / number of Hands" figure, then you will have more winning hands but you will lose more money in the long run as your average return will be lower.  Some people play this way because they want to get something back as often as possible, even though this is not the best strategy.

The "Payout Analysis Breakdown" shows for all the possible hands you could get while holding the card(s) you are holding, how many of each winning hand are in that set.  It also does the math for you and shows you the total payout for each type of hand.  The sum of these amounts is the same as the "Payout" part of the "Payout / number of Hands" figure.

Updates

Since the first version I posted here, I've added sounds for stuff, which helps clarify what state the game is in and tells you when you win, etc.  I've changed the Jacks or Better payscale to the version known as "full pay".  I've added the ability to switch to Bonus Poker and back to Jacks or Better.

I'd still like to add the ability to modify the payout amount for a given game so you can tailor it to the payscale you use.. I'll get to this stuff when I get a chance.  

If anything is not clear, or you have a suggestion for a new feature, email me at jesse_pangburn@yahoo.com.

The Source Code

I'm making the source code available under the GNU Public License.  This means you are free to use and modify the code, and I provide a compiled version that you can use right away and also the source code so that you may make further changes.  Here's the disclaimer: 

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You can read about the GPL here: http://www.fsf.org/copyleft/gpl.html.

I provide the source code in a java jar file VPA_code.jar, so everyone on any system with java can open it and use it (why zip or tar java files, when you can jar them?  I've seen people do this, doesn't it seem pretty ironic to distribute java source code in a platform dependent format?)  To extract the files from the jar, use this command:

jar xvf VPA_code.jar

This should extract the files in a Windows or *nix environment, sorry Mac people, I don't know how to use a Mac so I can't tell you how either.  I'm using Sun's JDK 1.3 to compile and execute this code, although it MIGHT work in a 1.2 environment since I tried compiling with 1.2 VM set as the target VM, and it worked.  If it doesn't work in a 1.2 environment, don't ask me why, I won't know.

To compile and run the code, use the following two commands:

javac *.java
appletviewer VPA.html

I'm providing this source code so that you can add to the list of available games, currently only Jacks Or Better (full pay version) and Double Bonus Poker.  It's super easy to add another game (assuming you have even a small amount of Java programming experience).  The basic idea is that there's an abstract class called Payout and you just subclass it to make a new game.  Here's the step-by-step:

  1. Copy the JacksOrBetterPayout.java file to a new file with the name of the game you want to add, let's suppose it's called "MyPoker".  The new file should be "MyPoker.java".
  2. Edit this file to make a class called MyPoker, following the model in JacksOrBetterPayout class, to implement the payout box and determine the value of hands passed to it.  This requires a small amount of programming ability on your part.  You should modify the constructor to name your game, the checkHand function to check the hands in your game, and the payoutValues and payoutNames arrays to hold the payout information for your game.  This is very easy since most of the code for checking the various hands is already implemented.  You can also use the DoubleBonusPayout class as another example
  3. Open the VPA.java file.  On line 87 is the combo box for selecting the different games, add your game to the list.  On line 129 is an if-else statement, modify it to check the combo box for the game you just added (careful to match the spelling and case exactly).
  4. Compile, test, debug, enjoy.
  5. If it works, please send me the modified code files so I can post the applet with my games and your game(s) here for others to enjoy.  I'll post your name and give you credit for the game(s) you added.

Source Code File Listing

Here's a list of the files in the VPA_code.jar file, and what they are for.

filesystem.attributes - don't know, it think the IDE I'm using makes it
VPA_IE_and_Netscape.html - code to use Sun's VM in the browser for IE and Netscape, requires that you compile the code and stick it in VPA.jar and put this file in a subdirectory called applets.  This is for posting on a webserver.
VPA_IE_only.html - test page that uses the VPA.class file directly.  Allows you to use IE to test code changes without putting the files in a jar first.
VPA.html - appletviewer file for testing code changes.  This is the fastest method, in my opinion.  "appletviewer VPA.html"
CardConstants.java - an interface definition file for holding constants related to the cards
CardDeck.java - the class implementing a 52 card deck
Card.java - the class implementing a single card
DoubleBonusPayout.java - a subclass of Payout used for running the "DoubleBonus" game version
JacksOrBetterPayout.java - a subclass of Payout used for running the "JacksOrBetter"game version
OddsAnalysis.java - the class for analyzing the odds of the game
Payout.java - an abstract class which you subclass to create different games
ScoreKeeper.java - the class that keeps track of your score, and visually identifies the hand that you are holding
SoundPlayer.java - the class that handles playing sounds for the various events in the game
VPA.java - subclass of JApplet, this is the main class
club.jpg - JPG for the club symbol (drew it myself, that's why it's so poor)
diamond.jpg - JPG for the diamond symbol (ditto)
heart.jpg - JPG for the heart symbol (ditto)
spade.jpg - JPG for the spade symbol (ditto)
payscales.txt - the payscales used for JacksOrBetter and DoubleBonus games
cardDeal.wav - sound for dealing cards with nothing good in the hand
click.wav - sound for clicking on a card
goodDeal.wav - sound for dealing cards with something of value in the hand
win.wav - sound for when you win money

There are also a bunch of class files in there, but they are just the compiled versions of the java files, so I'm not bothering to explain twice.

Again, if anything is not clear, or you'd just like a clarification, or I left some critical step out altogether, please email me at jesse_pangburn@yahoo.com.

Translations available: