Trying to loop craps game multiple times to find house advantage

The craps game below is correct...I just wanted to know what I would need to do to loop the game, say, 1000 times. I want to see what the house advantage would be when this game is run many times.

Thanks!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include <iostream>
#include <ctime>
#include <stdlib.h>

using namespace std;

int rollDice();

int main()
{
enum Status {CONTINUE, WON, LOST};
int myPoint = 0;
Status gameStatus;

srand(time(0));

int sumOfDice = rollDice();

switch(sumOfDice){

case 7:
case 11:
    gameStatus = WON;
    break;

case 3:
case 4:
case 12:
    gameStatus = LOST;
    break;

default:
    gameStatus = CONTINUE;
    myPoint = sumOfDice;
    cout << "Point is: " << myPoint << endl;
    break;
}

while(gameStatus == CONTINUE){

    sumOfDice = rollDice();
    if (sumOfDice == myPoint)
        gameStatus = WON;
    if (sumOfDice == 7)
        gameStatus = LOST;
    }

    if (gameStatus == WON)
    cout << "Player wins!" << endl;
    else
    cout << "Player loses!" << endl;

}

int rollDice(){

int dice1 = 1 + rand()%6;
int dice2 = 1 + rand()%6;

int total = dice1 + dice2;

cout << "Player rolled " << dice1 << " and " << dice2 << " for a total of " << total << endl;

return total;

}
Last edited on
Topic archived. No new replies allowed.