Game dev
Saved & recent

Pseudo-random numbers

Also called: pseudorandom numbers

Related terms: PRNG, RNG, seed, hash function

A computer cannot roll dice. It uses a formula that turns one number into the next, giving a sequence that only looks random. The starting number is the seed. The same seed always gives the same sequence.

That is a feature. It makes replays, daily challenges, shareable worlds and reproducible bugs possible. A hash function is the version with no memory: feed it a coordinate and get a random-looking value back. Noise is built on hashes.

Further reading
Melissa O’Neill: PCG Random Number Generation
seed 42 25 08 57 22 37 02 seed 42 25 08 57 22 37 02 seed 43 25 17 26 25 04 77 successive draws one generator
Each row shows the first six draws, mapped to integers from 0 to 99. The same seed restarts the same sequence.

View in the full Game dev collection