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 1 on roll number 1 PIG! Score for turn is 0. TURN IS OVER START OF TURN NUMBER 2 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 3 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: 5 player 2: 0 DECISION - ROLL AGAIN player 1 rolled a 4 on roll number 2 Number of rolls this turn: 2 Score for turn so far: 9 If you HOLD now scores will be: player 1: 9 player 2: 0 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 4 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: 0 player 2: 6 DECISION - ROLL AGAIN player 2 rolled a 6 on roll number 2 Number of rolls this turn: 2 Score for turn so far: 12 If you HOLD now scores will be: player 1: 0 player 2: 12 DECISION - ROLL AGAIN player 2 rolled a 5 on roll number 3 Number of rolls this turn: 3 Score for turn so far: 17 If you HOLD now scores will be: player 1: 0 player 2: 17 DECISION - ROLL AGAIN player 2 rolled a 4 on roll number 4 Number of rolls this turn: 4 Score for turn so far: 21 If you HOLD now scores will be: player 1: 0 player 2: 21 DECISION - ROLL AGAIN player 2 rolled a 5 on roll number 5 Number of rolls this turn: 5 Score for turn so far: 26 If you HOLD now scores will be: player 1: 0 player 2: 26 DECISION - HOLD - TURN IS OVER START OF TURN NUMBER 5 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: 6 player 2: 26 DECISION - ROLL AGAIN player 1 rolled a 6 on roll number 2 Number of rolls this turn: 2 Score for turn so far: 12 If you HOLD now scores will be: player 1: 12 player 2: 26 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 6 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: 0 player 2: 31 DECISION - ROLL AGAIN player 2 rolled a 3 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: 0 player 2: 34 DECISION - ROLL AGAIN player 2 rolled a 1 on roll number 3 PIG! Score for turn is 0. TURN IS OVER START OF TURN NUMBER 7 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: 26 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: 8 player 2: 26 DECISION - ROLL AGAIN player 1 rolled a 3 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: 11 player 2: 26 DECISION - ROLL AGAIN player 1 rolled a 4 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: 15 player 2: 26 DECISION - HOLD - TURN IS OVER START OF TURN NUMBER 8 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: 15 player 2: 32 DECISION - ROLL AGAIN player 2 rolled a 3 on roll number 2 Number of rolls this turn: 2 Score for turn so far: 9 If you HOLD now scores will be: player 1: 15 player 2: 35 DECISION - ROLL AGAIN player 2 rolled a 1 on roll number 3 PIG! Score for turn is 0. TURN IS OVER START OF TURN NUMBER 9 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: 21 player 2: 26 DECISION - ROLL AGAIN player 1 rolled a 3 on roll number 2 Number of rolls this turn: 2 Score for turn so far: 9 If you HOLD now scores will be: player 1: 24 player 2: 26 DECISION - ROLL AGAIN player 1 rolled a 5 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: 29 player 2: 26 DECISION - ROLL AGAIN player 1 rolled a 1 on roll number 4 PIG! Score for turn is 0. TURN IS OVER START OF TURN NUMBER 10 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: 15 player 2: 32 DECISION - ROLL AGAIN player 2 rolled a 2 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: 15 player 2: 34 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: 15 player 2: 39 DECISION - ROLL AGAIN player 2 rolled a 6 on roll number 4 Number of rolls this turn: 4 Score for turn so far: 19 If you HOLD now scores will be: player 1: 15 player 2: 45 DECISION - ROLL AGAIN player 2 rolled a 1 on roll number 5 PIG! Score for turn is 0. TURN IS OVER START OF TURN NUMBER 11 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: 21 player 2: 26 DECISION - ROLL AGAIN player 1 rolled a 5 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: 26 player 2: 26 DECISION - ROLL AGAIN player 1 rolled a 2 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: 28 player 2: 26 DECISION - ROLL AGAIN player 1 rolled a 3 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: 31 player 2: 26 DECISION - HOLD - 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: 31 player 2: 29 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: 31 player 2: 33 DECISION - ROLL AGAIN player 2 rolled a 1 on roll number 3 PIG! Score for turn is 0. TURN IS OVER START OF TURN NUMBER 13 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: 37 player 2: 26 DECISION - ROLL AGAIN player 1 rolled a 6 on roll number 2 Number of rolls this turn: 2 Score for turn so far: 12 If you HOLD now scores will be: player 1: 43 player 2: 26 DECISION - ROLL AGAIN player 1 rolled a 5 on roll number 3 Number of rolls this turn: 3 Score for turn so far: 17 If you HOLD now scores will be: player 1: 48 player 2: 26 DECISION - HOLD - TURN IS OVER START OF TURN NUMBER 14 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: 48 player 2: 31 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: 48 player 2: 37 DECISION - ROLL AGAIN player 2 rolled a 1 on roll number 3 PIG! Score for turn is 0. TURN IS OVER START OF TURN NUMBER 15 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: 26 DECISION - ROLL AGAIN player 1 rolled a 5 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: 55 player 2: 26 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: 57 player 2: 26 DECISION - ROLL AGAIN player 1 rolled a 2 on roll number 4 Number of rolls this turn: 4 Score for turn so far: 11 If you HOLD now scores will be: player 1: 59 player 2: 26 DECISION - ROLL AGAIN player 1 rolled a 3 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: 62 player 2: 26 DECISION - ROLL AGAIN player 1 rolled a 4 on roll number 6 Number of rolls this turn: 6 Score for turn so far: 18 If you HOLD now scores will be: player 1: 66 player 2: 26 DECISION - HOLD - TURN IS OVER START OF TURN NUMBER 16 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 17 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: 68 player 2: 26 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 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 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: 68 player 2: 26 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 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: 66 player 2: 31 DECISION - ROLL AGAIN player 2 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: 66 player 2: 33 DECISION - ROLL AGAIN player 2 rolled a 3 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: 66 player 2: 36 DECISION - ROLL AGAIN player 2 rolled a 5 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: 66 player 2: 41 DECISION - ROLL AGAIN player 2 rolled a 4 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: 66 player 2: 45 DECISION - HOLD - TURN IS OVER START OF TURN NUMBER 21 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 22 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: 66 player 2: 50 DECISION - ROLL AGAIN player 2 rolled a 3 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: 66 player 2: 53 DECISION - ROLL AGAIN player 2 rolled a 6 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: 66 player 2: 59 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 23 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: 72 player 2: 45 DECISION - ROLL AGAIN player 1 rolled a 3 on roll number 2 Number of rolls this turn: 2 Score for turn so far: 9 If you HOLD now scores will be: player 1: 75 player 2: 45 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 24 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: 66 player 2: 48 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: 66 player 2: 50 DECISION - ROLL AGAIN player 2 rolled a 1 on roll number 3 PIG! Score for turn is 0. TURN IS OVER START OF TURN NUMBER 25 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: 72 player 2: 45 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 26 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 27 It is player 1's turn. player 1 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: 69 player 2: 45 DECISION - ROLL AGAIN player 1 rolled a 6 on roll number 2 Number of rolls this turn: 2 Score for turn so far: 9 If you HOLD now scores will be: player 1: 75 player 2: 45 DECISION - ROLL AGAIN player 1 rolled a 6 on roll number 3 Number of rolls this turn: 3 Score for turn so far: 15 If you HOLD now scores will be: player 1: 81 player 2: 45 DECISION - HOLD - TURN IS OVER START OF TURN NUMBER 28 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: 81 player 2: 47 DECISION - ROLL AGAIN player 2 rolled a 5 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: 81 player 2: 52 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: 81 player 2: 58 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 29 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: 86 player 2: 45 DECISION - ROLL AGAIN player 1 rolled a 4 on roll number 2 Number of rolls this turn: 2 Score for turn so far: 9 If you HOLD now scores will be: player 1: 90 player 2: 45 DECISION - ROLL AGAIN player 1 rolled a 2 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: 92 player 2: 45 DECISION - ROLL AGAIN player 1 rolled a 5 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: 97 player 2: 45 DECISION - HOLD - TURN IS OVER START OF TURN NUMBER 30 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: 97 player 2: 48 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 31 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: 99 player 2: 45 DECISION - ROLL AGAIN player 1 rolled a 3 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: 102 player 2: 45 DECISION - HOLD - TURN IS OVER FINAL RESULTS: Number of turns: 31 player 1 score: 102 player 2 score: 45 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: 5424 player 2 wins: 4576 player 1 and player 2 stop at 5 rolls for turn player 1 wins: 5398 player 2 wins: 4602 player 1 stops at 15 points and player 2 stops at 5 rolls player 1 wins: 5069 player 2 wins: 4931 player 1 stops at 5 rolls and player 2 stops at 15 points player 1 wins: 5739 player 2 wins: 4261