I'm building a system that depends on a correct percentage winning chance.
After trying it myself, and with many solutions from other asked questions.
I not found a single solution that seems to come close, to the chance the percantage indicates.
In my best test, I got between 30%-39% wins on 100k trys with a chance of 0.6%.
(currently the lowest chance is about 0.025%)
Wouldn't matter to me if the chance would be around 1-3%, but 30%-39%?
function randChance($percent){
$number = 100;
$percent *= $number;
while(floor($percent) != $percent){
$number *= 10;
$percent *= 10;
}
$rates = [$number,$percent];
for ($i = 0; $i <= count($rates); $i++) {
$rate = $rates[$i] * 100;
for ($j = 0; $j <= $rate; $j++) {
$chance[] = $i;
}
}
shuffle($chance);
$rnd = mt_rand(0,(count($chance)+1));
return $chance[$rnd];
}
Aucun commentaire:
Enregistrer un commentaire