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
turn.
- 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.)
Output Format:
- Initially, prompt the user with "Hold-at-20 turn simulations? ".
- On the next line, print "Score" and "Estimated Probability" separated by
a tab.
- 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
score.
Sample Transcript (input underlined):
Hold-at-20 turn simulations? 1000000
Score Estimated Probability
0 0.624076
20 0.099659
21 0.095310
22 0.074086
23 0.054599
24 0.035313
25 0.016957
Extra Exercises:
- 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?
Todd Neller