Question: 10.22 (Project: Blackjack) Using the DeckOfCards class from this chapter, create a simple Blackjack game. The rules of the game are as follows: * Two
10.22 (Project: Blackjack) Using the DeckOfCards class from this chapter, create a simple Blackjack game. The rules of the game are as follows: * Two cards each are dealt to the dealer and the player. The players cards are dealt face up. Only one of the dealers cards is dealt face up. * Each card has a value. A card numbered 2 through 10 is worth its face value. Jacks, queens and kings each count as 10. Aces can count as 1 or 11whichever value is more beneficial to the player (as well soon see). * If the sum of the players first two cards is 21 (that is, the player was dealt a card valued at 10 and an ace, which counts as 11 in this situation), the player has blackjack and immediately wins the gameif the dealer does not also have blackjack, which would result in a push (or tie). * Otherwise, the player can begin taking additional cards one at a time. These cards are dealt face up, and the player decides when to stop taking cards. If the player busts (that is, the sum of the players cards exceeds 21), the game is over and the player loses. When the player is satisfied with the current set of cards, the player stands (that is, stops taking cards), and the dealers hidden card is revealed. * If the dealers total is 16 or less, the dealer must take another card; otherwise, the dealer must stand. The dealer must continue taking cards until the sum of the cards is greater than or equal to 17. If the dealer exceeds 21, the player wins. Oth- erwise, the hand with the higher point total wins. If the dealer and the player have the same point total, the game is a push, and no one wins. * An aces value for a dealer depends on the dealers other card(s) and the casinos house rules. A dealer typically must hit for totals of 16 or less and must stand for 17 or more. For a soft 17a total of 17 with one ace counted as 11some casinos require the dealer to hit and some require the dealer to stand (we require the dealer to stand). Such a hand is known as a soft 17 because taking another card cannot bust the hand. * Enable a player to interact with the game using the keyboard'H' means hit (take another card and 'S' means stand (do not take another card). Display the dealers and players hands as card images using Matplotlib, as we did in this chapter.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
