# Ranking a seven card hand

I was browsing through the net for a fast poker simulation. I stumbled upon this amazing look up table “HandRanks.dat”. This is some 125 Meg table of some 32 million entries. With this table you can rank any seven card hand with just seven look ups.

In C it will be, say you have read the file and loaded in an array called hr. You have cards c1,c2...c7, all in numeric, 2c as 1, 2d as 2Ah as 51 and As as 52. Following seven look ups will give the rank of the hand:
p = 53;
p = hr[p+c1];
p = hr[p+c2];
:
:
p = hr[p+c7]

The final p will give the type (flush, full house) and rank.

For example if you give As Ks Qs Js 10s x x, p will give type as 9 (straight flush) and rank as 10, tenth rank of straight flush. For ac 2c 3c 4c 5c x x, type will be 9 again and rank will be 1, first rank of straight flush. Higher the values, higher the hand. (Few more examples: 8c 8d 8s 2c 2d x x, type 7 (full house), rank 73, 2c 3c ac 7s 8s 2s 4s, type 2(pair), rank 180, 2c 2s 3s 4h 5s 7d 8d, type 2, rank 19) With few look ups you can find the rank of any hand. It takes only micro seconds, claim is that it can evaluate several hundred million hands in a second.

The idea was first conceived by one Cactus Kev , and given a final shape by Ray Wotton and Co. This was way back in 2007, since then several improvements are made. But still this table is widely used in poker simulation softwares and game sites, for its simplicity and efficiency.

You may go through these two links and the forum referred there, its an interesting read.

1 Like

Intrigued. Will have to check this out when I have a little more time.