views:

753

answers:

2

Hey,

Does anyone know a fast algorithm for evaluating 7 card poker hands? Something which is more efficient than simply brute-force checking a every 21 5-card combination of hands from a set of 7.

Cheers,

Pete

+5  A: 

This site lists a bunch of Poker Hand Evaluator libraries and gives a few details about each of them. Most of them are for 5 card hands, but there is at least one for a 7 card hand called The Snezee7 Evaluator. Plus the site give a great overview of the different techniques and algorithms used to analyze poker hands quickly.

I've used the Keith Rule C# Port of the Pokersource Evaluator in a few different poker projects and think that it is an excellent library. There are many clever tricks you can use to make really fast hand evaluators, but writing the code is a lot of work and I would highly suggest using an existing library.

Greg Bray
Note that Snezee7 requires a 266 MB lookup table.
David M
It does... but that is how you get a fast hand evaluator (lots of pre-computation). The Two Plus Two evaluator uses a similar approach to evaluate 7 card hands using a 123 MB lookup table. For 5 card hands the lookup tables are much smaller.
Greg Bray
+3  A: 

Glad you asked :) Yes, here's a brand new solution that may be just the ticket:

Code: http://code.google.com/p/specialkpokereval/
Blog: http://specialk-coding.blogspot.com/2010/04/texas-holdem-7-card-evaluator_23.html

A commercial-grade evolution of this evaluator is available for the iPhone/iPod Touch via iTunes Store. It's called "Poker Ace".

An excellent summary of various solutions complete with links is found on James Devlin's blog "Coding The Wheel".

One evaluator not yet discussed there is Klaatu's.

Good luck!

SpecialK