Remote Backpressure with Negative Numbers

Remote Backpressure with Negative Numbers

In the red and green wires section, you learned how to create circuit signals. The numbers within the signal represent the amount of a specific item across all the connected chests. For example, a signal of (15 iron) would mean that 15 iron were available across all of the chests.

By extending the numbers to the negative direction, players can represent demand. If there are (-100 iron) on the network for example, then it means some entity is demanding 50 iron be shipped to it. If the red wire were connected to both the (15 iron) and (-100 iron) signals, then the result would be -85 iron, representing that 85 more iron is demanded. Remember from the previous section: signals add to each other.

This methodology of using negative numbers and positive numbers to represent supply and demand is what I call Remote Backpressure. Lets start by creating our first negative numbers using the constant combinator.

A constant combinator can create any object on the signal to an integer between -2147483648 and +2147483647. Programmers call this a 32-bit signed integer (and for the programmers out there: yes, integer overflow and integer truncation are present). And just like anything else on the circuit network, connecting this red wire to any other box adds the contents of the box with the constant combinator.

In the following example, notice how this (-15 iron) is added with a box containing (100 iron). After the Red Wires are all connected together, the electrical pole reads (-85 iron).

From the perspective of Remote Backpressure, this means that the system demands 85 more iron plates. To react to these numbers, some actuator like a belt or inserter needs to be connected.

Within the system of remote backpressure, almost all actuators are standardized to react to the condition if (some_item < 0). In this case, I enable the inserter to only work if (iron < 0). As the box's contents increase to 100, the inserter stops and applies backpressure to the belt.

Limiting chests to a certain number is almost a solved problem already due to the stack-limitation feature. A more practical problem would be gun turret feeding.

Start with a magazine assembly rig going on. Typically, gun turrets are formed at chokepoints or natural barriers, like by trees or water. These locations are often very far away from the magazine assemblies.

Why so tedious?

The procedure listed here requires a lot of clicking and configuration. However, I choose to teach this suboptimal, tedious lesson because it is the easiest to understand. Later in the guide, you will learn pulse-mode circuits which can accomplish the same job with much fewer clicks.

Belts buffer approximately 7.1 items, half of that per side. Over 80 tiles of belt, 284 ammo magazines would be buffered, while the gun turrets would only buffer up 10 magazines at a time. This would be costly. In fact, 284 piercing rounds (1420 iron + 1420 copper) would cost more resources than 30 guns (1200 iron and 300 copper)!

Instead of buffering so much ammo, combinators can be used to limit the buffering on the belt to only 40 ammo at a time. To do that, we need to count up all of the ammo that are on the belts, and ensure that the belts don't get any more ammo than 40.

First, set the constant combinator to (-40 ammo). This represents a demand of 40 ammo on the belt.

To count the number of items on each belt segment, hook up wire to the belt, get rid of "Enable/Disable" and then set the mode to "Hold". Since the settings are somewhat complex, use "Shift-right click" and "Shift-left click" to copy/paste the settings quickly to all segments.

By stringing the wires together on each belt segment, the count of items at every location is added together. See the previous section for details.

Note the visual indicators: there is a red-scanning line when you have a belt set to "read mode", and there is a red/green light if "enable/disable" is on. Disabled belts have their animation stopped. Study these subtle (but useful) visual cues in the above example video.

At the very end, set the "Enable/Disable" flag on, and enable the entry-belt ONLY when Magazines < 0. And now, instead of wasting hundreds of ammo on these belts, only fourty magazines at a time will be let through. Hurrah!

Note: as the signal reaches zero magazines, it is removed from the pole. A value of zero is NEVER transmitted.