Class SeedableRandom
A fast, deterministic, seedable random number generator.
Defined in: random.js.
Constructor Attributes  Constructor Name and Description 

SeedableRandom(seed)
Unlike the native random number generator built into most browsers, this one is deterministic, and so it will produce the same sequence of outputs each time it is given the same seed.

Field Attributes  Field Name and Description 

The last value the random number generator was seeded with.


Alias for next();

Method Attributes  Method Name and Description 

next()
Get the next random number between 0 and 1 in the current sequence.


nextInt(a, gs)
Get the next random integer in the current sequence.


seed(x)
Seed the random number generator.


seed2d(x, y)
Seed the random number generator with a two dimensional seed.


seed3d(x, y, z)
Seed the random number generator with a three dimensional seed.

Class Detail
SeedableRandom(seed)
Unlike the native random number generator built into most browsers, this one is deterministic, and so it will produce the same sequence of outputs each time it is given the same seed. By default it is seeded with the current time, which means the output is effectively nondeterministic. To make the output deterministic (e.g. the same each time) you should seed it with your own number. This code is based on George Marsaglia's MWC algorithm from the v8 Javascript engine.
 Parameters:
 seed
 is an optional number to set the initial seed.
Field Detail
last_seed
The last value the random number generator was seeded with.
random
Alias for next();
Method Detail
next()
Get the next random number between 0 and 1 in the current sequence.
nextInt(a, gs)
Get the next random integer in the current sequence.
 Parameters:
 a
 The lower bound of integers (inclusive).
 gs
 The upper bound of integers (exclusive).
seed(x)
Seed the random number generator. The same seed will always yield the same sequence. Seed with the current time if you want it to vary each time.
 Parameters:
 x
 The seed.
seed2d(x, y)
Seed the random number generator with a two dimensional seed.
 Parameters:
 x
 First seed.
 y
 Second seed.
seed3d(x, y, z)
Seed the random number generator with a three dimensional seed.
 Parameters:
 x
 First seed.
 y
 Second seed.
 z
 Third seed.