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
+4 -3
View File
@@ -32,13 +32,14 @@ namespace math
{
// Helper functions.
uint64 luax_checkrandomseed(lua_State *L, int idx);
RandomGenerator::State luax_checkrandomstate(lua_State *L, int idx);
int luax_getrandom(lua_State *L, int startidx, double r);
RandomGenerator *luax_checkrandomgenerator(lua_State *L, int idx);
int w_RandomGenerator_randomseed(lua_State *L);
int w_RandomGenerator_setState(lua_State *L);
int w_RandomGenerator_getState(lua_State *L);
int w_RandomGenerator_random(lua_State *L);
int w_RandomGenerator_randomnormal(lua_State *L);
int w_RandomGenerator_randomNormal(lua_State *L);
extern "C" int luaopen_randomgenerator(lua_State *L);
} // math