random
random copied to clipboard
Predictable pseudo random number
I expected this module to return the same sequence of random numbers if seeded with the same value. But it seems completely unpredictable. I'm I missing something?
const rng = random.clone(seed).uniform();
rng();
rng();
rng();
I would've expected the three rnd()
calls to return the same random numbers every time.
This was definitely a bug; sorry about that.
I just published a fix that hopefully resolves your issue as v2.1.1
.
Thank you, but unfortunately it does not. The same example provided in this issue always returns different values, even giving the same seed
.
@transitive-bullshit Will this be resolved?
Same issue here.
Fortunatly this problem seems to be solved when using seedrandom explicitly:
// always random
const rng = random.clone('my-new-seed')
// always the same results
const rng2 = random.clone(seedrandom('kittyfoo'))
Just tested with v4
and this has been resolved after this fix https://github.com/transitive-bullshit/random/commit/4243d10c8139fe18878f4b186ad18ff67cac789c