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.)
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.
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 101.11KB 1224 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.