KirkMcDonald / kirkmcdonald.github.io

Simple web-based calculator for the game Factorio.
Apache License 2.0
547 stars 146 forks source link

Add power plant breakdowns #50

Open KirkMcDonald opened 6 years ago

KirkMcDonald commented 6 years ago

Now that the calculator can track electricity usage, a "Power" tab should be added to break down how many of each component would be required to power such a factory, for each of the different sorts of power plants.

It would probably be useful if this tab had a box where an arbitrary amount of additional power could be added to the computed amount. It might also be useful to provide an estimate for the power usage of inserters, etc, but such numbers would necessarily be an educated guess at best. These numbers also tend to be quite trivial compared to the rest of the factory, and could probably be easily ignored.

Power estimates also do not include the power requirements of beacons, which can be quite substantial, but naively multiplying the power needs of a single beacon by the number of beacons implied by the calculator's settings would be the wrong approach: Most factory designs will, as a rule, attempt to spread a single beacon's effect to as many entities as possible, rendering the actual number of beacons in play difficult to estimate from the calculator's settings alone. A dedicated "number of beacons" box might be a useful feature.

The number of entities required is entirely trivial to compute for solar power, though the exact arithmetic is slightly annoying to derive. (12500 ticks full bright, 5000 ticks dusk, 2500 ticks full dark, 5000 ticks dawn. Dawn and dusk are a simple linear rise/drop in light levels. The rest is computing how much excess solar capacity is required during the day, and the quantity of accumulator capacity that is needed to store it for use at night. These numbers are a flat multiple of the required power level, and it may be simplest to hard-code that multiple.)

These numbers are even more trivial for steam power (at least ideally; the actual fluid mechanics of the game might introduce some loss), and it would be useful to provide a number for the rate of fuel consumption, alongside an option for selecting the user's preferred fuel type. (This same option could be used to calculate the fuel needs of stone and steel furnaces.)

Nuclear power is only slightly more difficult, given the need to account for a reactor's neighbor bonus. Mathematically, it seems reasonable to simply provide numbers for a 2xN reactor that satisfies the required power needs. (And even more than steam power, the game's fluid mechanics introduce an incalculable source of loss, which it is easiest to simply ignore.)

Nuclear power could be made more complicated by attempting to provide numbers for a fuel-controlled/steam-buffered nuclear reactor, but this sort of trickery is probably outside the scope of this calculator, and providing the simple numbers needed to satisfy demand is probably adequate.

murrayvb0 commented 6 years ago

Might be a good idea to have the default number of beacons be ~1/2 the number implied by the calculators settings, which would assume that the player is using the fairly common beacon layout where they put two rows on the outside, sharing the beacons between two production steps simultaneously.

KirkMcDonald commented 6 years ago

It isn't quite that simple.

The most naive way of calculating the total number of beacons is to take the number of beaconed modules set in the calculator's spec, divide that by 2 (to get the number of beacons), and multiply that by the number of factories. This approach is obviously wrong: It gives you the useless case of never sharing a beacon between two assemblers, ever.

The second most naive way is to assume that any given beacon will reach four assemblers. This is what you get if you set down a line of beacons next to a line of assemblers. This also limits you to a maximum of four beacons per assembler (or a multiplier of 8 in the calculator). This approach implies that the number of beacons will be (number of assemblers + 3).

You can double the number of assemblers per beacon by putting assemblers on both sides of the line of beacons. You can double the number of beacons per assembler by putting beacons on both sides of the assemblers. Alternating between lines of beacons and lines of assemblers, therefore, gives you highly efficient beacon coverage. This approach implies that the number of beacons will be ((total number of assemblers + (3 * number of rows)) + (number of assemblers in one row + 3)).

It is also possible to adjust the ratio of beacons:assemblers in either direction by designing the factory in other ways. It is beyond the scope of the calculator to meaningfully compute a count of beacons. Doing so requires knowledge of your factory's layout that simply isn't present, and which I'm not all that interested in integrating into the tool. Simply prompting the user for a count of beacons seems like a decent compromise.

murrayvb0 commented 6 years ago

In retrospect what I said makes no sense. Just ignore that.

DJMcMayhem commented 5 years ago

Simply prompting the user for a count of beacons seems like a decent compromise.

That sounds amazing. +1 for this feature. Maybe also retitle it so you can enter "Beacons" and "Modules from Beacons" separately?