mirror of
https://github.com/love2d/love.git
synced 2026-08-15 07:41:11 +02:00
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:
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user