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

Fix spelling of noise_threshold

This commit is contained in:
Jun Zhang 2015-12-05 21:00:11 +08:00 committed by BlockMen
parent 70ece71ee4
commit a78dd7f2b6
5 changed files with 19 additions and 10 deletions

View file

@ -99,17 +99,17 @@ u32 PcgRandom::range(u32 bound)
Using rand() % 3, the number 0 would be twice as likely to appear.
With a very large RNG range, the effect becomes less prevalent but
still present. This can be solved by modifying the range of the RNG
to become a multiple of bound by dropping values above the a threshhold.
In our example, threshhold == 4 - 3 = 1 % 3 == 1, so reject 0, thus
to become a multiple of bound by dropping values above the a threshold.
In our example, threshold == 4 - 3 = 1 % 3 == 1, so reject 0, thus
making the range 3 with no bias.
This loop looks dangerous, but will always terminate due to the
RNG's property of uniformity.
*/
u32 threshhold = -bound % bound;
u32 threshold = -bound % bound;
u32 r;
while ((r = next()) < threshhold)
while ((r = next()) < threshold)
;
return r % bound;