How to randomize a whole number?
I had to be randomized a number from 1 to 3.
But thus appears in the text box:
3.5453500345
or 1.00004343
: (
Develop games in your browser. Powerful, performant & highly capable.
Generate a random float from 0 to x, not including x. E.g. random(4) can generate 0, 2.5, 3.29293, but not 4. Use floor(random(4)) to generate just the whole numbers 0, 1, 2, 3.
<img src="smileys/smiley32.gif" border="0" align="middle" />
Good post from Ashley HERE discusses this and explains why it should be done a particular way, and THIS LINK discusses how weighting would affect the results, which would probably be the same for floor.