Simulate throwing 3 dice. Tried using
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
function dorand2(){
var odice = document.getElementById("dice");
var a = 1;//tried without this too just 1 to 6
var b = 6 * a;
var r1 = 1+ Math.floor(getRandomInt(1, b)/a);
var r2 = 1+ Math.floor(getRandomInt(1, b)/a);
var r3 = 1+ Math.floor(getRandomInt(1, b)/a);
odice.innerHTML = "Dice A : " + r1 + " Dice B : " + r2 + " Dice C : " + r3;
}
Get same numbers for 1 or more in many tries. Am sure its even across runs. But looks odd, that out of 3 dice, get 5 on two of them, then next time 2 on two of them next turn... rarely are all 3 different. Would expect them to be different at least half the time?
Working sample: http://ift.tt/2zWvluz
Aucun commentaire:
Enregistrer un commentaire