Creating a blackjack game

This is a discussion on Creating a blackjack game within the Game Programming forums, part of the General Programming Boards category; I need some guidance, i havent finished the pseudocode yet but i quickly (less than 20 mins) wrote some of ...

  1. #1
    *this
    Join Date
    Mar 2005
    Posts
    498

    Creating a blackjack game

    I need some guidance, i havent finished the pseudocode yet
    but i quickly (less than 20 mins) wrote some of my ideas, let me know if its a good start or if i should aproach it another way

    Code:
    /****************************
    
    Present the user interface
       Display welcome message
       Display options for game
          1 Enter ammount of computers to play with
             create a class object for each computer
          2 Enter ammount of humans to play with
             create a class object for each human
          3 Start Game
          4 Exit
       Input option
       
    ////////////////////////////////Cards Class///////////////////////////////////
    PUBLIC FUNCTIONS:   
           
    structure deckType
       contains: size of array and an array filled of cardsType
    structure for the cardsType
       contains: suit 
       card number
       bool type dealt (true if card is dealt to a player)
       
    Create a deck of cards     
       create a deckType
       fill deck with each card
          for each card number
             create a card for each suit
             
    Shuffle the deck of cards
       for many repetitions
          choose two random numbers in deck
          swap those locations
          
    Deal cards - function takes in: Array of player, and number to deal (X)
       choose first X numbers in deck that havent been dealt
       check for variables in the array
       resize array if necessary
       place dealt cards after current variables
       mark cards as "dealt" in the deck
       
    Number of cards dealt
       go through deck
          for each bool dealt = true
          add 1 to # cards dealt
       return # of cards dealt
       
    ______________________________________________________________________________
    
    ///////////////////////////////Dealer Class///////////////////////////////////
    include cards class
    
    PUBLIC FUNCTIONS:
    
    create a dealer
    ______________________________________________________________________________
       
    ///////////////////////////////Player Class///////////////////////////////////
    include cards class
    
    PUBLIC FUNCTIONS:
           
    create a player
    ______________________________________________________________________________
    
    
    Deal 2 cards to each player and dealer
    Have player 1 go first
    after each player
       dealers turn
    Calculate the winner
       if the dealer is the highest
          display "You Lose, Dealer Wins!"
       if a player has the highest
          display "Player X Wins!"
    Ask if user would like to play new game, change settings, or exit
    ******************************/
    Last edited by JoshR; 04-28-2005 at 10:12 PM.

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,485
    So far so good.
    But you need to think about how to rank hands to decide who wins/loses.

    > resize array if necessary
    This is both too detailed, and presumes an implementation.
    You should only hint at the general implementation approach you'll take (you could choose an STL list).
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Call me AirBronto
    Join Date
    Sep 2004
    Location
    Indianapolis, Indiana
    Posts
    195
    This all sounds good but you need to think more about how you are going to tie all of this together. i suggest a switch enclosed within a while statement that both run by changing game states.

    Some thing like this:

    Code:
    while(GameState != GAMEOVER)
    {
         switch(GameState)
         {
          case: PLAYERTURN
                  { have a function in here that will make all the aproprate  calls to all the functions you need for this state then change to the next logical game state and return.  break}
            
          case: COMPUTERTURN
                 {same as last}
    
          case: GAMESTART
                {same as last}
    }

  4. #4
    Registered User
    Join Date
    Dec 2002
    Posts
    56
    Quote Originally Posted by loopshot
    This all sounds good but you need to think more about how you are going to tie all of this together. i suggest a switch enclosed within a while statement that both run by changing game states.

    Some thing like this:

    Code:
    while(GameState != GAMEOVER)
    {
         switch(GameState)
         {
          case: PLAYERTURN
                  { have a function in here that will make all the aproprate  calls to all the functions you need for this state then change to the next logical game state and return.  break}
            
          case: COMPUTERTURN
                 {same as last}
    
          case: GAMESTART
                {same as last}
    }
    That's implementation specific though.. I think right now he's just going for the general logic of the program..

  5. #5
    *this
    Join Date
    Mar 2005
    Posts
    498
    Ya I'm looking to see if im going in the right direction, thanks for the input guys, and good idea loopshot I'll keep that in mind when I start to code. Thanks again.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. 2D RPG Online Game Project. 30% Complete. To be released and marketed.
    By drallstars in forum Projects and Job Recruitment
    Replies: 2
    Last Post: 10-28-2006, 12:48 AM
  2. beach bar (sims type game)
    By DrKillPatient in forum Game Programming
    Replies: 1
    Last Post: 03-06-2006, 12:32 PM
  3. Game Engine Link Prob
    By swgh in forum Game Programming
    Replies: 2
    Last Post: 01-25-2006, 11:14 PM
  4. Blackjack (21) Game
    By Rabidpunk in forum Game Programming
    Replies: 12
    Last Post: 01-11-2002, 02:19 AM
  5. Blackjack (21) Game Pt. 2
    By Unregistered in forum Game Programming
    Replies: 0
    Last Post: 12-19-2001, 01:53 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21