Question: I mplement a dice game, in Python, called PIG, pitting two human players against each other. PIG is played with a standard six-sided die and

Implement a dice game, in Python, called PIG, pitting two human players against each other. PIG is played with a standard six-sided die and proceeds as follows:

  • Each player starts with zero points, and the first to 20 points wins.

  • The current player chooses to roll or hold.

  • If they choose roll:

    • The six-sided die is rolled

    • The value of the die is added to their round points.

    • The player goes again UNLESS...

    • ...If the value on the die is 1, then the round is over and the player has lost all the points they accumulated in the round.

  • If they choose hold:

    • The points accumulated in the round are added to the players overall score.

    • The round is over.

  • When the round ends (either because the player rolled a 1 or they chose to hold), it becomes the other players turn unless somebody has won.

  • We check to see if someone won at the end of each round

Requirements:

  • Prompt each player to either R (roll) or H (hold).

  • If they enter anything else, continue prompting them until they enter a correct input.

  • On a roll, randomly generate a value 1-6 to represent the die.

  • End the round when the die roll is value 1 (round points are lost), or the player chooses Hold (round points are added to that players overall score).

  • End the game one either player has 20 or more points and announce the winner.

  • Report everything as you go along -- what the die roll was, number of points so far, etc.

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!