<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/reversing-factorio-s-rng-wq3cvdmbf" -->

---
title: Reversing Factorio's RNG | daily.dev
description: A deep technical breakdown of Factorio's random number generator, showing it uses the taus88 algorithm (three combined linear feedback shift registers). By...
canonical: https://daily.dev/posts/reversing-factorio-s-rng-wq3cvdmbf
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Reversing Factorio's RNG | daily.dev
og:description: A deep technical breakdown of Factorio's random number generator, showing it uses the taus88 algorithm (three combined linear feedback shift registers). By...
og:url: https://daily.dev/posts/reversing-factorio-s-rng-wq3cvdmbf
og:image: https://api.daily.dev/og/posts/wQ3CvdmBf.png
og:image:alt: Reversing Factorio's RNG
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Reversing Factorio's RNG

**[Lobsters](https://daily.dev/sources/lobsters)** · 51 min read · 0 upvotes · 0 comments

## Summary

A deep technical breakdown of Factorio's random number generator, showing it uses the taus88 algorithm (three combined linear feedback shift registers). By decompiling the game binary and analyzing the underlying linear algebra over GF(2), the author shows how observing a handful of RNG outputs lets you invert the transition matrices, reconstruct the internal RNG state, and predict future 'random' quality rolls. The piece walks through LFSR theory, matrix inversion, information-theoretic recipe selection for maximizing observable bits, and an in-game combinator implementation that reads the RNG state, predicts future outputs, and manipulates crafting outcomes purely with game mechanics. A callout notes the in-game exploit breaks in Factorio 2.1 because the RNG usage changed, though the underlying taus88 generator and theory remain valid.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://gegell.github.io/posts/factorio-rng>

## Questions this post answers

### What pseudo-random number generator algorithm does Factorio use internally?

Factorio uses taus88, a combination of three linear feedback shift registers (LFSRs) XORed together, sourced from the Boost.Random library. This was confirmed both by a former Wube developer's forum post and by decompiling the game binary's RandomGenerator::getInt() function using its shipped debug symbols, then verifying bit-level equivalence with sympy.

_Developers curious about game engine internals can follow reverse engineering deep dives like this on daily.dev._

### Why are linear feedback shift register based RNGs considered cryptographically weak?

LFSR-based generators are weak because their output is a linear combination of the internal state bits over the field GF(2), meaning the entire internal state can be reconstructed from a small number of observed outputs by solving a system of linear equations. For a 32-bit taus88 LFSR triplet, only three consecutive full outputs are needed to recover the complete state and predict all future values.

_Anyone evaluating PRNG choices for security or game design can dig into weaknesses like this via daily.dev._

### Does Factorio 2.1 break RNG manipulation techniques that worked in Factorio 2.0?

Yes, Factorio 2.1 changes how the RNG is used internally, which breaks in-game implementations built for version 2.0 that relied on observing and predicting RNG calls through crafting mechanics. The underlying taus88 generator itself is unchanged, so the theoretical state-reconstruction approach still applies, but the specific in-game exploit no longer functions as built.

_Track version-specific breakage like this for games and tools you depend on with daily.dev._

## Community take

How the wider developer community reacted, aggregated from 2 discussions and 82 comments across lobsters, hackernews (as of 2026-09-17).

**TL;DR:** The write-up is widely praised as an impressive, deeply geeky reverse-engineering effort, with commenters swapping similar stories of predictable RNGs in other games and digging into the C++ template mechanics used to implement taus88.

**Sentiment:** 78% positive · 18% mixed · 4% skeptical

**The case for**

- Many found the two-year effort and in-game combinator implementation genuinely impressive and well explained.
- Several shared analogous RNG-cracking stories from other games (Stardew Valley, Doom, EverQuest, online poker) as related real-world precedent.
- Some appreciated the discussion of how template-heavy Boost code compiles down to the same efficient assembly shown in the decompilation.

**The pushback**

- A few questioned why taus88, an older 1996-era generator, was chosen when faster/better modern PRNGs exist in Boost now.
- Some found the heavy use of C++ templates for the RNG implementation needlessly ugly or hard to follow.

**By community**

- lobsters (mixed): No substantive comments were provided, so no real discussion signal exists here.
- hackernews (positive): Overwhelmingly admiring of the technical depth and effort, with tangents into similar RNG-cracking stories and C++ template design debates.

**Hottest debate:** Whether using deeply nested C++ templates (as in Boost's taus88 implementation) is elegant compile-time engineering or needless complexity versus plain C.

**Open questions**

- Whether the RNG-prediction technique could be adapted to work in Factorio 2.1 given the changed RNG usage.
- Whether similar seed-cracking approaches used in other games (like Stardew Valley's Switch version) could be fully automated the way this Factorio exploit was.

**Highlights**

> Yeah, no notes. It's remarkable. TL;DR: Wired up an in-game predictor of RNG output and used it to only craft legendary items when RNG would line up to roll legendary. From base to legendary at a suprisingly high rate. Look very closely at the video at the top of the post - what I was seeing didn't sink in until I had finished the article. Amazing.
> — [jvanderbot on hackernews](https://news.ycombinator.com/item?id=49732518)

> by far the blackest magic I ever saw for that game. I'm an upper intermediate at Factorio, resorting to someone else's blueprints only for belt balancers and rail intersections, and I can't even begin to figure out how it's done.
> — [vlyan on hackernews](https://news.ycombinator.com/item?id=49733720)

> > We chose taus88 mainly because it is the fastest from boost’s generators. That's an RNG from 1996. It seems neither recent C++ standards, nor boost, know anything about the modern PRNGs that are much faster yet better at passing test suites EDIT: Ok the above quote was from 2014, and boost seems to know some now! https://www.boost.org/doc/libs/latest/doc/html/boost_random/...
> — [Aardwolf on hackernews](https://news.ycombinator.com/item?id=49733807)

> At the conclusion, he said he spent two years on this! That's a thesis.
> — [3eb7988a1663 on hackernews](https://news.ycombinator.com/item?id=49735112)

> The coolest part of this for me is that it's not only reverse engineering the RNG and being able to predict random rolls, which is relatively simple for that PRNG algorithm, but then being able to implement that algorithm in-game using combinator networks. There are already a lot of amazing things that you can do with combinators and this is a great example to add to the list.
> — [renyicircle on hackernews](https://news.ycombinator.com/item?id=49739314)

**Source threads**

- [lobsters](https://lobste.rs/s/phbfog/reversing_factorio_s_rng) · 1 points · 0 comments
- [hackernews](https://news.ycombinator.com/item?id=49674451) · 224 points · 82 comments

## Similar posts on daily.dev

- [This \(Pseudo\) Random Number Generator Does It With Neon](https://daily.dev/posts/this-pseudo-random-number-generator-does-it-with-neon-zyrc6p4gw) · Hackaday · 0 upvotes · 0 comments
- [Correlated randomness in Slay the Spire 2](https://daily.dev/posts/correlated-randomness-in-slay-the-spire-2-8tnfr0vgp) · Lobsters · 0 upvotes · 0 comments
- [This is how the RNG works as an 'equalizer' in Dispatch](https://daily.dev/posts/this-is-how-the-rng-works-as-an-equalizer-in-dispatch-e9io08wla) · Game Developer · 0 upvotes · 0 comments
- [Certifiably random: Swiss researchers claim perfect random number source](https://daily.dev/posts/certifiably-random-swiss-researchers-claim-perfect-random-number-source-t6hhqkb2o) · CSO Online · 0 upvotes · 0 comments

---

Tags: [#cryptography](https://daily.dev/tags/cryptography), [#math](https://daily.dev/tags/math), [#reverse-engineering](https://daily.dev/tags/reverse-engineering)

[View this post on daily.dev](https://daily.dev/posts/reversing-factorio-s-rng-wq3cvdmbf)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Reversing Factorio's RNG","url":"https://daily.dev/posts/reversing-factorio-s-rng-wq3cvdmbf","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/reversing-factorio-s-rng-wq3cvdmbf"},"datePublished":"2026-09-17T12:49:29.128Z","dateModified":"2026-09-17T12:51:41.257Z","description":"A deep technical breakdown of Factorio's random number generator, showing it uses the taus88 algorithm (three combined linear feedback shift registers). By...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/4f71322c85963813ba4877751a41c9ab?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/4f71322c85963813ba4877751a41c9ab?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Lobsters","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Lobsters","logo":"https://media.daily.dev/image/upload/s--tl8v_Fku--/f_auto,t_logo/v1698841318/logos/lobste.jpg","url":"https://daily.dev/sources/lobsters"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/reversing-factorio-s-rng-wq3cvdmbf","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"cryptography,math,reverse-engineering","timeRequired":"PT51M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Lobsters","item":"https://daily.dev/sources/lobsters"},{"@type":"ListItem","position":3,"name":"Reversing Factorio's RNG"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/reversing-factorio-s-rng-wq3cvdmbf#faq","mainEntity":[{"@type":"Question","name":"What pseudo-random number generator algorithm does Factorio use internally?","acceptedAnswer":{"@type":"Answer","text":"Factorio uses taus88, a combination of three linear feedback shift registers (LFSRs) XORed together, sourced from the Boost.Random library. This was confirmed both by a former Wube developer's forum post and by decompiling the game binary's RandomGenerator::getInt() function using its shipped debug symbols, then verifying bit-level equivalence with sympy. Developers curious about game engine internals can follow reverse engineering deep dives like this on daily.dev."}},{"@type":"Question","name":"Why are linear feedback shift register based RNGs considered cryptographically weak?","acceptedAnswer":{"@type":"Answer","text":"LFSR-based generators are weak because their output is a linear combination of the internal state bits over the field GF(2), meaning the entire internal state can be reconstructed from a small number of observed outputs by solving a system of linear equations. For a 32-bit taus88 LFSR triplet, only three consecutive full outputs are needed to recover the complete state and predict all future values. Anyone evaluating PRNG choices for security or game design can dig into weaknesses like this via daily.dev."}},{"@type":"Question","name":"Does Factorio 2.1 break RNG manipulation techniques that worked in Factorio 2.0?","acceptedAnswer":{"@type":"Answer","text":"Yes, Factorio 2.1 changes how the RNG is used internally, which breaks in-game implementations built for version 2.0 that relied on observing and predicting RNG calls through crafting mechanics. The underlying taus88 generator itself is unchanged, so the theoretical state-reconstruction approach still applies, but the specific in-game exploit no longer functions as built. Track version-specific breakage like this for games and tools you depend on with daily.dev."}}]}
```

