Skip to main content

Production chain calculator for the game Factorio

Project description

factorio-planner ๐Ÿญ

Production chain calculator for Factorio.

Given an item and a target production rate, factorio-planner resolves the full dependency tree and tells you exactly how many machines, furnaces and raw resources you need.

PyPI version Python License: MIT CI


โœจ Features

  • Full dependency resolution โ€” recursively resolves every ingredient down to raw ores/fluids
  • Machine counts โ€” calculates exact (fractional) machines needed per tier
  • Productivity & speed bonuses โ€” model module effects with a single parameter
  • CLI tool โ€” run factorio-planner electronic-circuit --rate 10 directly in your terminal
  • JSON output โ€” machine-readable output for integration with other tools
  • Graph visualisation โ€” render the production chain as a directed graph (optional dep)
  • Extensible recipe DB โ€” load custom/modded recipes from JSON
  • Zero required dependencies โ€” core library needs nothing beyond the Python stdlib

๐Ÿ“ฆ Installation

pip install factorio-planner

With graph visualisation support:

pip install "factorio-planner[graph]"

๐Ÿš€ Quick start

Python API

from factorio_planner import Calculator

calc = Calculator()
plan = calc.compute("electronic-circuit", rate=10)
print(plan.summary())

Output:

Production plan: 10.00 electronic-circuit/s

Machines required:
  assembling-machine-1: 10.0
  stone-furnace: 22.4

Raw resources (per second):
  copper-ore: 15.00/s
  iron-ore: 10.00/s

Full formatted plan with tree

from factorio_planner import Calculator
from factorio_planner.formatter import format_plan

calc = Calculator()
plan = calc.compute("electronic-circuit", rate=10)
print(format_plan(plan))
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
  FACTORIO PRODUCTION PLAN
  Target: 10.00 ร— electronic-circuit / second
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€

Production tree:

electronic-circuit  ร—10.00/s  [ร—5.0 assembling-machine-1]
โ”œโ”€โ”€ iron-plate  ร—10.00/s  [ร—32.0 stone-furnace]
โ”‚   โ””โ”€โ”€ iron-ore  ร—10.00/s  [RAW]
โ””โ”€โ”€ copper-cable  ร—30.00/s  [ร—7.5 assembling-machine-1]
    โ””โ”€โ”€ copper-plate  ร—15.00/s  [ร—48.0 stone-furnace]
        โ””โ”€โ”€ copper-ore  ร—15.00/s  [RAW]
...

With productivity modules

# +40% productivity (research fully upgraded)
calc = Calculator(productivity_bonus=0.4)
plan = calc.compute("advanced-circuit", rate=5)
print(plan.summary())

Visualise the production graph

from factorio_planner import Calculator
from factorio_planner.graph import draw

calc = Calculator()
plan = calc.compute("utility-science-pack", rate=1)
fig = draw(plan)
fig.savefig("production_chain.png", dpi=150)

๐Ÿ–ฅ๏ธ CLI usage

# 10 electronic circuits per second
factorio-planner electronic-circuit --rate 10

# With productivity bonus
factorio-planner advanced-circuit --rate 5 --productivity 0.4

# JSON output (pipe-friendly)
factorio-planner iron-plate --rate 3 --json

# Skip tree, show only totals
factorio-planner utility-science-pack --rate 1 --no-tree

๐Ÿ““ Tutorial notebook

Open In Colab

The notebook walks through every feature step by step, from basic usage to full rocket-launch planning.


๐Ÿ”ง Custom / modded recipes

import json
from factorio_planner import Calculator, RecipeDB
from factorio_planner.models import Recipe

# Option A: add one recipe programmatically
db = RecipeDB()
db.add(Recipe(
    name="my-mod-item",
    ingredients={"iron-plate": 3, "electronic-circuit": 1},
    products={"my-mod-item": 1},
    crafting_time=2.0,
    machine="assembling-machine-2",
))
calc = Calculator(db=db)

# Option B: load from JSON file
db2 = RecipeDB.from_json("my_mod_recipes.json")
calc2 = Calculator(db=db2)

๐Ÿณ Docker

# Run examples inside Docker
docker build -t factorio-planner .
docker run --rm factorio-planner factorio-planner electronic-circuit --rate 10

๐Ÿงช Running tests

pip install "factorio-planner[dev]"
pytest --cov=factorio_planner

๐Ÿ“„ License

MIT โ€” see LICENSE.

factorio-planner is a fan project and is not affiliated with Wube Software.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

factorio_planner-0.1.0.tar.gz (19.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

factorio_planner-0.1.0-py3-none-any.whl (20.1 kB view details)

Uploaded Python 3

File details

Details for the file factorio_planner-0.1.0.tar.gz.

File metadata

  • Download URL: factorio_planner-0.1.0.tar.gz
  • Upload date:
  • Size: 19.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for factorio_planner-0.1.0.tar.gz
Algorithm Hash digest
SHA256 23ed5b385143b37ac79d47ccfc0ea52279dd0d4a5300a5160af2fe2fd0290374
MD5 0fce0fbaeeff0f789725e7fa500403b2
BLAKE2b-256 ff8c9e56e592def2d4f42f737dbf4226e6b6d597a3fcd57922c309201442967e

See more details on using hashes here.

Provenance

The following attestation bundles were made for factorio_planner-0.1.0.tar.gz:

Publisher: publish.yml on BernardRivera13/factorio-planner

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file factorio_planner-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for factorio_planner-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2dc7415464d44231ec2ae2bf51454432cbf88ec5cadacd3aecae30be5d236ec2
MD5 ec95f6673a3651e99681a54825e0aa33
BLAKE2b-256 d2c36d5d7e9810b406d58c9efdcfdd737d99c05a05080e8f0ed028f59bd1b727

See more details on using hashes here.

Provenance

The following attestation bundles were made for factorio_planner-0.1.0-py3-none-any.whl:

Publisher: publish.yml on BernardRivera13/factorio-planner

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page