Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem #1: Using MATLAB, build a program that allows the user to play a game of blackjack against the computer. Your program should have the

image text in transcribed

Problem #1: Using MATLAB, build a program that allows the user to play a game of blackjack against the computer. Your program should have the following constraints/requirements.. A freshly shuffled deck should be used at the start of each hand -Each card should be drawn from the top of the deck. -The player should be able to see the second card dealt to the dealer (computer), but not the first. -There must be clear instructions asking the user what he would like to do next. -The user's hand must be displayed to them showing both the current value and the card types they have. Three examples below Current Hand: [5 2 Ql Score = [17] Current Hand: A A K] Score [12] Current Hand: [105 K] Score = [25] Dealer: [5] Dealer: I J *BUST If you are unfamiliar with Blackjack, the rules are as follows. Every card has a value of 1-11. The cards 2-10 have their face value. Jacks, Queens, and Kings all have a value of 10. The Ace can either act as a 1 or an 11, whichever is most beneficial to the player/dealer. At the start of a hand, the player and dealer are both dealt two cards. The object of the game is to have a collection of cards with a value greater than that of the dealer, but not greater than 21 After the hand is dealt, the player has the option to Hit' or Stay'. Selecting Hit' should add another card to their hand and resolve the score, making sure to account for any oddities from Aces. if they choose Stay' they no longer receive cards and the dealer is given the option. The player is allowed to Hit' any number of times in order to approoch 21 as close as possible. if at any time the player's hand exceeds 21, they 'Bust' on their hand and immediately lose. if the dealer does this and the player has not, the player automatically wins. Upon choosing to Stay', the dealer can add to the cards in his hand. Traditionally, the dealer will always choose to Hit' if his total is 16 or below. He will choose to Stay' if he reaches at least 17. (Optional addition: the dealer will also hit on a 'soft 17', which is a 17 that has an Ace acting as an 11. For instance [A, 6]- 17. The dealer would hit here as there is no risk of busting.) How you approach this program is entirely up to you. However, the use of functions will likely prove useful for determining the cards associated with values 1-52 in the shuffled deck and calculating the current hand value Problem #1: Using MATLAB, build a program that allows the user to play a game of blackjack against the computer. Your program should have the following constraints/requirements.. A freshly shuffled deck should be used at the start of each hand -Each card should be drawn from the top of the deck. -The player should be able to see the second card dealt to the dealer (computer), but not the first. -There must be clear instructions asking the user what he would like to do next. -The user's hand must be displayed to them showing both the current value and the card types they have. Three examples below Current Hand: [5 2 Ql Score = [17] Current Hand: A A K] Score [12] Current Hand: [105 K] Score = [25] Dealer: [5] Dealer: I J *BUST If you are unfamiliar with Blackjack, the rules are as follows. Every card has a value of 1-11. The cards 2-10 have their face value. Jacks, Queens, and Kings all have a value of 10. The Ace can either act as a 1 or an 11, whichever is most beneficial to the player/dealer. At the start of a hand, the player and dealer are both dealt two cards. The object of the game is to have a collection of cards with a value greater than that of the dealer, but not greater than 21 After the hand is dealt, the player has the option to Hit' or Stay'. Selecting Hit' should add another card to their hand and resolve the score, making sure to account for any oddities from Aces. if they choose Stay' they no longer receive cards and the dealer is given the option. The player is allowed to Hit' any number of times in order to approoch 21 as close as possible. if at any time the player's hand exceeds 21, they 'Bust' on their hand and immediately lose. if the dealer does this and the player has not, the player automatically wins. Upon choosing to Stay', the dealer can add to the cards in his hand. Traditionally, the dealer will always choose to Hit' if his total is 16 or below. He will choose to Stay' if he reaches at least 17. (Optional addition: the dealer will also hit on a 'soft 17', which is a 17 that has an Ace acting as an 11. For instance [A, 6]- 17. The dealer would hit here as there is no risk of busting.) How you approach this program is entirely up to you. However, the use of functions will likely prove useful for determining the cards associated with values 1-52 in the shuffled deck and calculating the current hand value

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beyond Big Data Using Social MDM To Drive Deep Customer Insight

Authors: Martin Oberhofer, Eberhard Hechler

1st Edition

0133509796, 9780133509793

More Books