← Wed, Sep 30 digest

Solving Factorio Quality

read article ↗ hn thread ↗

Simon Sapin models Factorio Space Age's quality upcycling loops using transition matrices and Gaussian elimination, building an exact web calculator.

read it A rigorous mathematical breakdown of Factorio's quality production loops that offers both deep theoretical insight and a practical web tool.

summary

The author analyzes the new quality mechanics introduced in Factorio: Space Age, which involve probabilistic tier upgrades and recycling loops. Instead of using iterative approximations or infinite sums, the article frames item upcycling, washing, and asteroid reprocessing as systems of linear equations solved via transition matrices and Gaussian elimination. To implement this without floating-point errors, the author developed an exact rational arithmetic calculator in Rust and TypeScript. The piece concludes with practical throughput ratios for various factory setups and introduces a public web tool for players.

key points

  1. Quality upcycling and recycling loops can be modeled as steady-state linear equations solved exactly via transition matrices and Gaussian elimination.
  2. Using exact rational arithmetic avoids floating-point accumulation errors in multi-step matrix calculations.
  3. The asteroid reprocessing loop yields vastly superior legendary output ratios compared to standard item recycling.

who should read it

Factorio players who enjoy optimization, and engineers interested in practical applications of linear algebra and exact arithmetic.

discussion warm

consensus

Commenters appreciate the rigorous mathematical formulation of a complex game mechanic, with several sharing their own scripts and confirming the author's findings on upcycling efficiency.

pushback

Some discussants note that the prominent space casino strategy analyzed in the post is being removed in the upcoming Factorio 2.1 release because developers felt it made legendary items too easy to obtain.

best comment by scottmsul ↗

Oh boy, this is a rabbit hole I've gone down pretty hard as well. I made a python script and a separate js app for running linear solvers on the upcycling problem. I really like the author's exposition for how to setup the solve matrix, as it's the first step when understanding the quality math.

Speaking very high level, probably the most interesting and counter-intuitive thing I learned from doing these projects is that adding just a touch of speed modules can go a long way, especially at the lower quality levels. Of course, if the only thing being optimized is legendary outputs per common …

It highlights a counter-intuitive practical insight from building these solvers: adding speed modules to upcyclers dramatically improves throughput by relieving expensive machine bottlenecks.

Generated by an LLM from the article and thread. Check the sources before relying on it.