26 April 2010

Poker

Cactus Kev's Poker Hand Evaluator

This doesn't really fit into typical SB7 content, but I found it really interesting.
Cactus Kev's Poker Hand Evaluator
A while ago, I decided to take a shot at writing a poker hand evaluator in the programming language "C". There are already numerous evaluators out there, but I had an idea for an algorithm that might be faster than anything already out there. The basic concept is to write a routine that would take a five card poker hand and return it's overall "value". This is extremely valuable in any poker-related software, since the code will constantly be comparing various player's hand with each other to determine the "winner". Here is my concept on how I thought I could write a fast evaluator.
He gives a walk through of the motivation and techniques used. It's got some good statistics and programming lessons in there. He also includes the C code to make the thing work.

I worked on a class project as an undergrad related to poker and the hand evaluator was a complete pain in the ass to write. We came up with a bunch of possibilities that were (relatively) graceful and a bunch that were (relatively) fast but none that were both. Kev's code hits both of those.


PS Do kids these days even know how to pack multiple variables into single ints and use bitwise ops to extract them? Forget whether they know how to, do they even know it's possible?  I feel like at 26 years old I'm too young to be a cranky old timer, but I'm dismayed how few coders my age know these sorts of techniques that were de rigueur if you learned C.

No comments:

Post a Comment