For this program, simulate a craps game for a total of at most 20 wagers. That is, the first player rolls

the dice until he either wins or loses. That is the first wager. The winner then takes the dice, and rolls

until the second wager is decided. And so on, for a total of 20 wagers. However, if one of the

gamblers loses all of his money before the 20th wager, end the simulation at that point.

Assume that each player starts out with a balance of $1000. Assume also that when player 1 is rolling,

he always bets $100 on each wager. However, player 2 believes in luck and uses a strategy of his own

creation. When he has the dice and it is his turn to decide how much to bet, he considers how much

money he has. If he has at least as much money as he had when the game began, he decides his luck is

good and bets $150. If he has less money than when the game began, he decides his luck is bad, and

only bets $50 on that particular wager. Player 1 always rolls the dice first in this simulation.

You must use a pseudo-random number generator to simulate a dice roll. Use the DrawNum function

in the Lottery program handout. You may copy and paste it directly into your program 4 code, citing

the source in your comments. To simulate the roll of one die, call the DrawNum function once, with a

maximum roll of 6. Since the game is played with two dice, to simulate one roll you will have to

generate two numbers by calling DrawNum twice and then adding the two numbers together.

Your program must print out a roll-by-roll description of what happens as the game is played.

Sample out: Wager 1 : Bet is $100

Player 1 is rolling the dice

The roll is 2

That is craps! Player 1 loses.

Currently, Player 1 has $900 and Player 2 has $1100.

Wager 2 : Bet is $150

Player 2 is rolling the dice.

The roll is a 6. The point is 6. Player 2 rolls again.

The roll is a 5. The point is 6. Player 2 rolls again.

The roll is a 6. That is the point! Player 2 wins.

Currently, Player 1 has $750 and Player 2 has $1250.

Someone made a thread earlier today about a similar program. You could probably find tips by looking at it. Here's the link:

http://www.cplusplus.com/forum/beginner/115258/

http://www.cplusplus.com/forum/beginner/115258/

Topic archived. No new replies allowed.