Quote Originally Posted by Milk View Post
Have you come across the The Great Poker Hand Evaluator Roundup. It discusses a few cunning poker hand evaluation tricks.

Did you come across the bit counting algorithm at that stanford Bit Twiddling Hacks page? I love that page.

The following occurred to me on my way home, likely not as quick as an array look up but an improvement on what you had.
Code:
     public static int CountConsecutiveBits(int value)
        {
            int ct=0;
            while (value != 0)
            {
                ct++;
                value &= (value << 1);
            }
            return ct;
        }
it counts consecutive bits but it will only loop as many times as there are consecutive bits.
The bithacks was where I found the 14-bit set-bets counting function listed in the OP. It's an excellent page.
I haven't stumbled across the poker page before. Seems like an excellent resource and pretty much exactly something I can use, but sadly I don't have the time to browse it now. It will have to wait till tomorrow
Same is true with your function.
From a quick glance, it seems to follow the same principles as the Kernighan/Ritchie old ANSI C algorithm of counting set bits. I will try it out and check the results vs. a lookup table. Eventually though, I think the table is the way to go to get as much speed out of the code as possible.


Thanks again for all your help.
A fountain of information and great tips

Regards Tom