Open Side Menu Go to the Top
Register
Creating a poker calculator in Python Creating a poker calculator in Python

03-02-2017 , 03:37 PM
Hello everyone.

I am working on creating a Holdem poker calculator in python. I'm starting off by writing a simple calculator that can take two hands and calculate each hand's equity.

Here is what the program does right now: simply iterate through the 48C5 combos of flops. At each step, find each starting hand's best 5 card hand (from the 21 combinations 7c5), and finally compare the two best five card hands to see which is better or if they are tied. To do this, I created a dictionary of all 52C5 possible 5 card hands that orders them accordingly, so this is what I reference when I compare hands.

As you can imagine, this is very slow. It takes about 10 minutes to do one calculation...

What do you guys think is a better strategy for doing this? One idea to cut down on run time is to figure out some rules for dealing with multiplicities in flops. For example, different combos of AJ9105 will always have the same result if there is no flush draws.

Thank you!
Creating a poker calculator in Python Quote
03-02-2017 , 09:30 PM
Your strategy is a reasonable starting point. I think you should be able to do better than 10 minutes, so probably there are some optimizations you can do.

If memory isn't a factor you could pregenerate the scores for all 7 card hands, and look that up instead of doing 21 lookups per board.
Creating a poker calculator in Python Quote
03-02-2017 , 09:30 PM
You can send it to me if you'd like me to take a look and offer some pointers
Creating a poker calculator in Python Quote
03-02-2017 , 10:57 PM
There was a really good blog called "Coding the Wheel" that may interest you. I'll see if I can find it. I haven't had time to get back to the coding side of things.
Creating a poker calculator in Python Quote
03-02-2017 , 11:06 PM
"Coding the Wheel" was about writing a poker bot, although obviously there is some overlap between that and writing poker tools. I remember reading it when it came out, and I used some techniques from there for sure.
Creating a poker calculator in Python Quote
03-03-2017 , 04:04 AM
probably referring to this particular coding the wheel article

http://web.archive.org/web/200812191...luator-roundup
Creating a poker calculator in Python Quote
03-03-2017 , 02:55 PM
Yes, found it archived here as well.

https://archive.is/www.codingthewheel.com

I'm currently using poker-eval, which is a library available in the Python flavor.

When I first read the article on hand calculators, mind was totally blown.
Creating a poker calculator in Python Quote
03-05-2017 , 02:54 PM
switch to C++
Creating a poker calculator in Python Quote

      
m