20 likes | 107 Views
Exercise 7. The following is excerpted from Richard Epstein’s “The Theory of Gambling and Statistical Logic”. Years ago, this was the textbook for a first year math course on gambling, sadly no longer offered.
E N D
Exercise 7 The following is excerpted from Richard Epstein’s “The Theory of Gambling and Statistical Logic”. Years ago, this was the textbook for a first year math course on gambling, sadly no longer offered. “Of the various dice games adopted by the gambling casinos, the most prevalent, by far, is Craps. The direct ancestor of Craps is the game of Hazard, reputedly (according to William of Tyre, died 1190) invented by twelfth-century English Crusaders during the siege of an Arabian castle, Montmort established formal rules for Hazard and it subsequently became highly popular in early nineteenth-century England and France. In the British clubs the casts of 2, 3, or 12 were referred to as “Crabs”. Presumably the French adaptation involved a Gaelic mispronunciation, which contributed the word “Craps”, and since the game immigrated to America with the French colony of New Orleans, its currency became firmly established. Craps is played with two dice. A player throws both dice, winning unconditionally if he produces the outcomes 7 or 11 (as the sum of the numbers showing on the two dice), which are designated as “naturals”. If a player casts the outcomes 2, 3, or 12 – referred to as “craps” – he loses unconditionally. If he produces the outcomes 4, 5, 6, 8, 9, or 10, each of these outcomes being known as a “point”, he continues the sequence of throws until either the same outcome (point) is repeated or the outcome 7 occurs. Repetition of the particular “point” is a win, while the appearance of a 7 now signifies a loss.”. In casino, one can bet the “pass line”. This bet wins if the player wins (“makes a pass”) and loses if the player loses. One can also bet on “don’t pass bar 6-6”. This is basically betting against the player. In general, the bet wins if the player loses (and vice versa). If the player first roll is 6-6, however, the better neither wins nor loses, but simply gets his money back. Both the “pass line” and “don’t pass bar 6-6” pay out at two to one: if one bets $1, and the bet wins, one gets $2 back. For this assignment, you are to write a program which uses simulation to determine 1/. the percentage of the time that a “pass line” bet will win, 2/. the percentage of the time that a “don’t pass bar 6-6” bet will win (ignoring ties) and 3/. and the average number of die rolls per game. Simulation is, it must be admitted, not really very appropriate here, as all of the required quantities can easily be computed analytically. The problem works well as an exercise in simulation, however, and knowing the exact answers allows one to easily see how good (or bad) the simulation results are.
Your program must include a “die rolling” function and a function which simulates a single game of craps. The second of these functions must somehow “return” whether the player won, whether his first roll was a 12, and the number of die rolls it took to produce an outcome. Since the normal return mechanism can return only one value, you will need to use call by reference for at least two of these quantities. Your program should ask the user for the number of games to be simulated, and should loop so as to allow the effects of different values to be easily investigated (see the sample program). Food for thought (optional): Suppose you were to discover that one of the dice in use at a Craps table in the Hull casino was biased, and that a 3 came up 40% of the time (with each of the other values appearing 12% of the time). Would this represent a money-making opportunity and, if so, which bet should be chosen?