davidbau / seedrandom

seeded random number generator for Javascript
2.06k stars 160 forks source link

Is it possible to get the seed when using the new Math.seedrandom() approach #27

Closed CuAnnan closed 9 years ago

CuAnnan commented 9 years ago

I'm trying to keep some things seeded pseudorandom so as to make it easy to save them.

But I want to keep the Math.random as is.

Is it possible to have the best of both worlds and get the seed generated when using new Math.seedrandom approach?

davidbau commented 9 years ago

Have been behind on github issues. The answer you're looking for is in the README.md:

The "pass" option can be used to get both the prng and the seed. The following returns both an autoseeded prng and the seed as an object, without mutating Math.random:

var obj = Math.seedrandom(null, { pass: function(prng, seed) {
  return { random: prng, seed: seed };
}});