mirror of
https://github.com/luanti-org/luanti.git
synced 2025-10-14 17:15:21 +02:00
Add support for the PCG32 PRNG algo (and associated script APIs)
This commit is contained in:
@@ -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)`
|
||||
|
Reference in New Issue
Block a user