1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Simplify LuaPseudoRandom::l_next and fix docs

Also extends the allowed range on the C++ side. This has no side-effects.
This commit is contained in:
sfan5 2024-01-10 20:08:00 +01:00
parent d20f1182f2
commit e824e9023f
5 changed files with 22 additions and 20 deletions

View file

@ -8061,7 +8061,9 @@ 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)`.
* constructor `PcgRandom(seed, [seq])`
* `seed`: 64-bit unsigned seed
* `seq`: 64-bit unsigned sequence, optional
### Methods
@ -8156,14 +8158,15 @@ Can be obtained using `player:get_meta()`.
A 16-bit pseudorandom number generator.
Uses a well-known LCG algorithm introduced by K&R.
It can be created via `PseudoRandom(seed)`.
* constructor `PseudoRandom(seed)`
* `seed`: 32-bit signed number
### Methods
* `next()`: return next integer random number [`0`...`32767`]
* `next(min, max)`: return next integer random number [`min`...`max`]
* `((max - min) == 32767) or ((max-min) <= 6553))` must be true
due to the simple implementation making bad distribution otherwise.
* Either `max - min == 32767` or `max - min <= 6553` must be true
due to the simple implementation making a bad distribution otherwise.
`Raycast`
---------