Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

Poker Hand evaluator plugin


  • Please log in to reply
37 replies to this topic

#1 JRowe

JRowe

    Chasing the white rabbits

  • Active Members
  • PipPipPipPipPipPip
  • 1,765 posts

Posted 18 October 2009 - 07:08 AM

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.

Attached File  _HandEval.rar   101.11KB   1204 downloads

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, 22 October 2009 - 11:00 AM.

  • Geir1983 likes this







#2 Horrendous

Horrendous

    Seeker

  • Active Members
  • 16 posts

Posted 22 October 2009 - 10:50 AM

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?

#3 JRowe

JRowe

    Chasing the white rabbits

  • Active Members
  • PipPipPipPipPipPip
  • 1,765 posts

Posted 22 October 2009 - 10:51 AM

Aye, I built it on xp. I'll see what I missed.

#4 JRowe

JRowe

    Chasing the white rabbits

  • Active Members
  • PipPipPipPipPipPip
  • 1,765 posts

Posted 22 October 2009 - 11:01 AM

Updated the first post, here's what you need.

#5 Horrendous

Horrendous

    Seeker

  • Active Members
  • 16 posts

Posted 22 October 2009 - 11:58 AM

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

#6 JRowe

JRowe

    Chasing the white rabbits

  • Active Members
  • PipPipPipPipPipPip
  • 1,765 posts

Posted 22 October 2009 - 12:08 PM

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.

#7 Horrendous

Horrendous

    Seeker

  • Active Members
  • 16 posts

Posted 22 October 2009 - 03:25 PM

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

#8 JRowe

JRowe

    Chasing the white rabbits

  • Active Members
  • PipPipPipPipPipPip
  • 1,765 posts

Posted 22 October 2009 - 05:23 PM

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, 22 October 2009 - 05:24 PM.


#9 Horrendous

Horrendous

    Seeker

  • Active Members
  • 16 posts

Posted 22 October 2009 - 06:03 PM

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

#10 JRowe

JRowe

    Chasing the white rabbits

  • Active Members
  • PipPipPipPipPipPip
  • 1,765 posts

Posted 22 October 2009 - 06:44 PM

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?

#11 Horrendous

Horrendous

    Seeker

  • Active Members
  • 16 posts

Posted 22 October 2009 - 07:07 PM

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

#12 JRowe

JRowe

    Chasing the white rabbits

  • Active Members
  • PipPipPipPipPipPip
  • 1,765 posts

Posted 22 October 2009 - 07:13 PM

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.

#13 Horrendous

Horrendous

    Seeker

  • Active Members
  • 16 posts

Posted 22 October 2009 - 07:22 PM

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

#14 JRowe

JRowe

    Chasing the white rabbits

  • Active Members
  • PipPipPipPipPipPip
  • 1,765 posts

Posted 22 October 2009 - 07:40 PM

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.

#15 Horrendous

Horrendous

    Seeker

  • Active Members
  • 16 posts

Posted 23 October 2009 - 07:31 AM

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

#16 JRowe

JRowe

    Chasing the white rabbits

  • Active Members
  • PipPipPipPipPipPip
  • 1,765 posts

Posted 23 October 2009 - 09:17 AM

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.

#17 Horrendous

Horrendous

    Seeker

  • Active Members
  • 16 posts

Posted 23 October 2009 - 09:56 AM

Nice. Thank you!

#18 tito

tito

    Wayfarer

  • Active Members
  • Pip
  • 54 posts

Posted 13 June 2010 - 06:58 PM

any news on this topic ?
I'd love to try this out but I get the same errors...

#19 pierrotm777

pierrotm777

    Wayfarer

  • Active Members
  • Pip
  • 91 posts

Posted 14 June 2010 - 09:40 AM

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

#20 JRowe

JRowe

    Chasing the white rabbits

  • Active Members
  • PipPipPipPipPipPip
  • 1,765 posts

Posted 10 August 2010 - 08:55 PM

Use _XPokerEval.twoplustwo.exe to generate the HandRanks.dat file on your system.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users