|
The Game of Craps
Craps is a dice game with the following rules:
- The game is played wih two dice.
- A 7 or 11 on the first toss means an automatic win (called a "nick").
- A 2, 3, or 12 on the first toss means automatic lose (called a "crap").
- If the player tosses 4, 5, 6, 8, 9, or 10, then that number becomes the player's "point."
- The player repeats tossing until he wins by tossing his point a second time or loses by tossing a 7.
Let's take a look at the possible outcomes:
You can see by looking at the table below, that there are eleven possible outcomes. The dice can fall any of 36 ways. Six of these outcomes are called "doublets"--meaning both dice have the same number. The other 30 are variations. For example you can have an outcome of six by throwing 2-4, 4-2, and so on. All 36 possiblities need to be taken into account. This table shows the likleyhood of the various outcomes.
Nick, Crap, or Point |
c |
c |
p |
p |
p |
N |
p |
p |
p |
N |
c |
The Throw |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
Odds out of 36 throws |
1 |
2 |
3 |
4 |
5 |
6 |
5 |
4 |
3 |
2 |
1 |
You can calclulate the odds by adding up the fractions. Hitting a nick on the first time is equal to 8/36 in favor versus 28/36 against. This reduces down to 2/9 to 7/9, or as we say 7 to 2 against you scoring a nick.
Now, what we are going to do is write a program that plays Craps. I'm going to give you some of the pieces of the program, and then have you put it all together. You may work with one partner if you wish. Here's the basics:
Assignment
Write a Program that plays raps with the user. Use the following guidelines:
|