Question: I need to write a python code for a game of pig. These are my instructions. The game of Pig is a simple two-player dice
I need to write a python code for a game of pig. These are my instructions.
"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 his/her 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. (Hint: use the input function). 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."
I have been able to get most of it but as I try to edit my code I end up making it worse. Any help would be awesome.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
