Skip to main content

factory-sim

A tick-exact simulator of Factorio's early game, written in C with a Python API. It is about 3,600× faster than the real game, so agents can train in it and be tested on the real game afterwards.

pip install factory-sim

Prebuilt wheels for Python 3.11–3.13 on Linux, Windows and macOS.

What it simulates

  • A character that walks, reaches, hand-mines and carries an inventory
  • Burner mining drills, stone furnaces and fuel
  • Transport belts, burner inserters and wooden chests
  • Items on the ground, walls and water

Every rule and number was measured in Factorio 2.0.60. The simulator is checked against traces recorded from the real game, at every decision and, for belts and inserters, at every tick. The measurements live in FactorioGym, which drives the real game through a mod.

Scope

"Tick-exact" applies to the mechanics listed above, not to Factorio as a whole. The simulator is a work in progress: more of the game (electricity, assemblers and beyond) is being measured and added.

Known exceptions within that scope:

  • A few floating-point values are compared to within 1e-12, because the game prints some of them with an imprecise last digit.
  • Ore under a drill is compared as a total over its four tiles. The order a drill mines its tiles follows the engine's internal entity order, which could not be reduced to a rule.
  • Loading a mid-episode state that would need the engine's belt update order (which the game does not expose) raises an error instead of guessing.

Quick start

import gymnasium as gym
import fsim.gym_env  # registers the environments

env = gym.make("fsim/BuildLine-v0", split="test")
obs, info = env.reset(seed=0)
obs, reward, terminated, truncated, info = env.step(env.action_space.sample())

Install the Gymnasium extra with pip install factory-sim[gym]. Prime Intellect's Environments Hub (verifiers), OpenEnv and PufferLib are also supported; see docs/interfaces.md.

Speed

Decisions per second
Real game, 8 workers ~260
factory-sim, 16 threads ~950,000
factory-sim, full RL path (observations, masks, rewards), 8 threads ~530,000

A 40-million-decision PPO run takes about two days of nonstop play in the real game and a couple of hours here.

Tasks

Task Goal
construct_smelting_line Find an ore patch, place a drill and a furnace, fuel both, and make 10 iron plates
build_line Build a drill-and-furnace line that keeps running after construction
plate_line Fuel the right machines in a line that is already built
belt_smelting Walk between an iron patch, a coal patch and a chest, and build drills, furnaces, belts and inserters that deliver 150 plates to the chest

Each task has training layouts and held-out layouts. A seed produces the same scene here and in the real game.

Results

Agents trained or searched in the simulator, then run on held-out layouts:

Method Task Simulator Real game
PPO construct_smelting_line 92.0% 90.6%
PPO build_line 99.2% 90.6%
Evolved programs construct_smelting_line 99.6% 99.3%
Qwen3.5-9B, Evolve & Reinforce construct_smelting_line 71.9% not yet run

The Qwen3.5-9B model was trained with GRPO on the factorio-build environment. Its general planning stays close to the base model's (PlanBench Blocksworld 46.4 vs 53.2). Models are in the collection on Hugging Face.

What's in the repo

Path Contents
fsim/ The Python API, environments and scene generators
csrc/ The C simulator
train.py Masked PPO in one file
evolve/ LLM-guided search over def build(world): programs
integrations/verifiers/ The factorio-build and factorio-play environments for the Prime Environments Hub
recipes/grpo-factorio-build/ SFT and GRPO recipe for Qwen3.5 with prime-rl

Build from source

uv sync                        # builds the C extension
uv run pytest                  # includes parity tests against the real game
uv run python bench/bench.py   # throughput

Citing

@software{agrawal2026factorysim,
  author  = {Agrawal, Divyansh},
  title   = {{factory-sim}: a fast, tick-exact simulator of an early-game factory},
  year    = {2026},
  version = {0.3.0},
  url     = {https://github.com/divagr18/factory-sim}
}

License

Apache-2.0. Factorio is a game and trademark of Wube Software Ltd. This project is independent, not affiliated with or endorsed by Wube, and contains no game code or assets. See NOTICE.

Metadata

Release files for factory-sim 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for factory-sim 0.3.0
File Size Uploaded Provenance Actions
factory_sim-0.3.0.tar.gz 714.7 kB With provenance Details for factory_sim-0.3.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for factory-sim 0.3.0
File Actions
factory_sim-0.3.0-cp313-cp313-win_amd64.whl CPython 3.13 CPython 3.13 Windows x86-64 Details for factory_sim-0.3.0-cp313-cp313-win_amd64.whl
factory_sim-0.3.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.28+ x86-64, Linux glibc 2.17+ x86-64 Details for factory_sim-0.3.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl
factory_sim-0.3.0-cp313-cp313-macosx_11_0_arm64.whl CPython 3.13 CPython 3.13 macOS 11.0+ ARM64 Details for factory_sim-0.3.0-cp313-cp313-macosx_11_0_arm64.whl
factory_sim-0.3.0-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details for factory_sim-0.3.0-cp312-cp312-win_amd64.whl
factory_sim-0.3.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.28+ x86-64, Linux glibc 2.17+ x86-64 Details for factory_sim-0.3.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl
factory_sim-0.3.0-cp312-cp312-macosx_11_0_arm64.whl CPython 3.12 CPython 3.12 macOS 11.0+ ARM64 Details for factory_sim-0.3.0-cp312-cp312-macosx_11_0_arm64.whl
factory_sim-0.3.0-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details for factory_sim-0.3.0-cp311-cp311-win_amd64.whl
factory_sim-0.3.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.17+ x86-64, Linux glibc 2.28+ x86-64 Details for factory_sim-0.3.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl
factory_sim-0.3.0-cp311-cp311-macosx_11_0_arm64.whl CPython 3.11 CPython 3.11 macOS 11.0+ ARM64 Details for factory_sim-0.3.0-cp311-cp311-macosx_11_0_arm64.whl

Total release size: 6.7 MB

Release files / factory_sim-0.3.0.tar.gz

Download URL factory_sim-0.3.0.tar.gz
Size 714.7 kB
Tags Source
SHA-256 checksum
How to use checksums
7b3540c891f641e7bd1e505046d03f3da3e43b4e47c4a9abd768751ab76befad
BLAKE2b-256 checksum
How to use checksums
0f02f6081b88487fe9a55c358a1c59af9db2cce4cbd7d9535f440315e2a07934
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 1, 2026.

Transparency log

Release files / factory_sim-0.3.0-cp313-cp313-win_amd64.whl

Download URL factory_sim-0.3.0-cp313-cp313-win_amd64.whl
Size 586.8 kB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
da202754db5ab527a8ffa315ca0f7eb04f2041f5e74ed7f81da765ba8ff0bfba
BLAKE2b-256 checksum
How to use checksums
2ac4ff9eb0b1917cac03efb9e8a039d9e7de4c38d8fb5ee5bad2899a83bdc02a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 1, 2026.

Transparency log

Release files / factory_sim-0.3.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl

Download URL factory_sim-0.3.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl
Size 809.5 kB
Tags CPython 3.13 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
b72599f0d1a98b86c619139e86ac3504ace09687833e739d589aeec6be26f7aa
BLAKE2b-256 checksum
How to use checksums
e97fc8c3fa8dd38d22309a41da266db69b3a8f6864ed06435f912968fe9f7d7e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 1, 2026.

Transparency log

Release files / factory_sim-0.3.0-cp313-cp313-macosx_11_0_arm64.whl

Download URL factory_sim-0.3.0-cp313-cp313-macosx_11_0_arm64.whl
Size 604.0 kB
Tags CPython 3.13 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
c976b4cf056f8ba7b3eea766c857474a72d9b33be39d3a8c184d1101ff4ff95b
BLAKE2b-256 checksum
How to use checksums
1c548d00366c4ca10cc6d89895fdef649d29158d509c215d85e32abfec874dab
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 1, 2026.

Transparency log

Release files / factory_sim-0.3.0-cp312-cp312-win_amd64.whl

Download URL factory_sim-0.3.0-cp312-cp312-win_amd64.whl
Size 586.8 kB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
a199a7aeebe92b0535bcd77fcc5fb08e9000f3c8710307f0d9cdb9f8c2f51ea1
BLAKE2b-256 checksum
How to use checksums
692331b09946d9bc67402b920b99fc2ff77646994323158165f62ebf789fae97
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 1, 2026.

Transparency log

Release files / factory_sim-0.3.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl

Download URL factory_sim-0.3.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl
Size 809.6 kB
Tags CPython 3.12 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
f0ec8d1f792572f2ac61708f8807fbc8b4711915dc4159db50f87faae68b6d26
BLAKE2b-256 checksum
How to use checksums
39b01784bb567e77aa841b6b131a1c509baf92178de4bd8164195530872911ac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 1, 2026.

Transparency log

Release files / factory_sim-0.3.0-cp312-cp312-macosx_11_0_arm64.whl

Download URL factory_sim-0.3.0-cp312-cp312-macosx_11_0_arm64.whl
Size 604.0 kB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
c19aede048658a30e094c4dba54bb3032f89d5755e9cb09b4ce6f9d516e81256
BLAKE2b-256 checksum
How to use checksums
7650335fcaf077cda935fbfa1098bca3fd0770621ea0a40390349aba13403a37
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 1, 2026.

Transparency log

Release files / factory_sim-0.3.0-cp311-cp311-win_amd64.whl

Download URL factory_sim-0.3.0-cp311-cp311-win_amd64.whl
Size 586.8 kB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
bdf1fbaa0d78a28ad1e47eb6bf60c59958788b2139b236a53aee3a5b98f1fd9f
BLAKE2b-256 checksum
How to use checksums
e60bee4ea7d8ce2a461a095a8bed2939131f936902eb1967eb9889ec563c6a43
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 1, 2026.

Transparency log

Release files / factory_sim-0.3.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl

Download URL factory_sim-0.3.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl
Size 808.6 kB
Tags CPython 3.11 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
987dd54a1a6ac7cde947e10b9adcf649db1662a6f0b736054b40fb37020d7ecb
BLAKE2b-256 checksum
How to use checksums
cfb7cface0116585975c3d4a329a8d0fcfaa92f97c881f131e566d7595f8e44d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 1, 2026.

Transparency log

Release files / factory_sim-0.3.0-cp311-cp311-macosx_11_0_arm64.whl

Download URL factory_sim-0.3.0-cp311-cp311-macosx_11_0_arm64.whl
Size 603.9 kB
Tags CPython 3.11 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
a8f7ad1334a46c226efa6e5115c8f849d07a88eda8ffe2c104ff52392fdeddb9
BLAKE2b-256 checksum
How to use checksums
b33bf788119f9c71fe30df01cbe5d8c42222a4860cee43d12dc12fb6792fe30a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 1, 2026.

Transparency log

Security for factory-sim 0.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 10 files in this release have been uploaded with provenance metadata.

Select from 10 files

Attestation for factory_sim-0.3.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 1, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page