In Chapter 3, one of the exercises explained that in many programming languages you can generate a random number between 1 and a limiting value named LIMIT by using a statement
similar to random Number = random(LIMIT). Create the logic for the dice game Pig in which a player can compete with the computer. Th e object of the game is to be the first to score 100 points. Th e user and computer take turns rolling a pair of dice, the values of which are determined randomly.
Th e game follows these rules:
• On a turn, each player "rolls" two dice. If no 1 appears, the dice values are added to a running total, and the player can choose whether to roll again or pass the turn to the other player.
• If a 1 appears on one of the dice, nothing more is added to the player's total and it becomes the other player's turn.
• If a 1 appears on both of the dice, not only is the player's turn over, but the player's entire accumulated score is reset to 0.
• In this version of the game, when the computer does not roll a 1 and can choose whether to roll again, generate a new random value of 1 or 2. Use this value to decide whether the computer will continue to play or to pass the turn to the player.