# Thread: Help!For poker game simulation

1. since I don't know the "big part",I put is here.So I try my best,but yo said many ways,but can you show a easier way?just explain it simply.
A hint!I just need a hint.

2. I remember in "Beginning C++ game programming" book, the last chapter is making Blackjack game using OO and polymorphism. It will really benefit you, I can upload the code for you here from the CD if you want

3. Originally Posted by Hussain Hani
I remember in "Beginning C++ game programming" book, the last chapter is making Blackjack game using OO and polymorphism. It will really benefit you, I can upload the code for you here from the CD if you want

Yes,I really want it!Thank you!

4. >> just explain it simply.
I thought I did?

Just look at the values of the card and determine if they are consecutive. You already have code to get face value, so get each face value for the cards and sort them. If the five face values are in order, they are a straight (be careful with aces, though, since they can be high or low in straights).

I think a good idea would be to start with something simple like a pair. Write your function to determine if there is a pair in the five cards in the hand.

5. Originally Posted by Daved
>> just explain it simply.
I thought I did?

Just look at the values of the card and determine if they are consecutive. You already have code to get face value, so get each face value for the cards and sort them. If the five face values are in order, they are a straight (be careful with aces, though, since they can be high or low in straights).

I think a good idea would be to start with something simple like a pair. Write your function to determine if there is a pair in the five cards in the hand.
But how do I know "If the five face values are in order",I mean how do I make my PC know they are in order?How to design the function?

6. Perhaps a sort function like selection sort or bubble sort?

7. >> But how do I know "If the five face values are in order"?

If I asked you to write a function that took 5 numbers and returned true if the five values are sequential, what would you do? By "in order" I really meant sequential, since sorting them would actually put them in order.

So if I gave you 1,3,4,5,8, how would you determine that those numbers are not sequential?
What if I gave you 4,5,6,7,8, how would you know that those numbers are in sequential order?

It's your job to come up with the design of the function, hopefully these hints will help you.

8. Originally Posted by Daved
>> But how do I know "If the five face values are in order"?

If I asked you to write a function that took 5 numbers and returned true if the five values are sequential, what would you do? By "in order" I really meant sequential, since sorting them would actually put them in order.

So if I gave you 1,3,4,5,8, how would you determine that those numbers are not sequential?
What if I gave you 4,5,6,7,8, how would you know that those numbers are in sequential order?

It's your job to come up with the design of the function, hopefully these hints will help you.

But there is a big difference here,since my value are string,such as "One~Ten,Jack,Queen,King",do you mean I give them a number to represent the string?But One thing you should notice
while(card[dealt=rand()%52]);
which means I don't know which index the system give to the strings.If they are just integers like you said,I can do it,but they are strings.what is your idea?

9. The hand array holds ints. That's what I was thinking you would use when you figure out if the hand holds a straight, pair or whatever.

The hand array actually does hold the indexes into the card array, or did I read your code wrong?

10. Originally Posted by Daved
The hand array holds ints. That's what I was thinking you would use when you figure out if the hand holds a straight, pair or whatever.

The hand array actually does hold the indexes into the card array, or did I read your code wrong?

Oh,Thank you!I am a little stupid!
And this is some code I got from other people,I think it really show me something!And also thank you for your post!
Code:
```typedef enum
{
RankPoints_NoPoints = 0,
RankPoints_TwoPair = 5
} RankPoints;

RankPoints getRank( int* hand )
{
for( int i = 0; i < 5; i++ )
{
for( int j = i+1; j < 5; j++ )
{
if( faceValue[ hand[i]%13 ] == faceValue[ hand[j]%13 ] )
{
// do something....... for example
return RankPoints_TwoPair;
}
}
}
return RankPoints_NoPoint;
}```