Simplified version of Blackjack coded in Python.
- Check if python is installed by running:
python3 --version
- If not, click here.
- Clone this repository.
- Run this line into your terminal:
python3 main.py
- Follow instructions on the terminal.
- Both players are dealt 2 cards facing up.
- Either players can choose to either stand or hit.
- Number cards' values are their numbers, 10s and face cards' values are 10, and ace's value is 11.
- A player automatically wins when their cards' values add up to 21.
- A player automatically loses when their cards' values goes over 21. Note: Both players can choose stand unlimited amount of times in this game.
Code was refactored into different functions and files to minimize redundancy and maximize readability.
4 files are required to run this game: deck_of_cards.py, blackjack.py, util.py, and main.py.
- deck_of_cards.py
- Contains the class DeckOfCards. Contains methods to intuitively manipualate a deck using functions such as shuffle() and draw().
- blackjack.py
- Contains the class Blackjack. Contains methods that pertain to the game itself such as play_cpu_turn(), play_player_turn(), and play().
- util.py
- Contains all functions that are not class-specific such as clear() to clear the terminal screen.
- main.py
- Main file that needs to be run in order for the game to start.
- Python - The main programming language.
- Peter Lee
- Credits to GeeksforGeeks for code to clear the terminal.