Question: Help with loops in MatLAB Write a MATLAB script (blackjack. m) that plays the dice game Blackjack. The player begins by drawing 2 cards and

Help with loops in MatLABHelp with loops in MatLAB Write a MATLAB script (blackjack. m) thatplays the dice game Blackjack. The player begins by drawing 2 cards

Write a MATLAB script (blackjack. m) that plays the dice game Blackjack. The player begins by drawing 2 cards and the computer draws one card, the suit does not matter. The cards are drawn from an infinite deck and are numbered 2, 3, 4, 5, 6, 7, 8, 9, 10, J, Q, K, and A. They occur with equal frequency. The cards J, Q, and K all have a value of 10. The card A has a value of 1 or 11 depending on the situation. Your script should display the one card dealt to the computer and the two cards dealt to the player, along with the point total of the two player cards. It then should ask the player if they want an additional card. If yes, then show the three cards and the total. If your total is greater than 21, you lose regardless of what happens. If your total is still less 21, ask if the player wants another card. Remember to check the value of an A and make it 1 if it prevents going over 21. Once the player no longer wants another card, deal a second card to the computer and check its total. If the total is 16 or less, the computer MUST draw another card, if it is 17 or greater it cannot draw another card. If it is 22 or greater the computer loses (unless there is an A in which case the value becomes 1 and the game continues). Once the computer stops drawing cards, your script should print out a message declaring who wins: the computer, the player, or a tie. Advance modification (optional): Card Counting. Rather than play 1 hand, play until 150 cards have been dealt. Keep a running "count" of what has been played. Cards 2-6 are worth 1 point, while 10, J, Q, K, A are worth -1 point. At the end of each hand, ask the player what the deck count is and report how accurate they are, then start the next hand. In general, the higher the total, the more favorable the deck is to the player

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!