Hacker News front page61 min readintermediate
Reversing Factorio's RNG
Summary
The author reverse‑engineers Factorio’s RNG, confirms it’s the Boost taus88 generator (a 3‑LFSR XOR combo), proves equivalence with the game’s compiled code via decompilation and symbolic Python checks, and explains how the weak LFSR structure lets you predict future “random” quality outcomes.
- Factorio uses Boost’s `taus88` PRNG (three 32‑bit LFSRs XORed together).
- Decompiling the game binary (via Ghidra/Binary Ninja) shows the same three‑seed state and equivalent update logic after compiler optimizations.
- A Python/Sympy notebook demonstrates step‑by‑step equivalence between the Boost implementation and the decompiled code.
- Because LFSRs are linear over GF(2), the combined generator is trivially breakable: given a few outputs you can reconstruct the internal state and predict all future RNG calls.
Predicting the RNG lets players deterministically obtain high‑quality items in Factorio, turning a probabilistic mechanic into a guaranteed outcome. The work also showcases a practical workflow for verifying PRNG implementations in closed‑source games.
6/10

