mercredi 5 avril 2017

Do you have a function (else than random) to find random dice(from 1 to 6) numbers(in C++)

I am writing a code for a game with seven dices and I have a problem. If I use a random function(dice = rand()%6 + 1) I realized the probability to get for instance a sequence such as 123456 (a sequence that makes points in my game) has a much higher probability to get out. Mathematically, this sequence has 1.54% probability to show up but When I use a random function with 100 millions iterations it appears up to 5.4% of the time!

That leads me to my question. Do you know another way I could randomize the dice so that they would respect the probability? Or a way to fix that problem anyway?

Thanks in advance!




Aucun commentaire:

Enregistrer un commentaire