How do I programmatically calculate Poker Odds?

Joel Martinez picture Joel Martinez · Oct 11, 2008 · Viewed 42.5k times · Source

I'm trying to write a simple game/utility to calculate poker odds. I know there's plenty of resources that talk about the formulas to do so, but I guess I'm having trouble translating that to code. Particularly, I'm interested in Texas Hold-em ...

I understand that there are several different approaches, one being that you can calculate the odds that you will draw some hand based on the cards you can see. The other approach is calculating the odds that you will win a certain hand. The second approach seems much more complex as you'd have to enter more data (how many players, etc.)

I'm not asking that you write it for me, but some nudges in the right direction would help :-)

Answer

splattne picture splattne · Oct 11, 2008

Here are some links to articles, which could help as starting points: Poker Logic in C# and Fast, Texas Holdem Hand Evaluation and Analysis

"This code snippet will let you calculate poker probabilities the hard way, using C# and .NET."

The theoretical fundamentals are given in this Wikipedia article about Poker Probabilities and in this excellent statistical tutorial.

An example of a complete project written in Objective-C, Java, C/C++ or Python is found at SpecialKEval. Further links and reading can be found therein.