Question
PYTHON The game of Pig is a simple two player dice game in which the first player to reach 100 or more points wins. Players
PYTHON
The game of Pig is a simple two player dice game in which the first player to reach 100 or more points wins. Players take turns. On each turn a player rolls a six-sided die. After each roll: a) If the player rolls a 1 then the player gets no new points and it becomes the other players turn. b) If the player rolls 2-6 then they can either roll again or hold. If the player holds the sum of all rolls is added to their score and the turn passes to the other player. Write a program that plays the game of Pig where one player is human and the other is the computer. When it is the humans turn the program should show the score of both players and the previous roll. Allow the human to input r for roll again and h for hold. When it is the computers turn you need not do any prompting. Simply keep rolling until the computer has earned 20 or more points and then hold. If the computer rolls a 1 at any time then the turn is lost and no points are added to the score. If at any point the computer has enough points to win the game then the computer holds and the game ends. Allow the human player to roll first. A random roll can be simulated with a call to random.randint(1,6) which generates a uniform random number in [1,6]. Make sure to import the random module (ie. import random).
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started