Poker probability
May 3, 2007 Poker No CommentsI’ve started to write a software to assist players when playing real parties. It aims to calculate probabilities when 2 or more players get all-in as we can see on TV. It will also manage a timer and the differents levels for the blinds.
I’ve not yet published the source but it’ll happen soon, I wait to have a first command line calculator which works. The main problem will be optimization.
In order to wait, I will explain the big lines of the algorithm.
I’ve left conditionnal probabilities for now since it seems awfull to write and really complex in term of calculation. What I forgot to say is that it shoult compute the result in real time (less thant 10 sec I would say).
My approach has been to compute all combinations of 5, 2 and 1 cards and to store it in files. Thus, when 2 players get all-in, I iterate on the 2 millions hands of 5 cards, add their 2 cards hand and compare which one win. A counter for each player is managed to know at the end of the iteration, what are the probabilities.
The first problem is to find quickly what is the kind of a hand (card high, pair, …) et next to find if a hand is better than another. To find the kind of the 7 cards hand, I start to check from the better combination (Royal Flush) to the worth. I choose this solution because you go less deep in each algorithm when it’s not validated. Beginning to check for pair will more often returns true without excluding to have a better hand, so you need to check for the better kind of hand. Now, it’s also right for some kinds of hands when you start from the higher. If your 7 cards don’t make a Royal Flush, they can be a Flush or Straight, but if they aren’t a neither a Flush nor a Straight, it can’t be a Royal Flush. It’s not a big problem to reverse the checks, so I will make my choice later.
The second problem is to compare two kinds of hand. For a human, it’s easy and quick to know that a Full House Ace on Ten is better than a Straight Ace High but for a computer, it requires a lot of comparison. That’s why I try to find the better binary representation of a hand to make a comparison between bits. That’s the problem I’m currently working on.
For now, the code is in Python, but I may switch to C++ if I can’t get real time computation. I’ve not yet run a computation so I’ve no idea if my way is good.
Any advice or interest are welcome ![]()
