The JavaScript Math.random() function returns a random value between 0 and 1, automatically seeded based on the current time (similar to Java I believe). However, I don\'t
The code you listed kind of looks like a Lehmer RNG. If this is the case, then 2147483647
is the largest 32-bit signed integer, 2147483647
is the largest 32-bit prime, and 48271
is a full-period multiplier that is used to generate the numbers.
If this is true, you could modify RandomNumberGenerator
to take in an extra parameter seed
, and then set this.seed
to seed
; but you'd have to be careful to make sure the seed would result in a good distribution of random numbers (Lehmer can be weird like that) -- but most seeds will be fine.