r/technicalfactorio • • 18h ago

A LaTeX package that draws belt balancers from blueprint strings, and checks whether they balance

Thumbnail
gallery
218 Upvotes

I've been writing notes about belt balancers and got tired of pasting screenshots into them, so I wrote **beltmap**, a LuaLaTeX package that draws belt layouts. You give it a blueprint string and it draws the belts, splitters, and undergrounds as a diagram.

What it reads:

- blueprint strings and blueprint books, from 1.1 and 2.0 (direction numbering, splitter priorities, filters with quality);

- Factorio-SAT output;

- a layout typed as text, like `> S> >`, for a quick sketch in a document.

What it does with them:

- **Balance check.** `mix=bands` stripes every belt by how much of each input it carries. The shares are exact fractions, and the verdict under each picture, computed from the amounts each output carries, says whether the layout balances, and if not, which output gets too much of which input. The colors and stripes only illustrate it: from 5 inputs up, an unbalanced mix can blend to exactly the same gray.

- **Throughput check.** It tries every choice of open inputs and outputs and looks for a bottleneck (a max-flow test). This can prove a layout is limited, but passing it doesn't prove the layout is throughput unlimited, because splitters don't route along a max flow.

- **Splitter graph.** `view=graph` redraws the layout as a network of splitters.

- **Blueprints back out.** Every picture gives you the blueprint string of what it drew, and can attach it to the PDF. I tested 53 strings in Factorio 2.1.24: the game imported them, built them, and read every entity back, and its exports read back the same.

- **Animations.** A script exports PNG, SVG, or a GIF of the flow, which is where most of these pictures came from.

Limits: LuaLaTeX only (the glyphs alone work with any engine). Only belts, undergrounds, and splitters are drawn; anything else in a blueprint is skipped. Side-loading onto undergrounds is handled like side-loading onto a belt, which I haven't checked against the game.

It's on CTAN as of this week, so it should show up in TeX Live and MiKTeX soon. The manual has every picture above and the keys that make them.

- CTAN: https://ctan.org/pkg/beltmap

- GitHub (bugs and requests welcome): https://github.com/landonfox00/beltmap

Right now I'm trying to get the splitter graphs to render more nicely and maybe add game icons. Any and all feedback is very appreciated!