Coder Social home page Coder Social logo

factoriocalc's Introduction

FactorioCalc Readme

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. It has also been used to help beat both Space Exploration and Krastorio 2. 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.

factoriocalc's People

Contributors

kevina avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.