Module ROT.RNG
The RNG Class.
A Lua port of Johannes Baagøe's Alea
From http://baagoe.com/en/RandomMusings/javascript/
Johannes Baagøe
Functions
getSeed ([s=os.clock()]) | Seed. |
setSeed ([s=os.clock()]) | Seed. |
getState () | Get current rng state Returns a table that can be given to the rng to return it to this state. |
setState (stateTable) | Set current rng state used to return an rng to a known/previous state |
random ([a=0[, b=1]]) | Random. |
Functions
- getSeed ([s=os.clock()])
-
Seed.
seed the rng
Parameters:
- s number A number to base the rng from (default os.clock())
- setSeed ([s=os.clock()])
-
Seed.
seed the rng
Parameters:
- s number A number to base the rng from (default os.clock())
- getState ()
-
Get current rng state
Returns a table that can be given to the rng to return it to this state.
Any RNG of the same type will always produce the same values from this state.
Returns:
-
table
A table that represents the current state of the rng
- setState (stateTable)
-
Set current rng state
used to return an rng to a known/previous state
Parameters:
- stateTable table The table retrieved from .getState()
- random ([a=0[, b=1]])
-
Random.
get a random number
Parameters:
- a int lower threshold for random numbers (default 0)
- b int upper threshold for random numbers (default 1)
Returns:
-
number
a random number