The challenge: build a simple 1 player blackjack game that runs in a terminal.
- Shuffle the cards.
- Deal two to the human, two to the dealer.
- Human goes first with stick or twist options.
- picture cards are 10,
- ace is 1 or 11.
- over 21 is bust.
- once you stick, it’s over to the dealer who always sticks on 17+.
- winner is closest to 21 without going over.
If the player score > dealer score, and the dealer score < 17, they have to take a card. If the player score > dealer score, and dealer score >= 17, the dealer sticks and the player wins.
If the dealer score = player score, and this score < 17, the dealer has to hit again If the dealer score = player score, and the score is >= 17, then the game is a draw
If the player score < dealer score, the dealer stands and wins
- Kotlin
- No mutable variables (vars)
- No mutable state/collections
- TDD all the things
- Functional core / functional shell
- Derive meaning through types and type signatures
- No functions that blow up at runtime (e.g. list.first() on an empty list)