Rank7 – a seven card hand evaluator

February 27, 2010

Rank7 is a seven card poker hand evaluator. It uses a series of small lookup tables to evaluate the rank of a poker card. The rank can be used to determine which hand wins at a showdown.

To use this hand evaluator, you will need both rank7.c and rank7.gz as well as zlib, which should come standard on any system worth using.

This hand evaluator is based on the simple observation that in a poker hand, the suit of the cards either matters, or it does not. That is, we can create two lookup tables, one for subsets of cards of the same suit, and one for groups of cards where suit is irrelevant. Indexing into each of these tables is not incredibly difficult, but to speed this process I use two finite automata in the form of yet another table. This technique is similar to that of the famed 2+2 hand evaluator, except my tables use over 100x less memory.

I used the poker-eval hand evaluator to create my rank tables. My evaluator is over 40% faster than poker-eval on my machine and ranks over six million hands per second on my machine. It is likely a tad slower than the 2+2 evaluator, but I would expect it to be competitive.

Kevin Waugh