First, you are learning, so don't learn the
deprecated rand(). Learn the current tools for randomness. For example, the
http://www.cplusplus.com/reference/random/uniform_int_distribution/
Second, there is no such thing as "guaranteed" in random. There is just probability. If you want to ensure that there is at least one win per 15 rolls, then you could on the 15th roll check whether the 14 previous rolls did win. If yes, do normal random roll. If not, then set 1-1-1 without randomness. Anyone testing the machine properly would probably notice and start to bet on the 15th rolls ...
You have three wheels. If one wheel has only three values, {1, 2, 3}, then the probability that one wheel gets specific value is 1/3 and that all three wheels get the same value is 1/3*1/3*1/3 = 1/27. The other combinations show up 24/27.
The wheels on those machines do have more than three values, do they not?
Lets make a machine with 6 values: {1, 1, 1, 2, 2, 3}. Now the chance to get '1' is 1/2, to get '2' is 1/3, and to get '3' is 1/6. That leads to:
all 1's: 1/8
all 2's: 1/27
all 3's: 1/216
Not quite the numbers you had in mind, but you can keep evolving the wheels.
Furthermore, each wheel can be different. The user will not know.
1 2 3 4 5 6 7 8 9 10 11 12
|
const std::vector<int> wheelA = {1, 1, 1, 2, 2, 3}
// construct a trivial random generator engine from a time-based seed:
unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
std::default_random_engine generator( seed );
std::uniform_int_distribution<int> distribution( 0, wheelA.size() - 1 );
// one roll of the wheel:
int fruit = wheel[ distribution(generator) ];
if ( fruit == 42 ) bankruptcy(); // like we would lose. Ever.
|