Fundamentals of Computer Science I (CS151.02 2007S)
[Skip to Body]
Primary:
[Front Door]
[Syllabus]
[Glance]
[Search]
-
[Academic Honesty]
[Instructions]
Current:
[Outline]
[EBoard]
[Reading]
[Lab]
[Assignment]
Groupings:
[EBoards]
[Examples]
[Exams]
[Handouts]
[Homework]
[Labs]
[Outlines]
[Projects]
[Readings]
Reference:
[Scheme Report (R5RS)]
[Scheme Reference]
[DrScheme Manual]
Related Courses:
[CSC151 2006F (Rebelsky)]
[CSC151.01 2007S (Davis)]
[CSCS151 2005S (Stone)]
This homework assignment is also available in PDF.
Assigned: Friday, March 2, 2007
Due: Tuesday, March 6, 2007
Extensions due to weather automatically approved.
Summary: In this assignment, you will further explore
the use of the random
procedure to simulate a game of
Craps.
Purposes:
To reinforce the exploration of the random
procedure
from the lab on randomness and simulation. To remind you that
the house always wins
.
Expected Time: One to two hours.
Collaboration: You may work in a group of any size between one and four, inclusive. You may consult others outside your group, provided you cite those others. You need only submit one assignment per group.
Submitting: Email me your work, using a subject of CSC151 Homework 10.
Warning: So that this exercise is a learning assignment for everyone, I may spend class time publicly critiquing your work.
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.
a. 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.
> (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.
b. To the Statistician, the interesting thing about Craps is not what happens in one game, or even a few, but what happens, on average, over a sequence 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 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. For example, in the first part, you might write:
(define craps-narrative (lambda () (let ((point ...)) ... (continue-narrative point)))) (define continue-narrative (lambda (point) (let ((nextroll ...)) ...)))
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).
Sunday, 1 October 2006 [Samuel A. Rebelsky]
Monday, 2 October 2006 [Samuel A. Rebelsky]
Thursday, 1 March 2007 [Samuel A. Rebelsky]
[Skip to Body]
Primary:
[Front Door]
[Syllabus]
[Glance]
[Search]
-
[Academic Honesty]
[Instructions]
Current:
[Outline]
[EBoard]
[Reading]
[Lab]
[Assignment]
Groupings:
[EBoards]
[Examples]
[Exams]
[Handouts]
[Homework]
[Labs]
[Outlines]
[Projects]
[Readings]
Reference:
[Scheme Report (R5RS)]
[Scheme Reference]
[DrScheme Manual]
Related Courses:
[CSC151 2006F (Rebelsky)]
[CSC151.01 2007S (Davis)]
[CSCS151 2005S (Stone)]
Disclaimer:
I usually create these pages on the fly
, which means that I rarely
proofread them and they may contain bad grammar and incorrect details.
It also means that I tend to update them regularly (see the history for
more details). Feel free to contact me with any suggestions for changes.
This document was generated by
Siteweaver on Thu Sep 13 20:54:10 2007.
The source to the document was last modified on Thu Mar 1 21:35:45 2007.
This document may be found at http://www.cs.grinnell.edu/~rebelsky/Courses/CS151/2007S/Homework/hw.10.html
.
You may wish to
validate this document's HTML
;
;
http://creativecommons.org/licenses/by-nc/2.5/
or send a letter to Creative Commons, 543 Howard Street, 5th Floor,
San Francisco, California, 94105, USA.