The butterfly effect
By Robin Dowling ยท 18 days ago
A harmless-looking function was quietly rolling dice. It was only used for stats, but every time it was called it nudged the organism's random number stream. After 27,000 ticks, one extra organism survived. That tiny change was enough to unravel the whole world.
The hidden side effect
Each organism has an objective, basically what it wants to do next. Eat, reproduce, rest etc. On paper, it's a simple check: look at the organism's energy and state, then answer.
But buried inside it was a hidden randomness roll. The function called the reproduction check, and that check advanced the organism's random generator. The result was only used to decide whether to log something as REPRODUCE or REST. It seemed harmless, but it wasn't. Every call used up a random number, and those numbers shape the future.
The drift
This function was called by the stats system, which runs on an interval. Most of the time, that extra roll never mattered. But one skipped draw changes the sequence for everything that follows. The organism picks a different direction, takes a different action, or reproduces at a different moment.
For a long time, nothing obvious happened. The differences were small. A little path change here, a tiny outcome change there. The world looked stable.
Then, around tick 27,300, a single animal survived when it should have died. That one extra life was enough to change the local balance. Its neighbors got less food. One failed to reproduce. A gap stayed empty. Another animal went hungry and wandered elsewhere. The ripple kept spreading.

The collapse
Nothing dramatic happened at first. The simulation still looked natural. But the small differences accumulated. Population mixes shifted. Species that had been in balance started pulling apart. The system had been stable for a long time, but only because every random choice happened in the same order. Once that order drifted, the whole world began to move away from its old equilibrium.
The fix was simple: split the pure "can this organism reproduce?" question from the randomness that decides whether reproduction actually happens. The stats code should not touch the random stream at all.
The deeper lesson is simple: if a function is named like a question, it should not secretly change the answer.