Random Number Generation


Random number generation for procedural generation is almost always based on algorithms that deterministically produce pseudorandom numbers, rather than being fetched from an truly random external source such as cosmic background radiation or radioactive decay.

There are two primary methods of generating pseudorandom numbers: Random number generators and random hash functions.

  • Random number generators (or RNGs) produce a sequence of random numbers. Each random number is using the previous as part of its calculation, so it's not possible to get the Nth random number without first having gotten the first N-1 random numbers as well.
  • Random hash functions take an input and produce a random output. The same input always produces the same output with no dependency on previous queries. Not all hash functions are well suited for procedural generation, as they may either not have sufficiently random distribution, or be unnecessarily expensive, but there are some that are very well suited.

Both random number generators and random hash functions can support dynamic-world-generation using a random seed.

Code Example

External Links

Random number generation - Wikipedia article on Random Number Generation.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License