Craps game problem..

Oct 12, 2017 at 10:00pm
So i have to write a craps game and the rules for it must be: If the sum of the first roll of the die is 7 or 11, the player wins. If the sum of the first roll is 2, 3, or 12, the player loses. If the sum of the first roll is 4, 5, 6, 8, 9, or 10, the game will continue with the first roll becoming the "point" and the player will continue rolling the die until they either roll a number that equals the point or they roll a 7. If the player rolls a number equaling the "point" they win. If they roll a 7, they lose. I have the first two rules to the game working fine except the initial roll when you start the game always equals 6 and is never a different number. I also can not figure out a way to do the last part where the roll becomes the "point" and they continue rolling, as you can see in the code i have sorta gotten that part started but im not sure how to actually make that work. Any advice would be appreciated

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
#include <iostream>
#include <ctime>
#include <limits>
#include <cstdlib>
int main()
{
    srand(8); //sets the random number generator

    int die1, die2 = 0; 
    int roll1, roll2 = 0;
    char repeat = 'y'; 

    std::cout << "Press ENTER to play a game of craps." << std::endl;

    while (repeat == 'y' || repeat == 'Y') // allows user to repeat the game
    {
        std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n'); 
        die1 = rand() % 6 + 1;
        die2 = rand() % 6 + 1; 
        roll1 = die1 + die2;

        std::cout << "The come out roll was: " << roll1 << std::endl;
        if (roll1 == 7, roll1 == 11)
        {
            std::cout << "You win! Would you like to play again? [Y/N]:" << std::endl;
            std::cin >> repeat;
        }
        else (roll1 == 2, roll1 == 3, roll1 == 12)
       {
		 
            std::cout << "Sorry, you lose! Would you like to play again? {Y/N]:" << std::endl;
            std::cin >> repeat;
        } 
        else if (roll1 == 4, roll1 == 5, roll1 == 6, roll1 == 8, roll1 == 9, roll1 == 10)
    	{
    		std::cout << "the point is: " <<roll1 << std::endl;
    		std::cin >> 
		}
	}
    

return(0);}
Oct 12, 2017 at 11:42pm
for the "randomness":
1
2
3
4
5
6
7
8
   // random number stuff
    std::random_device rd;
    std::mt19937 gen;
    gen.seed(rd());
    std::uniform_real_distribution<int> uni(1,6); // <= you want to use the STL generator

die1 = uni(gen);
// and so on ... 


I actually did not understand the part of the game with "points", maybe you want to describe it more easily?
Topic archived. No new replies allowed.