-
Notifications
You must be signed in to change notification settings - Fork 0
7. Randomness
CookieShade edited this page Jul 16, 2016
·
2 revisions
Random number generation for basic uses.
Note: Technically pseudo-random, not truly random. Get your own library if you care.
Generates a random real number in the range [a, b). Roughly evenly distributed.
var num = BETA.randNum(-2.5, 2); // -2.5 ≤ x < 2
Generates a random integer in the range [a, b]. Roughly evenly distributed.
Returns NaN
if there is no integer in [a, b].
var int = BETA.randInt(-2.5, 2); // -2 ≤ x ≤ 2
Returns a randomly selected element in an array. Each element is roughly equally likely to be selected.
var el = BETA.randElement(["ghost", "skeleton", "zombie", "internet explorer"]) // Returns something terrifying