Texas Hold'em Poker hand evaluator

Advanced game related topics
aaron
Enthusiast
Enthusiast
Posts: 267
Joined: Mon Apr 19, 2004 3:04 am
Location: Canada
Contact:

Texas Hold'em Poker hand evaluator

Post by aaron »

Well, I've been intrigued by the texas hold'em poker craze, but my gameplay sucks pretty bad. So I sat down and tried to put together a poker hand evaluator so I could learn to judge the strength of hands. My first attempt wasn't too bad. It took roughly 16 seconds to evaluate 1 million 7-card hands. The problem was that it wasn't too hard to compare 2 players hands against each other but it become a little ugly when doing more. :x

I took a look on the net and ran across this website: http://www.suffecool.net/poker/evaluator.html He is using massive look-up tables to shortcut the ranking. The code is pretty easy so I converted it over to purebasic and gave it a shot. It takes about 5 seconds to rank 1 million 7 card hands. Not too shabby. :idea:

I've uploaded the converted code for everyone here: http://www.slightlystunned.com/purebasic/pokertest2.pb

My next step is to set it up so it can judge the relative strength of a hand at the various betting points in texas hold'em and then maybe make a little toy AI for me to play against. :D
User avatar
Rook Zimbabwe
Addict
Addict
Posts: 4322
Joined: Tue Jan 02, 2007 8:16 pm
Location: Cypress TX
Contact:

Post by Rook Zimbabwe »

If you want the code I developed (My Head 2 Head Hold'em Game will be out by Sept 30) with Demivecs help... I can probably find an earlier version for you to play with. Might take a few days though!

:D
Binarily speaking... it takes 10 to Tango!!!

Image
http://www.bluemesapc.com/
aaron
Enthusiast
Enthusiast
Posts: 267
Joined: Mon Apr 19, 2004 3:04 am
Location: Canada
Contact:

Post by aaron »

That would be cool. My own evaluator used a single pass scheme to judge the 7 cards rather than the multi-pass scheme of the code I posted. I figured that the single pass would be faster but I had to sort the cards once at the start to make it easier to find the various hands... possibly that slowed the whole thing down.

Initially I was running the new code with the debugger on (didn't even think about it) and it was taking almost 7 seconds to run through all 2.4 million 5-card hands, in comparison to the C version which was taking a fraction of a second. When I turned off the debugger I was stunned to see it drop to around 300ms. Ha ha... still a little slower than the raw C code but not too bad for being completely unoptimized in terms of Purebasic code.

I tried integrating the code from this page : http://senzee.blogspot.com/2006/06/some ... -hash.html in order to speed it up even more but ran into troubles with it working. I haven't looked too closely at it but it looks like its maybe an issue with unsigned/signed and the highest bit of a long not behaving as expected.
Post Reply