Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a program that will simulate the dice game Pig for 2 players. Background: Game Rules The rules to the (dice) game of Pig: You
Write a program that will simulate the dice game Pig for 2 players.
Background: Game Rules The rules to the (dice) game of Pig: You will need 2 dice. To Play: The players each take turns rolling two die A player scores the sum of the two dice thrown (unless the roll contains a 1): If a single number 1 is thrown on either die, the score for that whole turn is lost (referred to as "Pigged Out"). A 1 on both dice is scored as 25 During a single turn, a player may roll the dice as many times as they desire. The score for a single turn is the sum of the individual scores for each dice roll. The first player to reach the goal score wins unless a player scores higher subsequently in the same round. Therefore, everyone in the game a. b. c. d. must have the same number of turns. Execution and User Input This program is quite interactive with the user(s) and will take in the following information; please review the sample input/output sessions for details; we describe them again here emphasizing input. The program will prompt for the number of points the game will be played to (1-100) Once a valid goal score has been entered the game will "roll" the dice for the first player by randomly selecting the valid values 1 thru 6 for each of the two dice. The score will be displayed and the player will be prompted to continue their turn by rolling the die again (unless they have "pigged out" by rolling a single The player will have the option of continuing or ending the turn by entering y'for Yes. When Player 1 completes their turn, Player 2 will engage the exact same way At the conclusion of both player's turns the total score for each will be compared to the goal score to determine if the game has ended. If the goal score has not been reached, then the game continues with both players taking their turn in sequence. Once one or both of the players reaches the goal score the game ends and the results are displayed. The game may end in a tie. At the conclusion of a game, the program will prompt whether a new game shall be played: y'for Yes. Background: Game Rules The rules to the (dice) game of Pig: You will need 2 dice. To Play: The players each take turns rolling two die A player scores the sum of the two dice thrown (unless the roll contains a 1): If a single number 1 is thrown on either die, the score for that whole turn is lost (referred to as "Pigged Out"). A 1 on both dice is scored as 25 During a single turn, a player may roll the dice as many times as they desire. The score for a single turn is the sum of the individual scores for each dice roll. The first player to reach the goal score wins unless a player scores higher subsequently in the same round. Therefore, everyone in the game a. b. c. d. must have the same number of turns. Execution and User Input This program is quite interactive with the user(s) and will take in the following information; please review the sample input/output sessions for details; we describe them again here emphasizing input. The program will prompt for the number of points the game will be played to (1-100) Once a valid goal score has been entered the game will "roll" the dice for the first player by randomly selecting the valid values 1 thru 6 for each of the two dice. The score will be displayed and the player will be prompted to continue their turn by rolling the die again (unless they have "pigged out" by rolling a single The player will have the option of continuing or ending the turn by entering y'for Yes. When Player 1 completes their turn, Player 2 will engage the exact same way At the conclusion of both player's turns the total score for each will be compared to the goal score to determine if the game has ended. If the goal score has not been reached, then the game continues with both players taking their turn in sequence. Once one or both of the players reaches the goal score the game ends and the results are displayed. The game may end in a tie. At the conclusion of a game, the program will prompt whether a new game shall be played: y'for YesStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started