PcgRandom

From Minetest Developer Wiki
Jump to: navigation, search

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).
Note that math.random works about 19.3 times as fast as this.

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
Personal tools
Namespaces

Variants
Actions
Navigation
API
Toolbox