Changed love.math.randomnormal([mean], stddev) to love.math.randomNormal(stddev, [mean]);

Changed love.math.randomseed(seed) to love.math.setRandomState(state) and love.math.setRandomState(low, high). Added low, high = love.math.getRandomState().

love.math.setRandomState(state) can set the random state to an integer of up to 53 bits, love.math.setRandomState(low, high) can set the random state to a 64 bit integer by using the first argument as the lower 32 bits and the second argument as the higher 32 bits.
This allows for reliable setting and saving of the state of a RNG.

--HG--
branch : RandomGenerator-2
This commit is contained in:
Alex Szpakowski
2013-08-01 18:32:44 -03:00
parent dfba650575
commit 0447d1e7c5
8 changed files with 143 additions and 90 deletions
+20 -8
View File
@@ -53,12 +53,24 @@ public:
virtual ~Math()
{}
/**
* @copydoc RandomGenerator::randomseed()
**/
inline void randomseed(uint64 seed)
inline void setRandomState(RandomGenerator::State state)
{
rng.randomseed(seed);
rng.setState(state);
}
inline void setRandomState(uint32 low, uint32 high)
{
rng.setState(low, high);
}
inline RandomGenerator::State getRandomState() const
{
return rng.getState();
}
inline void getRandomState(uint32 &low, uint32 &high) const
{
rng.getState(low, high);
}
/**
@@ -86,11 +98,11 @@ public:
}
/**
* @copydoc RandomGenerator::randomnormal()
* @copydoc RandomGenerator::randomNormal()
**/
inline double randomnormal(double stddev)
inline double randomNormal(double stddev)
{
return rng.randomnormal(stddev);
return rng.randomNormal(stddev);
}
/**