Answer the question
In order to leave comments, you need to log in
Set the probabilities for the occurrence of two numbers with an indication of the chance, how?
There is such a game:
The user himself chooses the chance that he will guess. The greater the chance, the more likely it is to guess the button and get a win. And vice versa.
The question is that I don't know how to correctly write the probability in order to take into account the entered chance and, based on this, generate this or that button.
The "normal" probability won't work. Because at 80% you can win 20 times in a row, and this is no good.
That is why I created the question, because I don’t even know what can be thought up in this case.
Answer the question
In order to leave comments, you need to log in
Generate a random from 1 to 100 and see if it's equal to or less than the specified probability.
$chance = 80;
if( mt_rand(1, 100) <= $chance) {
// выиграл
} else {
// проиграл
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question