D. Final Algorithm, Flowchart, or Pseudocode

Blackjack Algorithm:

  1. Assign a number value to every card in the deck. Then put all of these numbers in a matrix.
  2. Make sure there are 4 cards with the same number value for each card type of card in the deck and that an ace can be 1 or 11 by user input. All face cards are equal to 10.
  3. At the start of each new hand, have the cards shuffled.
  4. Ask the user if they would like to play blackjack.
  5. Ask the user how much money they would like to bet.
  6. The dealer AI deals two cards to the player, both face up, and deals two cards to himself, one face up and the other face down.
  7. If the player has a 10-value card and an ace, the player automatically wins because they got a “blackjack”.
  8. If their two cards don’t equal 21, ask the player to hit(be given another card) or stay(move on to the dealer’s hand).
  9. If the player goes over 21, the dealer automatically wins.
  10. Once the player stays, the dealer must keep hitting until their hand is a greater value than the player’s or until they bust.
  11. Whoever had the higher hand value that didn’t exceed 21 wins the hand and gets twice the amount of their bet. If the player gets a blackjack, they win the amount they bet plus 1.5x the amount they bet.
  12. Repeat steps 1-11 until the user decides to stop playing.
  13. Program the dealer to make logical decisions during the hand so the player will not win every time.
  14. Have a total win/loss counter and a money earned counter.