Welcome to the dice game Pig. The game is played between two players. Players alternate taking turns. During a turn a player rolls a six sided die. If the result of the roll is a 1 the player's score for the turn is 0 and it is the next player's turn. If the result of the die is not a 1 the result is added to the player's score for the turn. After the first roll of a turn a player must decide to HOLD or ROLL AGAIN. If a player HOLDs their score for the turn is added to their total score. if a player ROLLs AGAIN they roll the die again. The same rules apply to the second and subsequent rolls in the turn: a 1 reduces the player's score for the turn to 0 and the turn is over. If the die is not 1 the result is added to the player's score for the turn and they must decide to HOLD or ROLL AGAIN. The first player to reach a total of 100 wins the game. This program simulates the results of different strategies for the game. RUNNING SAMPLE GAMES WITH OUTPUT ***** START OF GAME ***** START OF TURN NUMBER 1 It is player 1's turn. player 1 rolled a 4 on roll number 1 Number of rolls this turn: 1 Score for turn so far: 4 If you HOLD now scores will be: player 1: 4 player 2: 0 DECISION - ROLL AGAIN player 1 rolled a 2 on roll number 2 Number of rolls this turn: 2 Score for turn so far: 6 If you HOLD now scores will be: player 1: 6 player 2: 0 DECISION - ROLL AGAIN player 1 rolled a 6 on roll number 3 Number of rolls this turn: 3 Score for turn so far: 12 If you HOLD now scores will be: player 1: 12 player 2: 0 DECISION - ROLL AGAIN player 1 rolled a 6 on roll number 4 Number of rolls this turn: 4 Score for turn so far: 18 If you HOLD now scores will be: player 1: 18 player 2: 0 DECISION - HOLD - TURN IS OVER START OF TURN NUMBER 2 It is player 2's turn. player 2 rolled a 3 on roll number 1 Number of rolls this turn: 1 Score for turn so far: 3 If you HOLD now scores will be: player 1: 18 player 2: 3 DECISION - ROLL AGAIN player 2 rolled a 4 on roll number 2 Number of rolls this turn: 2 Score for turn so far: 7 If you HOLD now scores will be: player 1: 18 player 2: 7 DECISION - ROLL AGAIN player 2 rolled a 6 on roll number 3 Number of rolls this turn: 3 Score for turn so far: 13 If you HOLD now scores will be: player 1: 18 player 2: 13 DECISION - ROLL AGAIN player 2 rolled a 5 on roll number 4 Number of rolls this turn: 4 Score for turn so far: 18 If you HOLD now scores will be: player 1: 18 player 2: 18 DECISION - ROLL AGAIN player 2 rolled a 6 on roll number 5 Number of rolls this turn: 5 Score for turn so far: 24 If you HOLD now scores will be: player 1: 18 player 2: 24 DECISION - HOLD - TURN IS OVER START OF TURN NUMBER 3 It is player 1's turn. player 1 rolled a 1 on roll number 1 PIG! Score for turn is 0. TURN IS OVER START OF TURN NUMBER 4 It is player 2's turn. player 2 rolled a 5 on roll number 1 Number of rolls this turn: 1 Score for turn so far: 5 If you HOLD now scores will be: player 1: 18 player 2: 29 DECISION - ROLL AGAIN player 2 rolled a 1 on roll number 2 PIG! Score for turn is 0. TURN IS OVER START OF TURN NUMBER 5 It is player 1's turn. player 1 rolled a 4 on roll number 1 Number of rolls this turn: 1 Score for turn so far: 4 If you HOLD now scores will be: player 1: 22 player 2: 24 DECISION - ROLL AGAIN player 1 rolled a 3 on roll number 2 Number of rolls this turn: 2 Score for turn so far: 7 If you HOLD now scores will be: player 1: 25 player 2: 24 DECISION - ROLL AGAIN player 1 rolled a 2 on roll number 3 Number of rolls this turn: 3 Score for turn so far: 9 If you HOLD now scores will be: player 1: 27 player 2: 24 DECISION - ROLL AGAIN player 1 rolled a 6 on roll number 4 Number of rolls this turn: 4 Score for turn so far: 15 If you HOLD now scores will be: player 1: 33 player 2: 24 DECISION - HOLD - TURN IS OVER START OF TURN NUMBER 6 It is player 2's turn. player 2 rolled a 3 on roll number 1 Number of rolls this turn: 1 Score for turn so far: 3 If you HOLD now scores will be: player 1: 33 player 2: 27 DECISION - ROLL AGAIN player 2 rolled a 5 on roll number 2 Number of rolls this turn: 2 Score for turn so far: 8 If you HOLD now scores will be: player 1: 33 player 2: 32 DECISION - ROLL AGAIN player 2 rolled a 5 on roll number 3 Number of rolls this turn: 3 Score for turn so far: 13 If you HOLD now scores will be: player 1: 33 player 2: 37 DECISION - ROLL AGAIN player 2 rolled a 1 on roll number 4 PIG! Score for turn is 0. TURN IS OVER START OF TURN NUMBER 7 It is player 1's turn. player 1 rolled a 6 on roll number 1 Number of rolls this turn: 1 Score for turn so far: 6 If you HOLD now scores will be: player 1: 39 player 2: 24 DECISION - ROLL AGAIN player 1 rolled a 1 on roll number 2 PIG! Score for turn is 0. TURN IS OVER START OF TURN NUMBER 8 It is player 2's turn. player 2 rolled a 1 on roll number 1 PIG! Score for turn is 0. TURN IS OVER START OF TURN NUMBER 9 It is player 1's turn. player 1 rolled a 4 on roll number 1 Number of rolls this turn: 1 Score for turn so far: 4 If you HOLD now scores will be: player 1: 37 player 2: 24 DECISION - ROLL AGAIN player 1 rolled a 2 on roll number 2 Number of rolls this turn: 2 Score for turn so far: 6 If you HOLD now scores will be: player 1: 39 player 2: 24 DECISION - ROLL AGAIN player 1 rolled a 3 on roll number 3 Number of rolls this turn: 3 Score for turn so far: 9 If you HOLD now scores will be: player 1: 42 player 2: 24 DECISION - ROLL AGAIN player 1 rolled a 6 on roll number 4 Number of rolls this turn: 4 Score for turn so far: 15 If you HOLD now scores will be: player 1: 48 player 2: 24 DECISION - HOLD - TURN IS OVER START OF TURN NUMBER 10 It is player 2's turn. player 2 rolled a 2 on roll number 1 Number of rolls this turn: 1 Score for turn so far: 2 If you HOLD now scores will be: player 1: 48 player 2: 26 DECISION - ROLL AGAIN player 2 rolled a 4 on roll number 2 Number of rolls this turn: 2 Score for turn so far: 6 If you HOLD now scores will be: player 1: 48 player 2: 30 DECISION - ROLL AGAIN player 2 rolled a 4 on roll number 3 Number of rolls this turn: 3 Score for turn so far: 10 If you HOLD now scores will be: player 1: 48 player 2: 34 DECISION - ROLL AGAIN player 2 rolled a 4 on roll number 4 Number of rolls this turn: 4 Score for turn so far: 14 If you HOLD now scores will be: player 1: 48 player 2: 38 DECISION - ROLL AGAIN player 2 rolled a 6 on roll number 5 Number of rolls this turn: 5 Score for turn so far: 20 If you HOLD now scores will be: player 1: 48 player 2: 44 DECISION - HOLD - TURN IS OVER START OF TURN NUMBER 11 It is player 1's turn. player 1 rolled a 2 on roll number 1 Number of rolls this turn: 1 Score for turn so far: 2 If you HOLD now scores will be: player 1: 50 player 2: 44 DECISION - ROLL AGAIN player 1 rolled a 4 on roll number 2 Number of rolls this turn: 2 Score for turn so far: 6 If you HOLD now scores will be: player 1: 54 player 2: 44 DECISION - ROLL AGAIN player 1 rolled a 1 on roll number 3 PIG! Score for turn is 0. TURN IS OVER START OF TURN NUMBER 12 It is player 2's turn. player 2 rolled a 3 on roll number 1 Number of rolls this turn: 1 Score for turn so far: 3 If you HOLD now scores will be: player 1: 48 player 2: 47 DECISION - ROLL AGAIN player 2 rolled a 2 on roll number 2 Number of rolls this turn: 2 Score for turn so far: 5 If you HOLD now scores will be: player 1: 48 player 2: 49 DECISION - ROLL AGAIN player 2 rolled a 2 on roll number 3 Number of rolls this turn: 3 Score for turn so far: 7 If you HOLD now scores will be: player 1: 48 player 2: 51 DECISION - ROLL AGAIN player 2 rolled a 3 on roll number 4 Number of rolls this turn: 4 Score for turn so far: 10 If you HOLD now scores will be: player 1: 48 player 2: 54 DECISION - ROLL AGAIN player 2 rolled a 4 on roll number 5 Number of rolls this turn: 5 Score for turn so far: 14 If you HOLD now scores will be: player 1: 48 player 2: 58 DECISION - HOLD - TURN IS OVER START OF TURN NUMBER 13 It is player 1's turn. player 1 rolled a 4 on roll number 1 Number of rolls this turn: 1 Score for turn so far: 4 If you HOLD now scores will be: player 1: 52 player 2: 58 DECISION - ROLL AGAIN player 1 rolled a 2 on roll number 2 Number of rolls this turn: 2 Score for turn so far: 6 If you HOLD now scores will be: player 1: 54 player 2: 58 DECISION - ROLL AGAIN player 1 rolled a 5 on roll number 3 Number of rolls this turn: 3 Score for turn so far: 11 If you HOLD now scores will be: player 1: 59 player 2: 58 DECISION - ROLL AGAIN player 1 rolled a 3 on roll number 4 Number of rolls this turn: 4 Score for turn so far: 14 If you HOLD now scores will be: player 1: 62 player 2: 58 DECISION - ROLL AGAIN player 1 rolled a 5 on roll number 5 Number of rolls this turn: 5 Score for turn so far: 19 If you HOLD now scores will be: player 1: 67 player 2: 58 DECISION - HOLD - TURN IS OVER START OF TURN NUMBER 14 It is player 2's turn. player 2 rolled a 4 on roll number 1 Number of rolls this turn: 1 Score for turn so far: 4 If you HOLD now scores will be: player 1: 67 player 2: 62 DECISION - ROLL AGAIN player 2 rolled a 6 on roll number 2 Number of rolls this turn: 2 Score for turn so far: 10 If you HOLD now scores will be: player 1: 67 player 2: 68 DECISION - ROLL AGAIN player 2 rolled a 4 on roll number 3 Number of rolls this turn: 3 Score for turn so far: 14 If you HOLD now scores will be: player 1: 67 player 2: 72 DECISION - ROLL AGAIN player 2 rolled a 2 on roll number 4 Number of rolls this turn: 4 Score for turn so far: 16 If you HOLD now scores will be: player 1: 67 player 2: 74 DECISION - ROLL AGAIN player 2 rolled a 4 on roll number 5 Number of rolls this turn: 5 Score for turn so far: 20 If you HOLD now scores will be: player 1: 67 player 2: 78 DECISION - HOLD - TURN IS OVER START OF TURN NUMBER 15 It is player 1's turn. player 1 rolled a 4 on roll number 1 Number of rolls this turn: 1 Score for turn so far: 4 If you HOLD now scores will be: player 1: 71 player 2: 78 DECISION - ROLL AGAIN player 1 rolled a 4 on roll number 2 Number of rolls this turn: 2 Score for turn so far: 8 If you HOLD now scores will be: player 1: 75 player 2: 78 DECISION - ROLL AGAIN player 1 rolled a 1 on roll number 3 PIG! Score for turn is 0. TURN IS OVER START OF TURN NUMBER 16 It is player 2's turn. player 2 rolled a 6 on roll number 1 Number of rolls this turn: 1 Score for turn so far: 6 If you HOLD now scores will be: player 1: 67 player 2: 84 DECISION - ROLL AGAIN player 2 rolled a 1 on roll number 2 PIG! Score for turn is 0. TURN IS OVER START OF TURN NUMBER 17 It is player 1's turn. player 1 rolled a 1 on roll number 1 PIG! Score for turn is 0. TURN IS OVER START OF TURN NUMBER 18 It is player 2's turn. player 2 rolled a 1 on roll number 1 PIG! Score for turn is 0. TURN IS OVER START OF TURN NUMBER 19 It is player 1's turn. player 1 rolled a 5 on roll number 1 Number of rolls this turn: 1 Score for turn so far: 5 If you HOLD now scores will be: player 1: 72 player 2: 78 DECISION - ROLL AGAIN player 1 rolled a 2 on roll number 2 Number of rolls this turn: 2 Score for turn so far: 7 If you HOLD now scores will be: player 1: 74 player 2: 78 DECISION - ROLL AGAIN player 1 rolled a 2 on roll number 3 Number of rolls this turn: 3 Score for turn so far: 9 If you HOLD now scores will be: player 1: 76 player 2: 78 DECISION - ROLL AGAIN player 1 rolled a 4 on roll number 4 Number of rolls this turn: 4 Score for turn so far: 13 If you HOLD now scores will be: player 1: 80 player 2: 78 DECISION - ROLL AGAIN player 1 rolled a 4 on roll number 5 Number of rolls this turn: 5 Score for turn so far: 17 If you HOLD now scores will be: player 1: 84 player 2: 78 DECISION - HOLD - TURN IS OVER START OF TURN NUMBER 20 It is player 2's turn. player 2 rolled a 5 on roll number 1 Number of rolls this turn: 1 Score for turn so far: 5 If you HOLD now scores will be: player 1: 84 player 2: 83 DECISION - ROLL AGAIN player 2 rolled a 6 on roll number 2 Number of rolls this turn: 2 Score for turn so far: 11 If you HOLD now scores will be: player 1: 84 player 2: 89 DECISION - ROLL AGAIN player 2 rolled a 3 on roll number 3 Number of rolls this turn: 3 Score for turn so far: 14 If you HOLD now scores will be: player 1: 84 player 2: 92 DECISION - ROLL AGAIN player 2 rolled a 3 on roll number 4 Number of rolls this turn: 4 Score for turn so far: 17 If you HOLD now scores will be: player 1: 84 player 2: 95 DECISION - ROLL AGAIN player 2 rolled a 3 on roll number 5 Number of rolls this turn: 5 Score for turn so far: 20 If you HOLD now scores will be: player 1: 84 player 2: 98 DECISION - HOLD - TURN IS OVER START OF TURN NUMBER 21 It is player 1's turn. player 1 rolled a 4 on roll number 1 Number of rolls this turn: 1 Score for turn so far: 4 If you HOLD now scores will be: player 1: 88 player 2: 98 DECISION - ROLL AGAIN player 1 rolled a 6 on roll number 2 Number of rolls this turn: 2 Score for turn so far: 10 If you HOLD now scores will be: player 1: 94 player 2: 98 DECISION - ROLL AGAIN player 1 rolled a 2 on roll number 3 Number of rolls this turn: 3 Score for turn so far: 12 If you HOLD now scores will be: player 1: 96 player 2: 98 DECISION - ROLL AGAIN player 1 rolled a 2 on roll number 4 Number of rolls this turn: 4 Score for turn so far: 14 If you HOLD now scores will be: player 1: 98 player 2: 98 DECISION - ROLL AGAIN player 1 rolled a 6 on roll number 5 Number of rolls this turn: 5 Score for turn so far: 20 If you HOLD now scores will be: player 1: 104 player 2: 98 DECISION - HOLD - TURN IS OVER FINAL RESULTS: Number of turns: 21 player 1 score: 104 player 2 score: 98 player 1 won the game! RUNNING EXPERIMENTS (10,000 GAMES EACH) WITH NO OUTPUT player 1 and player 2 stop at 15 points for turn player 1 wins: 5368 player 2 wins: 4632 player 1 and player 2 stop at 5 rolls for turn player 1 wins: 5262 player 2 wins: 4738 player 1 stops at 15 points and player 2 stops at 5 rolls player 1 wins: 4983 player 2 wins: 5017 player 1 stops at 5 rolls and player 2 stops at 15 points player 1 wins: 5699 player 2 wins: 4301