Get random value in range
To get a random value, say from 17 plus or minus 3, I can say:
20 - Math.random() * 6
I was saying:
d = Math.random() * 3;
if (Math.random() < 0.5) {
d *= -1;
}
v = 17 + d;
There are more tips at: bbingo.xyz/techtips/
To get a random value, say from 17 plus or minus 3, I can say:
20 - Math.random() * 6
I was saying:
d = Math.random() * 3;
if (Math.random() < 0.5) {
d *= -1;
}
v = 17 + d;
There are more tips at: bbingo.xyz/techtips/
Comments
Post a Comment