Re: Resting outside is nearly always interrupted
Posted: 17 May 2015, 07:30
exactly getting it would need somehow seeding the generator althought goes over my head.
in previous fix
rand generator isn't always reliable in OEngine::Misc::Rng::rollDice(hoursToWait)
http://www.cplusplus.com/reference/cstdlib/rand/
stackoverflow
just some found googling std rand
in previous fix
Code: Select all
int x = OEngine::Misc::Rng::rollDice(hoursToWait);
if (x > fSleepRandMod * hoursToWait)
mInterruptAt = hoursToWait - int(fSleepRestMod * hoursToWait)
Code: Select all
int Rng::rollDice(int max)
{
return static_cast<int>((std::rand() / (static_cast<double>(RAND_MAX)+1.0)) * (max));
http://en.cppreference.com/w/cpp/numeric/random/randNotice though that this modulo operation does not generate uniformly distributed random numbers in the span (since in most cases this operation makes lower numbers slightly more likely).
stackoverflow
just some found googling std rand