I am making a simple (terminal) slot machine project, in which 3 fruit names will be output in the terminal, and if they are all the same then the player wins.
I cannot figure out how to make a set probability that the player will win the round (roughly 40% chance for example). As of now I have:
this->slotOne = rand() % 6 + 1; // chooses rand number for designated slot
this->oneFruit = spinTOfruit(this->slotOne); //converts rand number to fruit name
this->slotTwo = rand() % 6 + 1;
this->twoFruit = spinTOfruit(this->slotTwo);
this->slotThree = rand() % 6 + 1;
this->threeFruit = spinTOfruit(this->slotThree);
which picks a "fruit" based on the number, but each of the three slots has a 1 in 6 chance (seeing that there are 6 fruits). Since each individual slot has a 1/6 chance, overall the probability of winning is incredibly low.
How would I fix this to create better odds (or even better, chosen odds, changing the odds when desired)?
I thought of changing the second two spins to less options (rand()%2 for instance), but that would make the last two slots choose the same couple fruits every time.
The link to my project: https://github.com/tristanzickovich/slotmachine