| Schedule | Readings | Labs | Homework | Mechanics | Contact | |
| CSC 151-01, 2007S » Homework 11 » Simulating Craps | ||||||
One of the many table gains available in most casinos is Craps. While Craps has a variety of betting rules, the basic rules for rolling the dice are fairly simple. Here's what Wikipedia has to say on the subject.
Craps features a plethora of bets, but the most fundamental is the
pass linewager, which nearly all players make. On a come-out roll, the pass line bettors win when either a 7 or 11 is rolled. A 2, 3, or 12 loses, and is calledcraps. When any other number (4, 5, 6, 8, 9, or 10) is rolled, it is called the point. Once a point has been set, the pass-line bettor wins if the point is rolled again, and loses if a 7 is rolled first (seven-out).
For our purposes in this assignment, we'll assume one die is red (or scarlet) and one die is black.
In this assignment, you will simulate the game of Craps, focusing only on the results for pass-line bettors.
Write a procedure, (craps-narrative),
that
plays and
narrates one sequence from a game of Craps. Your narrative should
roll new dice each time, and therefore have unpredictable results. Here is an example showing several runs:
> (craps-narrative)
Come-out roll.
The red die shows 1. The black die shows 6.
A seven: You win!
> (craps-narrative)
Come-out roll.
The red die shows 2. The black die shows 3.
The point is 5.
The red die shows 5. The black die shows 5.
The point is 5.
The red die shows 3. The black die shows 4.
Seven out.
> (craps-narrative)
Come-out roll.
The red die shows 1. The black die shows 5.
The point is 6.
The red die shows 3. The black die shows 5.
The point is 6.
The red die shows 4. The black die shows 2.
You made the point.
> (craps-narrative)
Come-out roll.
The red die shows 1. The black die shows 5.
The point is 6.
The red die shows 3. The black die shows 5.
The point is 6.
The red die shows 4. The black die shows 2.
You made the point.
> (craps-narrative)
Come-out roll.
The red die shows 4. The black die shows 1.
The point is 5.
The red die shows 2. The black die shows 5.
Seven out.
To a statistician, the interesting thing about Craps is not what happens in one game, or even a few, but what happens over a long series of games.
Write a procedure, pass-line-bet-wins?
that
simulates
one sequence from a game of Craps and returns true (#t)
if the pass-line bettor wins and false (#f) otherwise.
Using this procedure, simulate one thousand sequences of Craps and determine how often the pass-line bettor wins in that sequence.
For both parts of the assignment, you will likely find it useful to write a main procedure that does the initial roll and a helper procedure that gets passed the points goal from the first roll.
We wrote the following two helper procedures in our own solution to this assignment. You may also find them helpful.
(define roll-a-die
(lambda ()
(+ 1 (random 6))))
(define display-dice
(lambda (red black)
(display " The red die shows ")
(display red)
(display ". The black die shows ")
(display black)
(display ".")
(newline)))
Wikipedia (2006). Craps. Online article at
http://en.wikipedia.org/wiki/Craps
(dated
28 September 2006, visited 1 October 2006).
Janet Davis (davisjan@cs.grinnell.edu)
Created March 1, 2007 based on http://www.cs.grinnell.edu/~davisjan/csc/151/2006F/homework/10.craps.html