Just a simple, and painful to use calculator for the game Factorio written in Python
修订版 | 5613f81605a919afb8b369dd513e14c74ac13668 (tree) |
---|---|
时间 | 2017-08-09 04:22:27 |
作者 | Eric Hopper <hopper@omni...> |
Commiter | Eric Hopper |
Add a README file for repositories to show to people to explain.
@@ -0,0 +1,52 @@ | ||
1 | +# Python Factorio Calculator # | |
2 | + | |
3 | +This is a simple calculator for the game [Factorio][Factorio]. Since I | |
4 | +like rational numbers and the ratios in the game are usually best | |
5 | +expressed this way, it does all math with fractions from Python's | |
6 | +fractions module. | |
7 | + | |
8 | +It requires Python 3.6 to work, mostly because I really like `f''` | |
9 | +strings. I'm also not much of a fancy UI guy, so it just has a bunch of | |
10 | +functions that do the kinds of things I need. | |
11 | + | |
12 | +The module is designed to be used like this: | |
13 | + | |
14 | + >>> from fractions import Fraction as F | |
15 | + >>> import factorio_calc as fc; from factorio calc import item_db as idb | |
16 | + >>> 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']))) | |
17 | + Factories (as a fraction) Rate Name | |
18 | + --------- --------------- ------- --------------------- | |
19 | + 2 7/4 1/4 Yellow Science | |
20 | + 4 15/4 3/8 Processing unit | |
21 | + 5 9/2 3/4 Adv Circuit | |
22 | + 2 27/16 27/4 Wire | |
23 | + 1 3/80 15/8 Sulfuric Acid | |
24 | + 1/8 Battery | |
25 | + 9 Circuit | |
26 | + 3/2 Plastic | |
27 | + 27/8 Copper | |
28 | + 3/16 Sulfur | |
29 | + 3/80 Iron | |
30 | + 15/4 Water | |
31 | + 1/8 Speed Module 1 | |
32 | + | |
33 | +For items specified as raw materials (or for items that have no | |
34 | +ingredients) it will simply list the rate at which they must be produced | |
35 | +for the given rate. All rates are in items/sec. | |
36 | + | |
37 | +I don't print out dependencies because I don't feel it's terribly useful | |
38 | +when building a factory. You can look at the dependencies in the game | |
39 | +and figure out how to hook things up so that it all works. What you | |
40 | +really need for planning is an idea of how many of which kinds of | |
41 | +factory you need, and what sorts of supplies you'll need to provide. | |
42 | + | |
43 | +For example, in the above build, I have a main bus for the copper, | |
44 | +plastic, circuits, water, and iron. The rates required for batteries, | |
45 | +sulfur, and speed modules are low enough that I'm comfortable with using | |
46 | +the logistics network to fly them in from other places in my factory | |
47 | +where they're made. This will yield at least 1 Yellow Science every 4 | |
48 | +seconds, and all the fractional factories tell me I will probably get | |
49 | +more production out of it. I could use the `actual_production` function | |
50 | +to figure out just how much. | |
51 | + | |
52 | +[Factorio]: https://www.factorio.com/ |