Pig is a folk jeopardy dice game with simple rules: Two players race to reach 100 points. Each turn, a player repeatedly rolls a die until either a 1 ("pig") is rolled or the player holds and scores the sum of the rolls (i.e. the turn total). At any time during a player's turn, the player is faced with two decisions:
Problem: Simulate a single solitaire game of Pig where a player rolls until a 1 ("pig") is rolled, or the turn total is greater than or equal to 20, or the score plus the turn total is greater than or equal to 100.
Note: Be sure to "factor out common code". There is no reason to have two separate, nearly identical sections of code for each player's turn.
Input Format: (no input)
Output Format:
Sample Transcript:
Player 1 score: 0 Player 2 score: 0 It is player 1's turn. Roll: 5 Roll: 6 Roll: 1 Turn total: 0 New score: 0 Player 1 score: 0 Player 2 score: 0 It is player 2's turn. Roll: 2 Roll: 5 Roll: 4 Roll: 5 Roll: 4 Turn total: 20 New score: 20 Player 1 score: 0 Player 2 score: 20
...
Player 1 score: 90 Player 2 score: 66 It is player 1's turn. Roll: 2 Roll: 2 Roll: 6 Turn total: 10 New score: 100