• R/O
  • SSH

Repository summary


Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Just a simple, and painful to use calculator for the game Factorio written in Python

Recent Commits RSS

Rev. Time Author Message
5b2a0077e913 2019-10-20 06:06:58 Eric Hopper tip Merge.
5aca86ec5453 2019-10-20 06:06:00 Eric Hopper Pickle database update.
540b2fa05cec 2019-03-30 11:08:48 Eric Hopper Update to 0.17 item database and the XML based format.
0114c5c1cd03 2019-03-30 11:06:38 Eric Hopper Update to preferentially read items.xml as the item datab...
0d7388324768 2018-02-09 14:49:39 Eric Hopper I never use cooked, remove it.
3d95e6a47f05 2018-02-07 01:25:29 Eric Hopper Adjustments for 0.16 times.
e1107f46ab6b 2018-02-06 13:46:18 Eric Hopper Added Grenade, Turret, and Black Science to XML.
a1dab0324be6 2018-02-06 13:43:20 Eric Hopper Begin version controlling the XML version of the database.
20ee3b22eaf7 2018-02-03 05:31:16 Eric Hopper Arrange for XML to be sorted in a predictable order. Thi...
462d2d0e4160 2018-02-03 03:37:30 Eric Hopper Added code to read and parse XML database.

Recently edited Tags

Name Rev. Time Author
tip 5b2a0077e913 2019-10-20 06:06:58 Eric Hopper


Name Rev. Time Author Message
default 5b2a0077e913 2019-10-20 06:06:58 Eric Hopper Merge.


Python Factorio Calculator

This is a simple calculator for the game Factorio. Since I like rational numbers and the ratios in the game are usually best expressed this way, it does all math with fractions from Python's fractions module.

If you're seeing this on GitHub, I'm a Mercurial user, so this is a mirror of the actual repository on bitbucket.

It requires Python 3.6 to work, mostly because I really like f'' strings. I'm also not much of a fancy UI guy, so it just has a bunch of functions that do the kinds of things I need.

The module is designed to be used like this:

>>> from fractions import Fraction as F
>>> import factorio_calc as fc; from factorio calc import item_db as idb
>>> fc.print_factories(
...     fc.factories_for_each(
...         idb['Yellow Science'],
...         F(1,4),
...         raw_materials=(idb['Circuit'],
...                        idb['Copper'],
...                        idb['Plastic'],
...                        idb['Battery'],
...                        idb['Speed Module 1'],
...                        idb['Sulfur'],
...                        idb['Iron'])))
Factories   (as a fraction)   Rate      Name
---------   ---------------   -------   ---------------------
        2               7/4       1/4   Yellow Science
        4              15/4       3/8   Processing unit
        5               9/2       3/4   Adv Circuit
        2             27/16      27/4   Wire
        1              3/80      15/8   Sulfuric Acid
                                  1/8   Battery
                                    9   Circuit
                                  3/2   Plastic
                                 27/8   Copper
                                 3/16   Sulfur
                                 3/80   Iron
                                 15/4   Water
                                  1/8   Speed Module 1

For items specified as raw materials (or for items that have no ingredients) it will simply list the rate at which they must be produced for the given rate. All rates are in items/sec.

I don't print out dependencies because I don't feel it's terribly useful when building a factory. You can look at the dependencies in the game and figure out how to hook things up so that it all works. What you really need for planning is an idea of how many of which kinds of factory you need, and what sorts of supplies you'll need to provide.

For example, in the above build, I have a main bus for the copper, plastic, circuits, water, and iron. The rates required for batteries, sulfur, and speed modules are low enough that I'm comfortable with using the logistics network to fly them in from other places in my factory where they're made. This will yield at least 1 Yellow Science every 4 seconds, and all the fractional factories tell me I will probably get more production out of it. I could use the actual_production function to figure out just how much.