Thread: Help!For poker game simulation

  1. #16
    Registered User
    Join Date
    May 2007
    Posts
    67
    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. #17
    "Why use dynamic memory?"
    Join Date
    Aug 2006
    Posts
    186
    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
    "C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg."-Bjarne Stroustrup
    Nearing the end of finishing my 2D card game! I have to work on its 'manifesto' though <_<

  3. #18
    Registered User
    Join Date
    May 2007
    Posts
    67
    Quote Originally Posted by Hussain Hani View Post
    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. #19
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    >> 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. #20
    Registered User
    Join Date
    May 2007
    Posts
    67
    Quote Originally Posted by Daved View Post
    >> 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. #21
    Its hard... But im here swgh's Avatar
    Join Date
    Apr 2005
    Location
    England
    Posts
    1,688
    Perhaps a sort function like selection sort or bubble sort?
    Double Helix STL

  7. #22
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    >> 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. #23
    Registered User
    Join Date
    May 2007
    Posts
    67
    Quote Originally Posted by Daved View Post
    >> 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. #24
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    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. #25
    Registered User
    Join Date
    May 2007
    Posts
    67

    Cool

    Quote Originally Posted by Daved View Post
    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;
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how do the game engine and the api interact?
    By Shadow12345 in forum Game Programming
    Replies: 9
    Last Post: 12-08-2010, 12:08 AM
  2. Open Source / Semi Open source game idea. Help needed
    By CaptainPatent in forum Projects and Job Recruitment
    Replies: 10
    Last Post: 05-16-2007, 10:44 AM
  3. game engine advice?
    By stien in forum Game Programming
    Replies: 0
    Last Post: 01-23-2007, 03:46 PM
  4. My Maze Game --- A Few Questions
    By TechWins in forum Game Programming
    Replies: 18
    Last Post: 04-24-2002, 11:00 PM