A python module to help you plan your factory for Factorio.
Project description
FactorioCalc is a Python module to help you symbolically plan your factory for Factorio.
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, the author, find designing my factory symbolically more natural than using a spreadsheet and tools like FactorioLab.
Read the docs at https://factoriocalc.readthedocs.io/en/stable/
Examples
>>> from factoriocalc import itm, rcp, mch, presets, config, produce
Create a simple factory that creates electronic circuits from copper and iron plates:
>>> config.machinePrefs.set(presets.MP_LATE_GAME) >>> circuits = 2*rcp.electronic_circuit() + 3*rcp.copper_cable() >>> circuits.summary() 2x electronic_circuit: AssemblingMachine3: electronic_circuit 5/s, iron_plate -5/s, copper_cable -15/s, electricity -0.775 MW 3x copper_cable: AssemblingMachine3: copper_cable 15/s, copper_plate -7.5/s, electricity -1.1625 MW >>> circuits.flows().print() electronic_circuit 5/s copper_cable 0/s (15/s - 15/s) iron_plate -5/s copper_plate -7.5/s electricity -1.9375 MW
Use produce to create a factory that produces rocket fuel:
>>> config.machinePrefs.set(presets.MP_MAX_PROD().withBeacons(presets.SPEED_BEACON, {mch.AssemblingMachine3:8, mch.ChemicalPlant:8, mch.OilRefinery:12})) >>> rocketFuel = produce([itm.rocket_fuel@6], using=[rcp.advanced_oil_processing]).factory >>> rocketFuel.summary() b-rocket-fuel: 23.4x rocket_fuel: AssemblingMachine3 +340% speed +40% prod. +880% energy +40% pollution 9.84x solid_fuel_from_light_oil: ChemicalPlant +355% speed +30% prod. +800% energy +30% pollution 4.65x solid_fuel_from_petroleum_gas: ChemicalPlant +355% speed +30% prod. +800% energy +30% pollution 2.26x advanced_oil_processing: OilRefinery +555% speed +30% prod. +1080% energy +30% pollution 1.06x heavy_oil_cracking: ChemicalPlant +355% speed +30% prod. +800% energy +30% pollution Outputs: rocket_fuel 6/s Inputs: water -220.004/s, crude_oil -295.803/s
Installation
FactorioCalc is available on PyPI so you can install it using pip:
pip3 install factoriocalc
Status
FactorioCalc has been used by the author to help produce a factory that produces around 2k science packs per minute, beat Space Exploration, beat Krastorio 2, and create a Krastorio 2 factory that produces 3k science packs per minute. The calculations, in terms of the rate of items produced and consumed, should be accurate (which includes tricky cases such as the Kovarex enrichment process). The solver, in nearly all cases, should produce optimal results in terms of materials used. The API is subject to change but the core functionality should be stable.
Possible Bugs
FactorioCalc uses a custom simplex solver written in pure python. The solver has no provisions to prevent cycling, so calls to solve could theoretical loop and need to be killed with control-c; however, so far this has not happened.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file factoriocalc-0.2.1.tar.gz
.
File metadata
- Download URL: factoriocalc-0.2.1.tar.gz
- Upload date:
- Size: 1.4 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cda0b94374ed40bc4da1ed3b1e89c983999d75a1018ddb33c81321471cd832de |
|
MD5 | 35e08daf9b3fd1604d403d492ad55ee6 |
|
BLAKE2b-256 | a538dd60b90b25cdef17b2ec715e1a4a99d840b553aab669372b16fcad9877cc |
File details
Details for the file factoriocalc-0.2.1-py3-none-any.whl
.
File metadata
- Download URL: factoriocalc-0.2.1-py3-none-any.whl
- Upload date:
- Size: 120.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1fd549729a3e0bd7cd8a8f1a60b216ad1c425e8c235a3a7dfd53781245b4726d |
|
MD5 | 0ce418df9fd5ead96ab717abc1709eba |
|
BLAKE2b-256 | 01e638af69cc4f07566cc46f797f0f42fb8516534438bc1160f7197b939fbc8c |