Module gamejs/math/random
A seedable random-number generator.
A generator is initialized by GameJs and can be used with the static functions of this module:
gamejs.random.choose([1,2,4]); // integet between and including 2 and 5 gamejs.random.integer(2, 5);
You can re-initialize this generator with a different seed by calling gamejs.utils.prng.init(seed)
after which the static functions in this module will use the new seed.
A seedable pseudo-random number generator.
Parameters
Number|String |
seed |
the seed for generating the numbers |
Alea.prototype.random ()
Returns
Number |
the next random number as determined by the seed |
Alea.prototype.vector (min, max)
Returns
Object |
random item from items list |
Re-initialize the per instance random number generator used in the static functions on this module (e.g. vector())
Returns
Number |
random integer between min and max |
Returns
Number |
next random float between 0 and 1 |
vector (minVector, maxVector)
Parameters
Array |
minVector |
2 integers, the minimum vector |
Array |
maxVector |
2 integers, the maximum vector |
Returns
Array |
a random vector [min[0]<=x<=max[0], min[1]<=y<=max[1]] |