Hi all.
I am creating a program which calculates poker odds. The program should
look at the visible cards (those on your hand and those on the table)
then count the cards needed to improve the hand(eg. how many cards do I
need to get a Flush) and then calculate the odds based on those
numbers. My problem is that I do not know how I should find the missing
cards.
One way I could do it is to use programming logic like this
(pseudo-code):
/* Find cards needed for a pair */
for x in "each visible card":
for y in "each non-visible card":
if(x.rank == y.rank):
/* We can use y to make a pair, count it */
cardsNeeded << y
But this can get very complicated and error prone (test cases is most
certainly needed) in the longrun.
Another way to do it would be to create a list of all possible hands
and then search through that. But a quick calculation tells me there
are 133 million (just above 1 trillion, if placement counts) different
combinations in a game of Hold 'Em, thats a fairly large list to carry
around.
Which one would you suggest? Have i missed other possibilities?