
If dealer_cards.card_value = 11 and dealer_cards.card_value = 11: # In case both the cards are Ace, make the second ace value as 1 Print("DEALER SCORE = ", dealer_score - dealer_cards.card_value) # Print dealer cards and score, keeping in mind to hide the second card and score If player_cards.card_value = 11 and player_cards.card_value = 11: # In case both the cards are Ace, make the first ace value as 1 In Blackjack, a card has three properties, its suit, its representing value and its value as score.Īll the above properties are maintained within the following Card Class. With the help of classes and objects, we can create an ensemble of suits and values to represent a “playing card”. The second parameter of the print_cards() function is a boolean value that indicates whether a hidden card is to be displayed or not. The details of each Card are stored as a Card Object. Our job is to effectively display a series of cards on the terminal something like the following figure. Creating a terminal-based game from scratch requires three main components: The Game Design, The Game Logic, and Management of Player Interaction.īlackjack Game Demo A Demo of our Blackjack Gameįirstly, we will work on our game’s design.

The programming of the Blackjack game becomes simple as soon as the rules are understood.

The general rule is that the dealer needs to keep hitting more cards if the sum of dealer’s cards is less than 17. The dealer does not have the authority to decide whether to hit or stand.If the player decides to stand, then the dealer reveals his hidden card.

If the player decides to hit, another card is dealt.The player has to decide whether to stand with the current set of cards or get another card.The dealer deals a card facing downwards for himself.

