Make the default seed of the generator returned by deterministicRandom() random. This means that the random number sequence won't be deterministic unless you set a seed.

This commit is contained in:
A.J. Beamon 2019-06-04 13:40:48 -07:00 committed by Alex Miller
parent 31e82a6d6d
commit c027792d0f
2 changed files with 3 additions and 1 deletions

View File

@ -127,6 +127,8 @@ void setThreadLocalDeterministicRandomSeed(uint32_t seed);
// Returns the random number generator that can be seeded. This generator should only
// be used in contexts where the choice to call it is deterministic.
//
// This generator is only deterministic if given a seed using setThreadLocalDeterministicRandomSeed
Reference<IRandom> deterministicRandom();
// A random number generator that cannot be manually seeded and may be called in

View File

@ -37,7 +37,7 @@ void setThreadLocalDeterministicRandomSeed(uint32_t seed) {
Reference<IRandom> deterministicRandom() {
if(!seededRandom) {
seededRandom = Reference<IRandom>(new DeterministicRandom(1, true));
seededRandom = Reference<IRandom>(new DeterministicRandom(platform::getRandomSeed(), true));
}
return seededRandom;
}