Module RNG
RNG functions
Functions
| random (m, n) | Functions the same as math.random(m, n), but using the RNG object's state. |
| randomseed (seed) | Functions the same as math.randomseed(seed), but affecting the RNG object's state. |
| getseed () | Returns the RNG object's seed. |
Functions
- random (m, n)
-
Functions the same as math.random(m, n), but using the RNG object's state.
When called without arguments, returns a uniform pseudo-random real number in the range [0,1).
When called with an integer number m, returns a uniform pseudo-random integer in the range [1, m].
When called with two integer numbers m and n, returns a uniform pseudo-random integer in the range [m, n].
Parameters:
- m int (optional) The start of the number range, if n is also provided; else, the end of the number range (the start of which being 1)
- n int (optional) The end of the number range
Returns:
-
number
A pseudo-random number based on the RNG object's state.
Usage:
RNG.random(12,24) -- returns an integer between 12 and 24, inclusive. RNG.random(12) -- returns an integer between 1 and 12, inclusive. RNG.random() -- returns a number in the range [0,1).
- randomseed (seed)
-
Functions the same as math.randomseed(seed), but affecting the RNG object's state.
Sets the pseudo-random generator's seed: equal seeds produce equal sequences of numbers.
Parameters:
- seed int (optional) An optional number input to set the seed with. If none is given, a client-generated seed is used.
Usage:
RNG.randomseed(151260123)
- getseed ()
-
Returns the RNG object's seed.
Returns:
-
int
The RNG object's seed.