So I found out something interesting when using Math.random in AS3: when you use Math.round, which is basically the best, most unbiased way to try to get whole numbers, the minimum and maximum outcomes will actually have LESS of a chance than every other number. So for instance, if you were trying to generate a number from 1-10, 2-9 would have a higher chance (11.25% each) of getting generated than 1 and 10 (5.62% each) instead of all of them actually being at 10%.

Now why is this? Well, since the minimum number is 1, the only possible way to get a 1 is to get anywhere from 1 to 1.5, while getting another random number like, say, 6, you can get anywhere from 5.5 to 6.5, which, as you can see, is double the leeway of getting a 1 (and the same exact thing obviously applies to 10, since you have to get a number anywhere from 9.5 to 10).

So this is just something to keep in mind when using the RNG in AS3. I did find a workaround you can use to get a true, unbiased percent for whatever you’re doing, however: if you were trying to get a number from 1 to 10, code it as 0 to 11 instead. 0 and 11 will have a lower chance of getting picked than the other numbers, but if they DO get picked, you can make the randomizer run again. So for example:

var rng = Math.round(Math.random() * 11);

if (rng == 0)

{

rng = Math.round(Math.random() * 11);

}

if (rng == 11)

{

rng = Math.round(Math.random() * 11);

}

This will give you a randomizer that generates any number from 1-10 at an actual 10% each.

If someone knows of a way to do this without the workaround, please let me know. Otherwise, you can just do this. Hope you learned something, and thanks for reading.