I'm making a dice program that calculates the statistics such as actual percentage, expected rolls and expected percentage and so on. I'm having a difficulty on the Pseudo random number generation. With two dice, the mim. sum of the dice is 2, not 1. There is something wrong with my code so it keep generating the number 1 out.

Can anyone help me with that?

cout << "Enter seed: "; 
		cin >> seed; 
		 
		cout << "Number of repeats: "; 
		cin >> intRepeats;  
		 
		x = seed;   //x is the PRN, and the first is user selected  
		 
		for (int i = 0; i < intRepeats; i++) 
		{ 
			x = ((multiplies * x) + inciement) % modulus;    //CREATE A RANDOM NUMBER  
			num = x / float (modulus);  
			roll = int (num * 12) +1; 
		 
			cout << "Dice roll was: " << roll << endl; 
			
			test++;
			frequency[(roll)]++;

[img] http://images.plurk.com/41fc82bc186ee5987fdfd4fcc78bc837.jpg [/img]

Two possibilities.
A. roll=int(num*11)+2; //Just reduce the 12 to 11 and add 2 instead of 1.
B. rewrite it to roll a single die, save the value, then roll again.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.