diff options
author | kwolekr <kwolekr@minetest.net> | 2015-03-22 00:01:46 -0400 |
---|---|---|
committer | kwolekr <kwolekr@minetest.net> | 2015-03-22 00:48:08 -0400 |
commit | 3993093f51544d4eb44efb57c973e29107ea2f7a (patch) | |
tree | 0533167edce0dbd2cb8f03c37b880e57cfd7916d /doc | |
parent | 7679396ebbb38115eedbfb8e9636dff50cdf2075 (diff) | |
download | minetest-3993093f51544d4eb44efb57c973e29107ea2f7a.tar.gz minetest-3993093f51544d4eb44efb57c973e29107ea2f7a.tar.bz2 minetest-3993093f51544d4eb44efb57c973e29107ea2f7a.zip |
Add support for the PCG32 PRNG algo (and associated script APIs)
Diffstat (limited to 'doc')
-rw-r--r-- | doc/lua_api.txt | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/doc/lua_api.txt b/doc/lua_api.txt index 81a35976b..fbacb07d9 100644 --- a/doc/lua_api.txt +++ b/doc/lua_api.txt @@ -2515,7 +2515,8 @@ an itemstring, a table or `nil`. Returns taken `ItemStack`. ### `PseudoRandom` -A pseudorandom number generator. +A 16-bit pseudorandom number generator. +Uses a well-known LCG algorithm introduced by K&R. It can be created via `PseudoRandom(seed)`. @@ -2525,6 +2526,19 @@ It can be created via `PseudoRandom(seed)`. * `((max - min) == 32767) or ((max-min) <= 6553))` must be true due to the simple implementation making bad distribution otherwise. +### `PcgRandom` +A 32-bit pseudorandom number generator. +Uses PCG32, an algorithm of the permuted congruential generator family, offering very strong randomness. + +It can be created via `PcgRandom(seed)` or `PcgRandom(seed, sequence)`. + +#### Methods +* `next()`: return next integer random number [`-2147483648`...`2147483647`] +* `next(min, max)`: return next integer random number [`min`...`max`] +* `rand_normal_dist(min, max, num_trials=6)`: return normally distributed random number [`min`...`max`] + * This is only a rough approximation of a normal distribution with mean=(max-min)/2 and variance=1 + * Increasing num_trials improves accuracy of the approximation + ### `PerlinNoise` A perlin noise generator. It can be created via `PerlinNoise(seed, octaves, persistence, scale)` |