FactorioCalc: a Python module to help you symbolically plan your factory

Calculate optimal ratios for feeding recipes, search through the research-tree, specialized tools to view game-information.
Post Reply
kevina
Manual Inserter
Manual Inserter
Posts: 3
Joined: Tue Jan 09, 2024 11:28 pm
Contact:

FactorioCalc: a Python module to help you symbolically plan your factory

Post by kevina »

When I first started playing Factorio one of the first things wanted to do was express my factories symbolically. For example something like: "2 electronic-circuit() + 3 copper-cable()" (for 2 assembling-machine-3 producing electronic circuits and 3 producing copper cables) and then simply query the object created to find out what it consumes and produces.

I looked, but couldn't find anything close to what I wanted, so I wrote a Python package to that effect. About a year ago, I released the first version and posted on reddit without it getting much attention. It has been under continuous development since then and now version 0.2.0 is available.

With FactorioCalc you can:
  • Symbolically express your exact machine configuration and ask it what the resulting inputs and outputs is.
  • Import a blueprint and determine what it produces.
  • Specify the recipes you want to use and let FactorioCalc determine the exact number of machines needed.
  • Specify what you want, and let FactorioCalc determine both the recipes and the number of machines required.
  • Combine factories, which were created using any of the above methods, to create a larger factory.
FactorioCalc has supports for using custom recipe data and mods. The companion mod, Recipe Exporter, provides the recipe data.

FactorioCalc contains a custom simplex solver so it can easily handle complex cases that involve recipes with more than one output, such as oil and uranium processing.

I have used FactorioCalc to help produce a factory that produces around 2k science packs per minute, and with Space Exploration and Krastorio 2.

I personally find FactorioCalc a better way to plan my factory than using FactorioLab and perhaps a spreadsheet. I also find it more flexible than in game tools such as "Factory Planner" or "Helmod". That being said I realize I have a tendency to go about things in a unique way, so I am really interested if anyone other than me finds this useful.

If this sounds like something you are interested in please check out the documentation at and try it out. You can find it on PyPI (https://pypi.org/project/factoriocalc/) and GitHub (https://github.com/FactorioCalc/FactorioCalc). The overview section of the documentation is available as Jupyter notebook that you can use in your browser.

User avatar
BrainGamer_
Inserter
Inserter
Posts: 46
Joined: Sun Nov 14, 2021 9:52 pm
Contact:

Re: FactorioCalc: a Python module to help you symbolically plan your factory

Post by BrainGamer_ »

kevina wrote:
Wed Jan 10, 2024 3:49 am
The companion mod, Recipe Exporter, provides the recipe data.
I guess this didn't exist 2 years ago yet but now you can use the --dump-data CLI arg to get factorio to dump the entire data.raw table as a JSON file (with some quirks) and use that to get recipes, items, etc instead of a custom companion mod :)
kevina wrote:
Wed Jan 10, 2024 3:49 am
Import a blueprint and determine what it produces.
Does this just count machines and their recipes or actually detect belts, pipes, inserters, etc to determine what feeds into what (with certain bottlenecks)?

kevina
Manual Inserter
Manual Inserter
Posts: 3
Joined: Tue Jan 09, 2024 11:28 pm
Contact:

Re: FactorioCalc: a Python module to help you symbolically plan your factory

Post by kevina »

BrainGamer_ wrote:
Wed Jan 10, 2024 10:48 am
I guess this didn't exist 2 years ago yet but now you can use the --dump-data CLI arg to get factorio to dump the entire data.raw table as a JSON file (with some quirks) and use that to get recipes, items, etc instead of a custom companion mod :)
Thanks for the tip. I was not aware of that option; it looks it it was added in March of 2023. It might of saved me a little bit of trouble; however, my mod exports the data via a console command so it is also to determine if a recipe is enabled or not.
BrainGamer_ wrote:
Wed Jan 10, 2024 10:48 am
kevina wrote:
Wed Jan 10, 2024 3:49 am
Import a blueprint and determine what it produces.
Does this just count machines and their recipes or actually detect belts, pipes, inserters, etc to determine what feeds into what (with certain bottlenecks)?
At the moment it just counts. A more detailed analysis that determines what feeds into what is something I have thought about, but not yet implemented.

kevina
Manual Inserter
Manual Inserter
Posts: 3
Joined: Tue Jan 09, 2024 11:28 pm
Contact:

Re: FactorioCalc: a Python module to help you symbolically plan your factory

Post by kevina »

kevina wrote:
Wed Jan 10, 2024 6:01 pm
At the moment it just counts.
To expand on "just counts": FactorioCalc can be used to do more than just compute maximum rates. For example, if you analyses a blueprint for space science that includes the satellite, it can take into account that the assembling machine producing the satellite is idle most of the time. By taking this into account, FactorioCalc can give you a better idea of the resources used than in-game tools such as Rate Calculator or Max Rate Calculator. A full analysis to determine what feeds into what would certainly be more useful, though a lot more complicated.

Post Reply

Return to “Cheatsheets / Calculators / Viewers”