Two Plus Two Publishing LLC
Two Plus Two Publishing LLC
 

Go Back   Two Plus Two Poker Forums > >

Notices

Programming Discussions about computer programming

Reply
 
Thread Tools Display Modes
Old 02-23-2019, 11:21 AM   #1
FCD
stranger
 
Join Date: May 2018
Posts: 8
Python implementation of 2+2 evaluator

Hi all!

Do you know any working version of 2+2 poker evaluator that can be used in Python project?
FCD is offline   Reply With Quote
Old 02-23-2019, 01:25 PM   #2
RustyBrooks
Carpal \'Tunnel
 
RustyBrooks's Avatar
 
Join Date: Feb 2006
Location: Austin, TX
Posts: 24,351
Re: Python implementation of 2+2 evaluator

I'm not that familiar with the evaluator, but if it's written in C or C++ it should not be too hard to make a python wrapper for it.
RustyBrooks is offline   Reply With Quote
Old 02-24-2019, 08:26 PM   #3
ungarop
journeyman
 
ungarop's Avatar
 
Join Date: Dec 2004
Location: MA
Posts: 340
Re: Python implementation of 2+2 evaluator

OP, I assume you mean this code:
https://github.com/tangentforks/TwoPlusTwoHandEvaluator

If so, RustyBrooks has the right idea. Cython wrapper:
https://medium.com/@shamir.stav_8331...n-b09db35012a3

Ref to 2017 thread about evaluator that has links to the original thread:
https://forumserver.twoplustwo.com/1...stion-1685353/
ungarop is offline   Reply With Quote
Old 02-25-2019, 02:49 AM   #4
FCD
stranger
 
Join Date: May 2018
Posts: 8
Re: Python implementation of 2+2 evaluator

I should expect quite big drop in efficiency, shouldn't I? Thanks for the answers.
FCD is offline   Reply With Quote
Old 02-25-2019, 08:18 AM   #5
just_grindin
Pooh-Bah
 
Join Date: Dec 2007
Posts: 4,877
Re: Python implementation of 2+2 evaluator

Quote:
Originally Posted by FCD View Post
I should expect quite big drop in efficiency, shouldn't I? Thanks for the answers.
Reading the tutorial your C/C++ will be compiled so you should have the speed benefit of that language.

The wrapper just lets you make calls and receive output from your python code. The bulk of the evaluator will still execute in the c code so I wouldn't expect a huge loss in efficiency.
just_grindin is offline   Reply With Quote
Old 02-26-2019, 05:12 AM   #6
plexiq
veteran
 
Join Date: Apr 2007
Location: Vienna
Posts: 2,003
Re: Python implementation of 2+2 evaluator

Unless I'm mixing up the 2+2 evaluator with another one, an evaluation is really just 7 consecutive reads from a large integer array.

Idk much about Python performance, but if you are doing individual hand evaluations through a C wrapper then that's probably going to see a massive performance hit. That just based on the fact that a single evaluation is nothing more than a bunch of array reads, even a fairly efficient wrapper is likely going to introduce significant overhead there. If you are doing entire enumerations with a single call to the C library, that's a different story and you'd probably get very close to the C performance.

For individual evaluations you are probably better off to read the lookup array into Python and then do the evaluation there, there's no actual hand evaluation code beyond generating the lookup table. Or use an entirely different evaluator, as the 2+2 one isn't very efficient for individual/random evaluations anyway.
plexiq is offline   Reply With Quote
Old 03-04-2019, 06:51 AM   #7
FCD
stranger
 
Join Date: May 2018
Posts: 8
Re: Python implementation of 2+2 evaluator

Did you guys think to create a poker evaluator working on GPU? Sounds like a possible thing to me considering all paralellization possibilities when simulating new hands.
FCD is offline   Reply With Quote
Old 03-04-2019, 07:46 AM   #8
adios
Carpal \'Tunnel
 
Join Date: Sep 2002
Location: Russian Troll
Posts: 21,497
Re: Python implementation of 2+2 evaluator

Quote:
Originally Posted by FCD View Post
Did you guys think to create a poker evaluator working on GPU? Sounds like a possible thing to me considering all paralellization possibilities when simulating new hands.
What OS would run on the GPU? Not windows. Linux maybe?

Is there a single core processor running on recent desktops today? You donít need a GPU to implement parallel algorithms.
adios is offline   Reply With Quote
Old 03-04-2019, 08:04 AM   #9
plexiq
veteran
 
Join Date: Apr 2007
Location: Vienna
Posts: 2,003
Re: Python implementation of 2+2 evaluator

@adios High end GPUs can run more than hundred times as many floating point operations per second than a high end CPU of comparable cost. But GPUs are only efficient for certain types of work loads.

Quote:
Originally Posted by FCD View Post
Did you guys think to create a poker evaluator working on GPU? Sounds like a possible thing to me considering all paralellization possibilities when simulating new hands.
Yes, it's possible to run 7 card evaluations on the GPU in principle. The 2+2 evaluator would be trivial to run on a GPU, although I believe it would have bad performance due to the GPU memory model. Whether it makes sense to run hand evaluations on the GPU in general depends on what you are trying to do. Hand evaluations rarely make up a significant chunk of the overall runtime anyway.
plexiq is offline   Reply With Quote
Old 03-04-2019, 08:04 AM   #10
just_grindin
Pooh-Bah
 
Join Date: Dec 2007
Posts: 4,877
Re: Python implementation of 2+2 evaluator

Quote:
Originally Posted by FCD View Post
Did you guys think to create a poker evaluator working on GPU? Sounds like a possible thing to me considering all paralellization possibilities when simulating new hands.
I was under the impression that the benefit of a GPU wasn't running things in parallel.

The GPU is better at manipulating vectors so if your algorithm or part of your algorithem is intensive vector manipulation the GPU can provide you better performance.
just_grindin is offline   Reply With Quote
Old 03-04-2019, 02:05 PM   #11
RustyBrooks
Carpal \'Tunnel
 
RustyBrooks's Avatar
 
Join Date: Feb 2006
Location: Austin, TX
Posts: 24,351
Re: Python implementation of 2+2 evaluator

You don't run an OS on the GPU - you use a programming paradigm like CUDA.

Running things on a GPU provides massive parallelization if the problem can be broken up appropriately. Modern GPUs have thousands of small cores - like the nvidia 1080 Tis has 3500-something cores. Like plexiq said, I don't think you'd get a lot of benefit here because the cores would all be fighting for their own memory.

I've been out of the space for a long time but there were people doing really amazing graph theory algorithm stuff on GPUs years ago.
RustyBrooks is offline   Reply With Quote
Old 03-05-2019, 03:50 PM   #12
FCD
stranger
 
Join Date: May 2018
Posts: 8
Re: Python implementation of 2+2 evaluator

I'll just have this idea in mind. Lookup tables aren't the best way to aproach this problem but I believe there's a way to treat it in a more gpu friendly manner. I'll let you know in case I figure out something. I'm sure there's a bunch of low, high-level language developers who would like to use it. Cheers

Last edited by FCD; 03-05-2019 at 03:55 PM.
FCD is offline   Reply With Quote
Old 03-05-2019, 05:04 PM   #13
plexiq
veteran
 
Join Date: Apr 2007
Location: Vienna
Posts: 2,003
Re: Python implementation of 2+2 evaluator

Idk, what's your use case for a GPU accelerated hand evaluator?

As I mentioned before, the hand evaluator is almost never the bottleneck unless you just want a plain equity calculator. And these run fast enough even with regular evaluators.
plexiq is offline   Reply With Quote
Old 03-06-2019, 10:35 AM   #14
FCD
stranger
 
Join Date: May 2018
Posts: 8
Re: Python implementation of 2+2 evaluator

There was going some kind of a competition which algorithm is faster. That would be just cool to create an algorithm for Python as fast as C++ 2+2 evaluator. Coding is fun. Nothing beyond that
FCD is offline   Reply With Quote
Old 03-14-2019, 03:22 PM   #15
PokerHero77
old hand
 
Join Date: Oct 2008
Posts: 1,429
Re: Python implementation of 2+2 evaluator

The 2+2 evaluator would not be a good candidate for GPUs.

There is an evaluator that I'm working on converting to a GPU that is comparatively fast (about 1 second on my Dell to evaluate all 133,784,560 7 card combinations in Java). It involves clever bit-shifting which a GPU can do well. The code uses 1 IF statement which I am in the process of removing, which as you may know kills GPU performance.
PokerHero77 is offline   Reply With Quote

Reply
      

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Forum Jump


All times are GMT -4. The time now is 10:10 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
Copyright © 2008-2017, Two Plus Two Interactive
 
 
Poker Players - Streaming Live Online