Skip to content

Blackjack is a fun, Python-based card game offering a risk-free way to enjoy and practice Blackjack. With an intuitive text interface, it caters to both experienced players and newcomers. The goal is to achieve a hand value close to 21 without busting, outsmarting the dealer in the process.

Notifications You must be signed in to change notification settings

ovinokurov/Blackjack-Game

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 

Repository files navigation

Blackjack-Game

This is a simple text-based Blackjack game implemented in Python. It includes a basic user interface and provides a fun way to practice your Blackjack skills without any monetary risk.

Requirements

  • Python 3

How to run the game

To run the game, simply execute the main.py file:

python main.py

Game rules

The game is played with a standard deck of 52 playing cards. The goal is to have a hand value as close to 21 as possible without going over. Face cards (K, Q, J) are worth 10 points, Aces can be worth 11 or 1, and numbered cards are worth their face value.

The game starts by dealing two cards to both the player and the dealer. The dealer shows one card face up, while the other card remains hidden. The player can see both of their cards and their total value.

The player has two options:

  • Hit (h): Draw another card to try to improve the hand value.
  • Stand (s): Keep the current hand and end the turn.

If the player's hand value exceeds 21, the player busts, and the dealer wins. If the player stands, the dealer reveals their hidden card and draws more cards if their hand value is less than 17. If the dealer's hand value exceeds 21, the dealer busts, and the player wins. If both the player and the dealer stand, the hand with the value closest to 21 wins.

To exit the game, simply choose not to play again when prompted.

Implementation details

The game is implemented using three main classes:

-Card: Represents a playing card with a suit and rank.

-Deck: Represents a deck of 52 playing cards and provides methods to shuffle and draw cards.

-Hand: Represents a hand of cards, calculates the hand value, and provides a string representation of the hand.

The blackjack_game function controls the game flow, and the print_hands function displays the current hands of the player and the dealer. The main loop at the bottom of the script allows for replaying the game.

Enjoy the game and good luck!

About

Blackjack is a fun, Python-based card game offering a risk-free way to enjoy and practice Blackjack. With an intuitive text interface, it caters to both experienced players and newcomers. The goal is to achieve a hand value close to 21 without busting, outsmarting the dealer in the process.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages