Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.


The most interesting part of this project for me was implementing the "basic strategy" of Blackjack. Blackjack is a game without any real complexity or decision making; the best player options for any permutation of visible cards can be summarized in a table. Even following this strategy, the player is bound to lose to the house in the long run. This basic strategy of play is summarized on wikipedia here: I decided to simplify the game by eliminating the double down, split, and surrender rules, but I did implement an ace rule so the player can have a hard or "soft" hand. Then

I turned that wikipedia table into a rather long playerTurn method with if-then statements and while loops to make the player always take the best choices considering his hand and the dealer's one visible card. Critical to my playerTurn method was having a way to test whether his hand was "hard" or "soft." A hard hand is a hand without an ace, or with an ace that has to be considered low for the player not to bust. A "soft" hand is a hand where the ace can be taken high or low, and the player is not busted either way. There are different strategies for hard and soft hands so I had to make a way to test the hand's hardness. A loop through the hand that finds no aces guarantees that the hand is hard, but a hand with an ace that totals 12 or more when the ace is taken as low is also hard. Only a hand with an ace that values less than 12 is a soft hand. I had to code all of this into an algorithm.