views:

2697

answers:

7

Hello, 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 :-)

A: 

What about a simulation. Simulate different game strategies a multitude of times and calculate the odds.

Gamecat
+10  A: 

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.

splattne
+6  A: 

Monte carlo simulation is a common approach to get the odds calculation for poker hands. There are plenty of examples of implementing this kind of simulation for holdem on the net.

http://www.codeproject.com/KB/game/MoreTexasHoldemAnalysis1.aspx

Joel Cunningham
+1  A: 

Take a look at pokersource if you have reasonably strong C abilities. It's not simple, I'm afraid, but some of the things you're looking for are complex. The poker-eval program that uses the library will probably do much of what you want if you can get the input format correct (not easy either). Sites such as this one or this also use this library AFAIK.

Still, it could be worse, you could be wanting to calculate something tricky like Omaha Hi-lo...

Mike Woodhouse
+1  A: 

Pokersource and the statistical articles are not bad suggestions. But this is really best done with a Monte Carlo simulation, a useful, simple, and powerful approach to this type of difficult problem.

It works equally well with Omaha Hi-lo as it does with Hold'em

Steve McLeod
A: 

Complete source code for Texas hold'em poker game evaluator can be found here:

http://www.advancedmcode.org/poker-predictor.html

It is built for matlab, the GUI id m-coded but the computational engine is c++.

It allows for odds and probability calculation. It can deal, on my 2.4Ghz laptop, with a 100000 10 players game computation in 0,3 seconds.

An accurate real time computer:-)

Luigi Giaccari