Reversing Factorio's RNG
4 days ago
- Factorio uses the taus88 PRNG, a combination of three linear feedback shift registers (LFSRs), which is deterministic and can be reversed.
- By observing RNG outputs (e.g., from recycling repair packs which yield one bit per result), the internal state can be recovered using linear algebra over GF(2).
- The in-game system predicts future random calls, particularly quality rolls, and manipulates crafting to obtain legendary items by skipping undesirable calls.
- Implementation steps include sampling the RNG, computing state with precomputed matrices, predicting future states, and skipping calls using scrap recycling.
- Limitations include multiple RNGs in the game, interference from other random events (e.g., biter movement, particles), and changes in Factorio 2.1 that break the method.
- The project is a proof-of-concept; practical use in a live save is challenging due to uncontrolled RNG calls from other game mechanics.