You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you look at the article's comments, you'll be able to see that "since seedrandom.js uses RC4 which is a cryptographically strong generator, it is designed very difficult to reverse. In other words, even if you know the sequence of generated bits, it is hard to go backwards to figure out the seed, and it is hard to go forward to predict the next random bits."
Further down, someone has stated that you can use the insert a few lines behind the arc4 = new ARC4(key); line:
// remember and restore PRNG statemath['getPrng']=function(){return[arc4.i,arc4.j,arc4.S.slice(0)];};//copies of i,j and Smath['setPrng']=function(prng){arc4.i=prng[0];arc4.j=prng[1];arc4.S=prng[2].slice(0);};
Hope this helps! (This wasn't made by me: you can see who made it in the comments.)
Not sure if saving the state is how to do this. I want to be able to go back a number of steps and repeat the random numbers again from there. So:
const r = seedrandom(100000);
console.log(Math.random(), Math.random(), Math.random()); // .78, .55. .13 // shortened ;-)
r.step(-3);
console.log(Math.random(), Math.random(), Math.random()); // .78, .55. .13
The text was updated successfully, but these errors were encountered: