473,396 Members | 1,970 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Poker hand evaluation

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?

Dec 12 '06 #1
1 4451
Martin Olsen wrote:
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.
Perhaps there is further symmetry in this list that you could
exploit to reduce the its size? For example does permuting card
suits around make any difference? I don't know the rules to
"Hold 'Em", just guessing. If you can permute suits, then I
believe this list could shrink 4!=24 times. 5.5 million is
not much then.

Also, with a list you are paying extra memory cost for the
links between list elements. Perhaps a vector or deque would
be better here, or perhaps you don't literally mean a (std::)list?

HTH,
- J.
Dec 12 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: ibtc209 | last post by:
I just started programming in C, and I need some help with this problem. Your program will read the information about one MiniPoker hand, namely the rank and suit of the hand’s first card, and...
27
by: Simon Biber | last post by:
I was reading http://en.wikipedia.org/wiki/Poker_probability which has a good description of how to count the frequency of different types of poker hands using a mathematical approach. A sample...
4
by: hardieca | last post by:
Has anyone heard of an open-source .NET engine that calculates the winning and losing percentages of hands? Regards, Chris
15
by: sandy123456 | last post by:
At the moment im trying to write a hand class for a game poker patientnce But when i get to the part having to catergorise the difference of full house straight flush flush four of a kind and...
54
by: Rasjid | last post by:
Hello, I have just joined and this is my first post. I have never been able to resolve the issue of order of evaluation in C/C++ and the related issue of precedence of operators, use of...
13
by: kinghippo423 | last post by:
Hello Everyone, I did a poker program in Java that essencially finds the strenght of a poker hand created Randomly. My program is doing OK...but I'm pretty sure it can be optimised. This is my...
24
by: bnashenas1984 | last post by:
Hi every one I'm trying to make a little poker game but I don't know how to evaluate the strength of a 7 card hand.. It's not that hard with 5 cards. Actually I found some program to do that with...
9
by: teejayem | last post by:
I am looking for some help! I am currently developing a new game for an online community. The game is called Pokino which ishalf bingo and half poker. Wierd eh?! Anyway... The final part...
7
by: Extremity | last post by:
Hi, I am taking a intro to C++ course so my knowledge base only limits to areas such as if/else, functions, and recursions. We are creating a program which will determine the probability of Poker...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.