DEV Community

arranlemon
arranlemon

Posted on

Blackjack Terminal Game

As a part of the Learn Python3 module in Codecademy I had to develop a terminal game of my choice. As a passionate lover of cards I chose the game Blackjack. I chose this game for the following reasons:

  1. In Blackjack it's fine to see other players cards (a relative rarity in most card games)
  2. The game allows for more players than most card games (up to 8 in this case)
  3. It can also be played by a single player (also a rarity for most card games)

My implementation of the Blackjack game allows for up to 8 players. Players can choose their name and the number of chips they start with. The min bet is 10 and the max bet is 100. All bets must also be a multiple of 10. Players can elect to sit hands out if they choose. This game implements the splitting hand option. It doesn't implement the following lesser known side rules however:

Doubling Down
Surrender
Insurance 

The deck is implemented as a List in which each card is a list of the form ["card", card value] with two card values in the case of an ace. I used the random module in order create the effect of drawing random cards from the deck. The time module is also used to delay output to make the game flow in a manner less jarring to the eye. I also created a Hand and Player class. The Hand class is used to keep track of the cards and money bet on that hand. The methods of this class cover all the actions that the player can take on a hand. This includes hit, sit, splitting a hand, calculating the best hand value and whether the hand is a bust. The Player class keeps track of how many chips the player has, their hands and how many chips the player started with to track profits and losses. The methods of Player are used to create hands and calculate winnings (if any) from a hand.  
Below is a link to the GitHub repository with the code allowing you to play the game.

GitHub logo arranlemon / Blackjack_project

Final project as a part of the Codecademy Learn Python3 module. Attempts to implement the game blackjack as a terminal game.

Date: 28/9/2021
Author: Arran Lemon
This project attempts to implement the game blackjack as a terminal game. It is the final project
in the Learning Python module as a part of my Codecademy course. I have done some coding as a part
of my electrical engineering degree but due to a combination of poor mental health and other reasons
I haven't been able to develop the skill as much as I'd like. During the pandemic I've taken a
semester off my studies and got a Codecademy subscription. I'm so far really enjoying the course and 
have enjoyed this project, it's sea of errors and all. 


As a fan of card games I originally wanted to implement the game Hearts but in that game it's important 
to not be able to see the hands of other players which seemed a little too inconvenient for a terminal game. 
So instead I decided

https://github.com/arranlemon/Blackjack_project.git

Top comments (0)