• R/O
  • SSH

ソースツリー

タグ

よく使われているワード(クリックで追加)

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


名前 サイズ Rev. 日時 作者 ログメッセージ
.hgignore 36 f0447abbcf09 2017-10-03 12:43:45 Eric Hopper <hopper@omnifarious.org> Ignore various Python and emacs dropp...
README.md 3.11 k e1e9d8116ea8 2017-08-10 07:49:29 Eric Hopper <hopper@omnifarious.org> Fix example to no longer have very lo...
factorio_calc.py 11.15 k 5b2a0077e913 2019-10-20 06:06:58 Eric Hopper <hopper@omnifarious.org> Merge.
item-db-0.16.pickle 4.21 k 5b2a0077e913 2019-10-20 06:06:58 Eric Hopper <hopper@omnifarious.org> Merge.
items-0.16.xml 10.74 k 540b2fa05cec 2019-03-30 11:08:48 Eric Hopper <hopper@omnifarious.org> Update to 0.17 item database and the ...
items.xml 12.27 k 540b2fa05cec 2019-03-30 11:08:48 Eric Hopper <hopper@omnifarious.org> Update to 0.17 item database and the ...

README.md

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.