Overview - adambananka/blackjack GitHub Wiki

Blackjack game

Rules

  • game is for 1 - 6 players (dealer not counted, he is played automatically)
  • player cards are all dealt face up
  • dealer has one card face up, one face down
  • every game starts with full and shuffled deck
  • you have these possible moves: hit, stand, surrender, split
  • you can surrender only as your first move
  • you can split only while having 2 cards of same value (not the rank)
  • dealer doesn't hit on soft 17
  • win is paid out 1:1
  • Blackjack is paid out 3:2
  • surrender costs you half of your bet

Gameplay

  • firstly you'll be prompt for number of players
  • enter the name of every player
  • game loop
    • all players places their bets (up to number of their chips, which is displayed)
    • initial deal - everyone gets 2 cards
    • if player doesn't have Blackjack, it's his/her turn
      • choose one move mentioned above
      • player continues to do that, until he/she exceeds 21 ("busts") or ends by his/her will (by stand or surrender)
    • after all players (and all their hands) it's dealer's turn
    • then result summary take place, displaying score and result for every player (and every hand) and the dealer
    • if any player runs out of chips, game ends for him/her
    • if there is no player left, game ends
  • players are asked whether they want to continue playing
  • if want so, the game loop will start again
  • if no, current ammount of chips will be displayed for every player and the game ends

Results

  • after every round, all results are saved to DB
  • every result contains:
    • name of player
    • player's cards in string form
    • player's score
    • player's bet
    • player's result
  • at the end of game, all results from DB are saved to file

Possible changes (in code)

  • number of card decks
    • one card deck consists of 52 cards
    • by default 1
    • can be changed by altering constant NUMBER_OF_DECKS in Deck class
  • amount of player chips
    • by default 100
    • can be changed by altering constant INITIAL_CHIPS in Player class
  • result output file and it's encoding
    • can be changed by altering constants FILE_NAME and FILE_ENCODE in ResultManager class

Basic strategy