Closed TimothyGu closed 5 years ago
If I understand correctly, .seed
gets the current state of the PRNG, suitable for creating a clone of the current PRNG which will produce the same values, whereas .randomSeed
gets a new seed every time it's invoked, suitable for creating a new PRNG which will produce different values. (These are confusingly similar, and one of them should probably be renamed. I'd vote for renaming .seed
to .state
.)
It seems reasonable for .seed
to be a getter, but not .randomSeed
.
Good catch on the distinction. I agree with your points.
Hmmm, making .seed a getter would be reasonable.
I'm against using a non-"seed" word, because the whole point (of both of them) is that it's an appropriate value to use as a {seed}
parameter of a new prng. Open to suggestions for better names under that constraint, tho.
Ooh, unexpected convenience of this switch: cloning a PRNG can now be done by just passing the parent PRNG as the argument, since it'll just pull the .seed property off of it:
const prng = Math.seededPRNG({seed:0});
const clone = Math.seededPRNG(prng);
First, the explainer seems to be inconsistent on whether it'sprng.seed()
orprng.randomSeed()
.Second, it seems to be more natural to make the
seed
/property a getter instead. The operation of getting the seed seems to be fairly lightweight, and a getter would better convey that.randomSeed