(no subject)

Dec 28, 2008 20:19

I converted http://www.suffecool.net/poker/evaluator.html to Common Lisp code. Instead of looping/recursing over all 21 seven-card hand combinations, I wrote a macro to expand to what is basically an unrolled loop that checks them all and returns the best value. I have implementations of both versions, the original binary-search version, and the faster perfect hash version. The hash function depends on 32 bit word overflow occurring (but ignores the overflow bit), so I had to (ldb (byte 32 0) ...) around any calls to + in the hash function to get it to work.

Using a test function that loops over every possible five-card hand, the perfect hash version evaluates them all in about one second - most of that is hash-table accesses to keep the hand statistics. The binary search version takes a little over two seconds.

Now that I have that evaluator, I'm pondering converting the 2+2 evaluator as well, assuming I can write code to generate the lookup tables correctly. (The code for that evaluator is dead simple, and the card representation is just a positive integer less than 52)
Previous post Next post
Up