Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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 Concepts

Authors: David Kroenke, David Auer, Scott Vandenberg, Robert Yoder

10th Edition

0137916787, 978-0137916788

More Books

Students also viewed these Databases questions