What happened

In 2003, mathematician George Marsaglia published his paper "Xorshift RNGs," introducing the xorshift generator family. These generators rely on just two core operations: XOR (exclusive OR) and bit shifts.

The initial code, used in generating 32-bit numbers, employed uint32_t variables and a series of bitwise manipulations – shifting bits to the left and right, combined with XORing those shifted values—to create a pseudo-random sequence. Essentially, each iteration's output depends on the previous value, along with some carefully chosen shift amounts. Marsaglia's original code included a static variable y initialized to 2463534242 that was manipulated using bitwise operations.

Why it matters

The beauty of xorshift generators lies in their relative simplicity and effectiveness. They provide a surprisingly robust method for creating sequences that mimic the statistical properties of true random numbers, allowing for the generation of diverse and complex worlds within video games like Minecraft.

This technology is a key enabler of procedural content – content automatically generated by an algorithm—which dramatically reduces development time and allows for vastly larger and more varied game environments than would be feasible through manual design.

But, but, but…

While xorshift generators have proven effective in practice, it's crucial to understand their deterministic nature. Because the sequence is entirely determined by a seed value—the starting point—the same seed will always produce the exact same sequence of numbers.

This means that if you were to generate a world using a particular seed, and someone else used the same seed, they would create virtually identical worlds. This isn't necessarily a problem; in fact, it’s deliberate. Minecraft users frequently share seeds to allow others to experience the exact same wondrous landscapes or challenging dungeons. There's also a degree of 'noise' built into the system via carefully chosen constants that make each output slightly different - even given the identical seed. The core caveat lies in the fact that xorshift generators, while impressive, aren’t truly random; they are highly predictable and can be reverse-engineered if the seed is known.

“the first one—the seed—is given, and the rest of the sequence follows from it.”
— Dr Non

The counter-take

the assumption that ‘randomness’ requires true entropy is often incorrect. Clever algorithms, even if deterministic, can convincingly mimic randomness, allowing us to build complex simulations and games without needing truly unpredictable sources of data.

The AI angle

AI increasingly relies on pseudo-random number generation for tasks like music composition and art creation. However, deterministic algorithms like xorshift generators highlight a potential vulnerability: if an AI’s seed is compromised, its output becomes predictable and potentially controllable by an adversary. This asymmetry – where controlled determinism can be exploited – represents a crucial area of development for secure AI systems.