Hold-at-20 Outcomes (Computation)

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:

Problem:  Compute and report the probabilities of the possible scoring outcomes from a hold-at-20 Pig turn.

The following is a dynamic programming algorithm that approaches the problem by computing the probability of passing through each score on the way to the final outcome:

At the beginning of each iteration i,  score[i] is the probability of passing through score i.  After all iterations, the remaining positive values are the probabilities of their respective score outcome probabilities.

Input Format:  (no input)

Output Format:

Sample Transcript:

Score   Probability
0       0.624541
20      0.099713
21      0.094991
22      0.074189
23      0.054196
24      0.035198
25      0.017173

Extra Exercises:

  1. What is the expected average score outcome for hold-at-20?
  2. Additionally allow the user to specify the hold value.  What is the probability of reaching 100 in a single turn?

Todd Neller