# Simplifying System for pumps (gas and liquid) and in/outputs

## Recommended Posts

1) Give both kinds of pump an input and an output port.

2) Get rid of vents and output buildings, unnecessary. Just a dead end endpoint of a pipe serves s input or output, depending (See below)

3) When pumping, Perform the following logic:

• Find the zones that are connected by pipes without interruption by pumps. I.e. any network of pipe sections you could explore as an ant without going through any machines or leaving the pipe systems. Make a list of objects for these zones and their inputs, outputs, etc.. This can be done once whenever pipes are built or destroyed, not every tick.
• For each zone, add up the total sum of inputs and outputs from operational pumps at a given time (this part is by tick,but one check per pump is not that intensive of calculation, not like pathfinding). Output of a pump = 1, input = -1.
• If the sum is 0, the zone does not input or output anything to any intake or output (either machine or drain or spigot), the pumps, if any, just supply each other in ratio.
• If the sum is negative, then any and all external connections other than pumps in that zone share SUPPLY fluid to the zone.
• If the sum is positive, then any and all external connections other than pumps in that zone share TAKING fluid from that zone.
• Now just divide all inputs evenly among all outputs in each zone.

Image example:

Zone A has a sum of -2, so its only external connection (bottom of image) becomes an intake and supplies as much as it can (1 unit). The pumps end up a bit starved but they share what's available (Pumps 2,3,4 share input from Pump 1 and the intake, so each seemingly gets 2/3 its maximum). The fact that pump 1 only gets 2/3 means it only outputs 2/3, which leads to a confusing differential equation, BUT you don't have to solve that. By just simulating tick by tick, you've made a simple dynamic systems model that will figure it out for you, even if it leads to oscillations for a bit, or whatever. It should settle into an equilibrium.

Zone B is 0, so Pump 3 supplies all its output perfectly to Pump 1.

Zones C and D have sums of 1, so their external connections (ends of pipes OR machines of some sort) become outlets receiving all the output of those pumps.

More complicated:

Now there are only 2 zones: A and D.

Zone A's total sum is now 4-3 = +1. So all of its external connections (two of them: bottom and top right) become intakes, both supplying 1/2 of a full pump's worth of fluid from their lakes or machines they're connected to. Overall, Pumps 1,2,3,4 are now all sharing fluid from Pumps 1,2,3,(2x intakes running at 1/2 capacity each). So all 4 pumps run full time.

Zone D still has a sum of 1, so outputs pump 4's full output to its external connection.

WHAT IF you were to suddenly run out of water at the upper right intake? Easy: bottom intake now just pulls in a full pipe's worth.

WHAT IF pump 3 shut down / lost power? Easy: sum of zone A is still the same, so nothing actually changes at all.

WHAT IF pump 4 shuts down (OR bottom right output backs up which will also shut down pump 4)? Well now, the sum of zone A is 0, so the external connections neither pull or supply fluid. However, pumps 1,2,3 continue to just push their own fluid that was still in the system around in circles (because you were a dumb player who built silly loops).

------------------------------

This solves:

1. Requests for drains / requests not to have to have a giant pump in every room you want to pull from.
2. Unnecessary complexity of vents and outlets by just removing them from the game.
3. Annoyance over pumps using up all their local gas too quickly. Easy fix: just build a couple of extra dead end pipe bits in the vicinity, and now they have 3, 4, 5 intakes to share among.
4. Unnecessary annoyance of building two giant logically redundant systems for input and output to the same area. Instead just have a power switch turning a pump on or off that flips the net sum, or use a valve to flip the net sum, which turns the same pipe from intake to output with minimal infrastructure.
5. Can easily be upgraded to additional feature later of "two pipes connecting a room with nothing else attached help equalize pressure"
##### Share on other sites

Sounds interesting, would make life easier.