Reversing Factorio's RNG(gegell.github.io)
251 points by jheitmann 31 days ago | 48 comments
tl;dr: Factorio uses the taus88 PRNG (three XORed LFSRs), which is linear over GF(2) and therefore trivially breakable—observing enough output bits lets you reconstruct the internal state via matrix inversion and predict all future "random" rolls. The author built an in-game implementation using repair pack recyclers as entropy sources (each craft leaks ~2 bits via 50/50 output splits), needing 44 recycling operations to recover the full 88-bit state and predict quality upgrade outcomes. Note: this works in Factorio 2.0 but was broken by RNG changes in 2.1.
HN Discussion:
  • ↑Admiration for the in-game combinator implementation beyond just the RNG cracking
  • ↑Criticism of Factorio's choice of an outdated PRNG and boost's verbose API
  • ↑Games should use CSPRNGs to prevent this class of reverse-engineering exploits
  • •Sharing related examples of RNG cracking in other games like Stardew Valley and Minecraft
  • ↑General appreciation for the article's depth and niche subject matter