"Pig" is a very simple game. Two players take turns; on each turn, a player rolls a six-sided die ("die" is the singular of "dice") as many times as she wishes, or until she rolls a 1. Each number she rolls, except a 1, is added to her score this turn; but if she rolls a 1, her score for this turn is zero, and her turn ends. At the end of each turn, the score for that turn is added to the player's total score. The first player to reach or exceed 100 wins.
As defined above, the first player has an advantage. To make the game more fair, we will say that if the first player reaches or exceeds 100, the second player gets one additional turn. (If the second player is the first to reach 100, the first player does not get an additional turn.)
Your assignment is to implement the game of Pig. You will play against the computer. The computer always goes first, so you get one more turn if the computer is the first to reach 100.
If both players are tied with 100 or more, each gets another turn until the tie is broken.
Define and use at least the following functions:
def human_move(computer_score, human_score):
def computer_move(computer_score, human_score):
def is_game_over(computer_score, human_score):
Trueif either player has 100 or more, and the players are not tied, otherwise it returns
False. (Call this only after the human's move.)
randommodule on https://docs.python.org/3/library/index.html and follow the link to find the
"Roll again? ". If the user responds with a string whose first character is
'Y', the function returns
True. If the user responds with a string whose first character is
'N', the function returns
False. Any other response will cause the question to be repeated until the user provides an acceptable response.
def show_results(computer_score, human_score):
Submit your pig.py file to Canvas
by 11:59pm Tuesday, September 13. Since this will be a single file, there
is no need to zip it.
Only files submitted to Canvas will be accepted. I do not accept assignments submitted by email.