Hold-at-20 Outcomes (Estimation)
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:
- roll - If the player rolls a
- 1: the player scores nothing and it becomes the opponent's
- 2 - 6: the number is added to the player's turn total and the
player's turn continues.
- hold - The turn total is added to the player's score and it
becomes the opponent's turn.
Problem: Simulate a given number of hold-at-20 turns, and report the
estimated probabilities of the possible scoring outcomes.
Input Format: Enter a single positive integer indicating the number of
turns simulated. (Larger numbers will tend to yield better estimations.)
- Initially, prompt the user with "Hold-at-20 turn simulations? ".
- On the next line, print "Score" and "Estimated Probability" separated by
- After the simulations, print a table line for each score outcome that
occurred in increasing order of score. For each score outcome, print
the score, a tab, and the fraction of turn simulations that yielded that
Sample Transcript (input underlined):
Hold-at-20 turn simulations? 1000000
Score Estimated Probability
- What is the expected average score outcome for hold-at-20?
- Additionally allow the user to specify the hold value. What is the
probability of reaching 100 in a single turn?