Jump to content

Poker Hand evaluator plugin


JRowe
 Share

Recommended Posts

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
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • 7 months later...
  • 1 month later...
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...