Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Part II: Programming For this assignment, your job is to create a program that plays ( a simplified version of ) blackjack. Name your program
Part II: Programming
For this assignment, your job is to create a program that plays a simplified version of blackjack. Name your program blackjack.py
The Rules
For simplicity, we won't be implementing the full set of blackjack rules, but will get the core of the game working:
A regular deck of cards is used. The cards are every combination of ranks two three, four, five, six, seven, eight, nine, ten, jack, queen, king, ace and suits spades clubs, diamonds, hearts The deck is shuffled put into a random order before the game begins.
In our game, each player starts with $ At the start of the game, ask how many people wish to play.
Before each turn, each player makes a bet. They can risk any amount of their money on each turn.
Two cards are dealt given to each player and placed faceup on the table. The dealer also receives two cards, but one is kept facedown the hole card The rest of the cards form the shoe.
The object of the game is to get cards that have value as close as possible to without going over busting The cards in a players hand have point values as follows.
Card Rank Value
the card's face value
J Q K
A or whichever is better
Each player gets a turn to take additional cards from the shoe. A player can take another card hit as many times as they like. When they stop taking new cards stand their turn is over. The cards in the player's hand will not change after their turn is over.
Once the players have taken their turns, the dealer reveals hisher hole card. The dealer also has the chance to hit and stand, but they have a more rigid rule to follow. The dealer must hit take another card if their hand contains points or less, and stand stop taking cards if they have points or more.
Once all of the cards have been played, each player either wins or loses depending on what is in their hand and the dealer's hand.
Player Busts Player Doesn't Bust
Dealer Busts player loses player wins
Dealer points Player points player loses player wins
Dealer points Player points na push
Dealer points Player points na player loses
If the player wins, they get their bet back plus an equal amount from the dealer. If they lose, they lose the amount of money they bet.
A push is a tie. In that case, the player takes hisher money back and doesn't win or lose anything. In true blackjack, there is an additional set of outcomes that occur when either the player or dealer has blackjack: points with two cards. We won't worry about those rules here.
After the turn is played and the bets are settled, they play continues with another round go back to step
In a true game of blackjack, players can join or leave the game between hands. We won't worry about that. For this game, all of the players will play three hands, and then the game will stop.
Implementing
To help you along, a cards module has been provided. You'll have to download the cards module. Save this file in the same directory as your blackjack.py file and you should be able to import cards.
You must use Card objects as provided to represent the cards in the deck and players' hands. The deck and hands should be lists of Card objects. There are several functions in the cards module that will help you complete the assignment; they are described in the module documentation.
Several hints have been provided to help you find your way through this assignment. The hints don't say much about breaking your code into functions: deciding how to do that is part of the assignment.
Output
Here is a short sample of what the program should look like when it runs.
How many players are there?
Player #:
You have $
How much do you want to bet?
Player #:
You have $
How much do you want to bet?
Hands:
Dealer: H
Player #: D JH
Player #: D TS
Player #
Cards: D JH total:
Hit h or stand s h
Cards: D JH H total:
Hit h or stand s s
Player #
Cards: D TS total:
Hit h or stand s s
Dealer draws S
Dealer's hand: QC H S total:
Player # wins $
Player # wins $
Press enter to continue.
Player #:
You have $
How much do you want to bet?
Player #:
You have $
How much do you want to bet?
Hands:
Dealer: D
Player #: JC C
Player #: H KC
Player #
Cards: JC C total:
Hit h or stand s s
Player #
Cards: H KC total:
Hit h or stand s h
Cards: H KC KD total:
Bust!
Dealer draws C
Dealer's hand: D D C total:
Player # loses $
Player # loses $
Press enter to continue.
Player #:
You have $
How much do you want to bet?
Player #:
You have $
How much do you want to bet?
Hands:
Dealer: S
Player #: S JS
Player #: D S
Player #
Cards: S JS total:
Hit h or stand s s
Player #
Cards: D S total:
Hit h or stand s h
Cards: D S H total:
Hit h or stand s s
Dealer draws QH
Dealer's hand: C S QH total:
Player # loses $
Player # pushes.
Press enter to continue.
Player : $
Player : $
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started