tags:

views:

63

answers:

1

I'm working on an app which is intended to give the % chance of landing specific poker hands in a Texas Hold'em game. The idea is to select any of 0-7 cards and then calculate what your chances are of completing each of 1P,2P,3K,S,F,FH,4K,SF.

I am, in particular, not attempting to compare two hands nor determining your chances of winning.

I am looking for the algorithms involved in performing this sort of calculation. I have managed to work out the math on some of the hands, but feel like this must have been done (to death) and that I'm simply reinventing the wheel.

My understanding is that libraries like poker-eval and it's ilk are intended for evaluation and comparison only, such that the returned value after evaluating a hand is solely for comparison against another evaluated hand. As a result I haven't grabbed any of them.

Does anyone have any suggestions of where to look? Would one of the existing libraries out there do what I want done?

Thanks in advance.

A: 

The hand evaluations routines typically produce an int. This int is usually 0 when the hand is a royal flush AKQJTsssss.

Therefore, I'd suggest determining each hand's category by finding the range of int values that are straight flushes, quads, and so on. Once you know that straight flushes are from 0 to 10 and quads are from 11 to 140..... you can easily compute the number you want using the highly optimized hand evaluator's output.

I'd suggest doing a straight enumeration if you think you are often going to "start" with 5 or more cards.

Ivan