dinsdag 20 november 2007

Card Masquerade

I've found some interesting resources on the Internet on evaluating Poker hands. I chose to use Cactus Kev's method. He uses a single 32 bit int to store the cards rank bitmap, suit, rank and rank prime number. See the site itself for the surprising details!

I had to adjust the Card class to accomodate for the int though. Luckily we have unit tests in place to quickly review the changes. The exported members have not changed, but the internals have been rewritten to directly write to and read from the int bitmask. This way we can quickly implement the hand evaluator.

I will not tire you with the bitwise operations I do, just download the solution below and take a peek at the Card class. If you think what I do could be done better, feel free and let me know :).

For the hand evaluator itself I have found some articles on combinatorial operations and permutations, for that is exactly what we need. Who said Poker is a simple game?

Download entire solution

Geen opmerkingen: