Poker Programming

Nerd alert! I recently got back into programming in Java. I started by retrofitting my old Texas Hold’em Odds Calculator so 1) it runs about an order of magnitude faster, and 2) it includes icons for the card suits.

Tenis suggested a new applet to work on: He wants an applet for Texas Hold’em that, given his starting hand, tells him what opponent starting hands would likely beat him and what opponent hands he would likely beat. Because of the sheer combinatorics, I scoped the problem down and refined it a bit: Given your starting hand and the flop, list the percent chance that the given starting hand will beat or be beaten by all other possible starting hands.

I took up the challenge and tonight I finished the engine behind the applet; I still have to write the user interface, which can take a while. While I go do that, here’s some math and sample input/output (let me know if you see any bugs):


  • There are 1,326 (52 choose 2) possible starting hands in Texas Hold’Em
  • Since we’re given your starting hand and the flop, we are left with 1,081 (47 choose 2) starting hands that oppose you
  • We compare your starting hand against each of the 1,081 opponent starting hands one at a time
    • For one such comparison, we know your starting hand, your opponents’ starting hand, and the flop, which leaves 45 cards in the deck for the turn and the river
    • In other words, there are 990 (45 choose 2) possible combinations for the river and turn
  • This means that to analyze one starting hand + flop combination, the applet examines 990 combinations for each of the 1,081 opponent starting hands, or 1,070,190 hand comparisons (990 x 1,081)

Edit: Here’s the first draft of the new Texas Hold’em Matchups calculator

2 thoughts on “Poker Programming

  1. Pingback: The Folding Fool » Blog Archive » Poker Programming

  2. Jon Vish

    I was looking at your work.
    Would you be interested in converting an existing Class III poker game to an on-line play version as a casino game?

    Thank you

Leave a Reply

Your email address will not be published.