(svn r21886) -Codechange: move documentation towards the code to make it more likely to be updated [n].

This commit is contained in:
rubidium
2011-01-22 09:53:15 +00:00
parent 024869f33c
commit 43c8073551
33 changed files with 338 additions and 364 deletions

View File

@@ -15,6 +15,10 @@
Randomizer _random, _interactive_random;
/**
* Generate the next pseudo random number
* @return the random number
*/
uint32 Randomizer::Next()
{
const uint32 s = this->state[0];
@@ -24,17 +28,30 @@ uint32 Randomizer::Next()
return this->state[1] = ROR(s, 3) - 1;
}
/**
* Generate the next pseudo random number scaled to max
* @param max the maximum value of the returned random number
* @return the random number
*/
uint32 Randomizer::Next(uint32 max)
{
return ((uint64)this->Next() * (uint64)max) >> 32;
}
/**
* (Re)set the state of the random number generator.
* @param seed the new state
*/
void Randomizer::SetSeed(uint32 seed)
{
this->state[0] = seed;
this->state[1] = seed;
}
/**
* (Re)set the state of the random number generators.
* @param seed the new state
*/
void SetRandomSeed(uint32 seed)
{
_random.SetSeed(seed);