Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For this part you will implement a two-player version of the card game Blackjack but with six-sided dice instead of playing cards. The function blackjack.dice()

image text in transcribedimage text in transcribed

For this part you will implement a two-player version of the card game Blackjack but with six-sided dice instead of playing cards. The function blackjack.dice() will simulate the game with no interaction from the user. The game rules are as follows: Players take turns "rolling" two six-sided dice, each accumulating a running total. We will see later how the rolling of dice will be simulated If a player's total is less than 16, the player must roll the dice and add the total to his score . If a player's total is greater than or equal to 16, the player does not roll the dice. If a player's total equals exactly 21, the game ends immediately with a win for that player. If a player's total becomes greater than 21 ("busting"), the game ends immediately with a win for the other player. Thus, players continue rolling dice and accumulating totals while all of the following conditions are true: Neither player has reached 21 exactly. Neither player has busted (exceeded a total of 21) At least one player still has a score of less than 16. If the game ends with neither player hitting 21 or busting, then the player whose score is closest to 21 wins the game. In the event of a tie, the function returns the list [0, 0] The function takes a single argument, dice, which is a list of 30 or so integers in the range 1 through 6, inclusive. Rolling of dice is simulated by the function by reading integers from this list two at a time. One way to keep track of which numbers the function should read next is to maintain an index variable (e.g., next.die) that is updated For this part you will implement a two-player version of the card game Blackjack but with six-sided dice instead of playing cards. The function blackjack.dice() will simulate the game with no interaction from the user. The game rules are as follows: Players take turns "rolling" two six-sided dice, each accumulating a running total. We will see later how the rolling of dice will be simulated If a player's total is less than 16, the player must roll the dice and add the total to his score . If a player's total is greater than or equal to 16, the player does not roll the dice. If a player's total equals exactly 21, the game ends immediately with a win for that player. If a player's total becomes greater than 21 ("busting"), the game ends immediately with a win for the other player. Thus, players continue rolling dice and accumulating totals while all of the following conditions are true: Neither player has reached 21 exactly. Neither player has busted (exceeded a total of 21) At least one player still has a score of less than 16. If the game ends with neither player hitting 21 or busting, then the player whose score is closest to 21 wins the game. In the event of a tie, the function returns the list [0, 0] The function takes a single argument, dice, which is a list of 30 or so integers in the range 1 through 6, inclusive. Rolling of dice is simulated by the function by reading integers from this list two at a time. One way to keep track of which numbers the function should read next is to maintain an index variable (e.g., next.die) that is updated

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

Database Reliability Engineering Designing And Operating Resilient Database Systems

Authors: Laine Campbell, Charity Majors

1st Edition

978-1491925942

More Books

Students also viewed these Databases questions

Question

Buntpht Breparation Buntpht Breparation

Answered: 1 week ago