Poker Hand evaluator plugin

40 posts in this topic

#1 ·  Posted (edited)

I wrote/wrapped this up last year, and it's geared to evaluate a 5, 6, or 7 card hand, meaning it can tell you, given 7 cards, what the best 5 card hand you can make from the cards, how strong that hand is within it's own category (such as, 4 of a kind sixes will beat four of a kind fives.)

It's based on the Two+Two forum brilliance, using a hash table (a 123 mb table of every possible 5, 6, and 7 card hand.)

http://www.codingthewheel.com/archives/poker-hand-evaluator-roundup#2p2

This is fast. It can evaluate 1 million hands in 28 seconds, ymmv.

There are 4 functions:

LoadHRDat()
AnalyzeHand($iCardOne, $iCardTwo, $iCardThree, $iCardFour, $iCardFive, $iCardSix, $iCardSeven)
AnalyzeHand6($iCardOne, $iCardTwo, $iCardThree, $iCardFour, $iCardFive, $iCardSix)
AnalyzeHand5($iCardOne, $iCardTwo, $iCardThree, $iCardFour, $iCardFive)

You need to have the HandRanks.dat file in your script directory, LoadHRDat() expects to find it there. I could make it more user friendly, but I'm not sure why it would ever need that, at this point. :)

The functions return a hash value.

$HandCategory = BitShift($Analysis, 12)
            $HandRankWithinCategory = BitAND($Analysis, 0x00000FFF)

You need to perform a BitShift($return, 12) to get the hand category.

You need to perform a BitAND($return, 0x00000FFF) to get the hand rank within that category.

There are 9 categories. 1 is the lowest ranking, the highest rank depends on the category.

A hand that tells you it is category 4, rank 858, means you've got 3 aces, a King, and a Queen, the best possible 3 of a kind. Rank 1 would be 3 deuces, a three, and a four.

I have some helper code packaged up to interpret the information to english, these are _CardList.au3, _HandCategories.au3, and _HandStrength.au3. These denote the cards, the types of categories, and a normalized database of every 5 card hand (no variation.) They allow you to translate the results into english.

_HandEval.rar

To use: run XPokerEval.TwoPlusTwo.exe to create the HandRanks.dat database, then run RandomHandGenerator.au3 to generate random hands and see the results of evaluation.The hands database is important, without it the functions won't work. DealAHandOptimum() is a nice function if you want to generate your own random card hands.

Or, download and unrar HandRanks.dat from here.

And yes. Yes, I know. :)

Edited by JRowe
1 person likes this

Share this post


Link to post
Share on other sites



#2 ·  Posted

Sorry to bother you. I have a problem. XPokerEval.TwoPlusTwo.exe crashed (Error executing program). HandRanks.dat has not been created. Does it work for WinXP?

Share this post


Link to post
Share on other sites

#3 ·  Posted

Share this post


Link to post
Share on other sites

#4 ·  Posted

Share this post


Link to post
Share on other sites

#5 ·  Posted

Thank you for the upload. I feel quite dumb because i have another problem. Am i supposed to use newer version than 3.3.0.0? Or Am i missing any other #include? Thank you for you time.

Posted Image

Share this post


Link to post
Share on other sites

#6 ·  Posted

Did you download Handeval.rar?

You need the plugin dll in the same directory as HandRanks.dat and the the demo script. Sorry I wasn't more explicit.

Share this post


Link to post
Share on other sites

#7 ·  Posted

Unfortunately, I have all parts in the same directory (Demo script,HandRanks.dat,handEval.dll).

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Sounds like an msvc runtime distributable issue. Lemme figure out which one you need and I'll link it.

Here we be:

Install this: http://www.microsoft.com/downloadS/details.aspx?familyid=9B2DA534-3E03-4391-8A4D-074B9F2BC1BF&displaylang=en

Edited by JRowe

Share this post


Link to post
Share on other sites

#9 ·  Posted

It still doesn't know LoadHRDat(). I am sorry to be annoying. Maybe i should give up this.

Share this post


Link to post
Share on other sites

#10 ·  Posted

Are you using 3.3.0.0? It looks as if the "#AutoIt3Wrapper_Plugin_Funcs= LoadHRDat, AnalyzeHand" is missing from RandomHandGenerator.au3, but I've double checked and its there.

Sorry you're having issues, really not sure what they might be... are you running x64 AutoIt? What are your machine specs?

Share this post


Link to post
Share on other sites

#11 ·  Posted

I am using AutoIt 3.3.0.0 (not x64) and WinXP SP3 (not 64), AMD Athlon Dual Core 64x2, 2.40GHz, 2GB RAM and so on..

I thought there is something wrong with #AutoIt3Wrapper_Plugin_Funcs too. But i didn't find out what it could be.

There is no reason you should be sorry. It seems there is a problem between my monitor and my chair :)

Share this post


Link to post
Share on other sites

#12 ·  Posted

Ok, I recreated the error. The problem is the plugin dll not being in the correct location, or not being read from the correct location. Is handEval.dll in the same directory?

Try replacing line 10 of RandomHandGenerator with this:

$handEval = PluginOpen(@ScriptDir & "\handEval.dll")

Or replacing it with the explicit path to the file.

Share this post


Link to post
Share on other sites

#13 ·  Posted

I tried, but it returns the same result. I also checked that there was no read-only things or so..

Share this post


Link to post
Share on other sites

#14 ·  Posted

Are you using 7zip to unrar the file? If so, download winrar and unrar it with that. I've had file corruption errors before from 7zip that weren't immediately apparent. Vice versa too, I'm not bashing 7zip, it's just that there's sometimes issues with using one program on a file compressed by the other.

Something is screwing up the handEval.dll . Since it's not the redistributable, the OS, or the AutoIt version, I'm guessing it's the download and/or the uncompression.

Share this post


Link to post
Share on other sites

#15 ·  Posted

I am using winrar. I must admit I have never worked with 7zip.

Share this post


Link to post
Share on other sites

#16 ·  Posted

Only thing I can recommend is to compile it yourself. Sometime in the next week, I'll upload the source code for the plugin and link to the source for xPokerEval. If you haven't already, download the express edition of Visual C++ from Microsoft.

Share this post


Link to post
Share on other sites

#17 ·  Posted

Nice. Thank you!

Share this post


Link to post
Share on other sites

#18 ·  Posted

any news on this topic ?

I'd love to try this out but I get the same errors...

Share this post


Link to post
Share on other sites

#19 ·  Posted

any news on this topic ?

I'd love to try this out but I get the same errors...

The link for the HandRanks.dat file is bad.

Do you have another ?

Thanks

Share this post


Link to post
Share on other sites

#20 ·  Posted

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now