Craps Dice Game (Ex9-7, P.294)
Craps is a dice game played at many casinos. A player rolls a
pair of normal six-sided dice.
-
If the initial roll is 2, 3, or 12, the player loses.
- If the roll is 7 or 11, the player wins.
- Any other initial roll causes the player to "roll for point."
- The player keeps rolling the dice until either rolling a 7 or
re-rolling the value of the initial roll
(any value of the dice that sum to the point will do; the player
doesn't have to exactly repeat the value combination of the come-out
roll).
- If the player re-rolls the initial value before rolling a 7,
it's a win.
- Otherwise, the player loses when he/she rolls a 7.
Write a program to simulate multiple games of craps and estimate the
probability that the player wins. For example, if the player wins 249
out of 500 games, then the estimated probability of winning is 249/500 =
0.498.