35

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

4

6 回答 6

23

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.

于 2008-10-11T10:01:48.113 回答
7

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

于 2008-10-11T10:08:09.630 回答
1

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...

于 2008-10-11T10:13:37.933 回答
1

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

于 2008-10-17T12:50:32.683 回答
1

Have a look here as well:

http://specialk-coding.blogspot.com/2010/04/texas-holdem-7-card-evaluator_23.html

Monte Carlo simulation is often slower than the good exact evaluators.

于 2010-06-29T11:55:38.013 回答
0

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

于 2010-02-13T09:28:16.490 回答