Circuit network: I don't understand

Don't know how to use a machine? Looking for efficient setups? Stuck in a mission?
J-H
Fast Inserter
Fast Inserter
Posts: 190
Joined: Fri Apr 21, 2017 11:48 pm
Contact:

Circuit network: I don't understand

Post by J-H »

I have copied this string from a Reddit post, but I don't understand what's going on.

The OP (fofz1776):
https://www.reddit.com/r/factorio/comme ... ?rdt=54092
Sushi belts are belts that carry more than two different items. Sushi can make things smaller and sometimes even simpler. There are many ways to make sushi. This tutorial is for a simple way of making sushi that can have any number of items.

The idea is simple. You have a belt that makes a loop and a combinator that knows what is in the loop. This can achieved in the following way:

Connect everything that puts items into the loop with green wires.

Connect everything that takes items out of the loop with red wires.

Set everything to "read contents" and "pulse"

Connect the red wire to a combinator set to multipy "each" by -1 and output "each"

Connect the green wire and the combinator to annother combinator set to add 0 to "each" and output "each"

Connect that combinator's output to it's own input with a green wire.

Now the green wire will carry a signal that is the contents of the loop. By setting "enable/disable" conditions for anything that puts items into the loop, you can limit how much of any item is in the loop. To varify that everything is working, mouse-over the combinator to see the contents of the loop and confirm that it is accurate.
Blueprint
Please help me understand the steps that are going on here.

Connect everything that puts items into the loop with green wires.
This is for belt inputs, not arm inputs. Green signal is going to carry contents information somewhere.

Connect everything that takes items out of the loop with red wires.
These are for arm outputs, and they're going to send info of what they've picked up somewhere.

Set everything to "read contents" and "pulse"
This means that it's going to send one-time information instead of ongoing information. Does this mean it's an add and subtract process to track the inventory on the belt rather than a live inventory? If so, if I directly add extra components to one of the target machines, am I going to throw off the math permanently?

Connect the red wire to a combinator set to multipy "each" by -1 and output "each"
Item taken off belt x -1 means it's now tracking how many items have been removed from the belt.
The Each symbol means it's going to do it for "each" input, so if arms are handling 5 different products, the signals for all will be adjusted.

Connect the green wire and the combinator to annother combinator set to add 0 to "each" and output "each"
Connect that combinator's output to it's own input with a green wire.

The green wires (input to belt) are now taking Each, adding nothing, and outputting each. It's outputting this to itself, and also back to the green inbound belts.
Something + 0 = Something = somehow the belts get this number and know when to add things? The logic chain appears to be nonsense, yet it's somehow working.
What am I missing? I have no programming background worth mentioning.
mmmPI
Smart Inserter
Smart Inserter
Posts: 4460
Joined: Mon Jun 20, 2016 6:10 pm
Contact:

Re: Circuit network: I don't understand

Post by mmmPI »

sounds like it create a memory cell with an arithmetic doing the each +0 => each looping on itself.

most likely to represent the quantity of material in the belt

Then it "pulse" some quantities in. if you send for 1 tick 1 iron ore in the previously mentionned combinator, it will do 1 iron ore +0 => 1 iron ore and keep that value, "pulse" another one, and it will loop 2 iron ore

or remove them by pulsing negative quantity with the red wire.

If an inserter remove an iron ore, it will pulse " -1 iron ore" on the memory cell, and from 2 it will turn to 1 again.

J-H wrote: Sat Apr 19, 2025 7:36 pm This means that it's going to send one-time information instead of ongoing information. Does this mean it's an add and subtract process to track the inventory on the belt rather than a live inventory? If so, if I directly add extra components to one of the target machines, am I going to throw off the math permanently?
Most likely, the math will be off, or the memory cell inacurate. The design you found on reddit is quite old, with the 2.0 update you don't need the memory cell anymore, you can remove this cause of failure and instead just read directly the content of the belt, by connecting it to a wire and "read all belts" + "hold"
Last edited by mmmPI on Sat Apr 19, 2025 7:50 pm, edited 1 time in total.
jdrexler75
Fast Inserter
Fast Inserter
Posts: 121
Joined: Sat Nov 28, 2020 5:27 pm
Contact:

Re: Circuit network: I don't understand

Post by jdrexler75 »

This is a very old setup, and back then sushi belts were rather complicated to get working.

Since 2.0 with the "read all connected belts" option, it only takes a single decider to implement a sushi belt for an arbitrary number of items on it. So I don't think there's much value in understanding obsolete logic unless you want to feel like an archaeologist here.



red input = all input belts (read only the final belt, not all belts)
green input = sushi belt (read all belts)

output = filter for the inserters, anything present in the input belts that the sushi belt doesn't have enough of

The constant 20 in the comparison needs to be tuned manually, depending on number of different number and belt length.

Full example of my science sushi, six input belts for the 12 types of science:
mmmPI
Smart Inserter
Smart Inserter
Posts: 4460
Joined: Mon Jun 20, 2016 6:10 pm
Contact:

Re: Circuit network: I don't understand

Post by mmmPI »

jdrexler75 wrote: Sat Apr 19, 2025 7:47 pm Since 2.0 with the "read all connected belts" option, it only takes a single decider to implement a sushi belt for an arbitrary number of items on it. So I don't think there's much value in understanding obsolete logic unless you want to feel like an archaeologist here.
I realized this while editing my post, i think there's still value to understand but i agree with your reasonning
robot256
Smart Inserter
Smart Inserter
Posts: 1202
Joined: Sun Mar 17, 2019 1:52 am
Contact:

Re: Circuit network: I don't understand

Post by robot256 »

I got beaten to the punch but here's my response too.
J-H wrote: Sat Apr 19, 2025 7:36 pm I have copied this string from a Reddit post, but I don't understand what's going on.

The OP (fofz1776):
https://www.reddit.com/r/factorio/comme ... ?rdt=54092
Blueprint
Please help me understand the steps that are going on here.

Connect everything that puts items into the loop with green wires.
This is for belt inputs, not arm inputs. Green signal is going to carry contents information somewhere.
Correction, this is for all inputs to the sushi loop belts. Items can be added to the belt loop by either belts or inserters, including inserters that unload machines onto the sushi belt.
Connect everything that takes items out of the loop with red wires.
These are for arm outputs, and they're going to send info of what they've picked up somewhere.

Set everything to "read contents" and "pulse"
This means that it's going to send one-time information instead of ongoing information. Does this mean it's an add and subtract process to track the inventory on the belt rather than a live inventory? If so, if I directly add extra components to one of the target machines, am I going to throw off the math permanently?
Yes, the system described uses + and - pulses to make a combinator remember how many of each item are on the belt loop. It does not track how many items are in the *machine*, so you can add and remove as many as you want without affecting the count in the sushi belt.
Connect the red wire to a combinator set to multipy "each" by -1 and output "each"
Item taken off belt x -1 means it's now tracking how many items have been removed from the belt.
The Each symbol means it's going to do it for "each" input, so if arms are handling 5 different products, the signals for all will be adjusted.
Correct.

Connect the green wire and the combinator to annother combinator set to add 0 to "each" and output "each"
Connect that combinator's output to it's own input with a green wire.

The green wires (input to belt) are now taking Each, adding nothing, and outputting each. It's outputting this to itself, and also back to the green inbound belts.
Something + 0 = Something = somehow the belts get this number and know when to add things? The logic chain appears to be nonsense, yet it's somehow working.
What am I missing? I have no programming background worth mentioning.
The last step is to *copy* the signal from one wire to another without letting signals flow in the other direction. This is needed so that the inserters or belts loading the sushi belt can transmit their pulses on one wire, and read the negative "more something needed" signal on the other wire to enable it.

It's a great way to understand circuits. But with 2.0, you can read the contents of the entire sushi belt by connecting a wire to a single belt and setting it to "read entire belt". Then you hook that signal directly to each belt/inserter loading the loop, and set them to enable when their item is less than some number. That's it.
J-H
Fast Inserter
Fast Inserter
Posts: 190
Joined: Fri Apr 21, 2017 11:48 pm
Contact:

Re: Circuit network: I don't understand

Post by J-H »

Thanks!
I take it the "memory cell" is the second combinator, the one that sends and receives the same number? Its job is only to hold a "The value in the system now is X"?

So the overall logic is:

The system has Y amount of product X with a target value of Z.
The input (arm/belt) is set to input as long as the number of Product X is less than Z.
Each time an arm removes a piece of Product X, it sends a number removed (1, or multiples for a bigger inserter), via the red wire. The * -1 combinator changes this scalar number to a negative. This then tells the input areas that the number in the system is now Y-1. If Y-1 is less than Z, then the input will activate.
When the input activates, it sends via the green wire a +1, which tells the system that the number is now Y-1 +1 = Y.

This information is either stored in the memory cell that just sends an "Each+0" = Each because it's just holding the "not visible/behind the scenes" actual value Y, or in 2.0 the network somehow just remembers it.

Correct?
Tertius
Smart Inserter
Smart Inserter
Posts: 1282
Joined: Fri Mar 19, 2021 5:58 pm
Contact:

Re: Circuit network: I don't understand

Post by Tertius »

J-H wrote: Sat Apr 19, 2025 9:32 pm This information is either stored in the memory cell that just sends an "Each+0" = Each because it's just holding the "not visible/behind the scenes" actual value Y, or in 2.0 the network somehow just remembers it.
This "somehow" or "behind the scenes" is nothing mystical and not really anything behind the scenes. It works this way:

The game as a whole runs in small steps, called "ticks". It performs 60 ticks per second, 60 small steps to create the illusion of a continuous flow.

If it comes to the circuit network, the game works through the circuits one tick at a time, tick per tick. Each tick it processes all circuit connected devices such as combinators or inserters. It looks at all the input signals on the circuit wires, and from that input the behavior of each connected device is computed. If you have a circuit connected inserter with an activation condition, this condition is checked each tick and the inserter activated or deactivated for this tick.

If it comes to a combinator, for every tick the input is determined, and in an arithmetic combinator the output is computed according to the given operation (+, -, *, / etc.). This is given to the output, where it is used as input to any connected devices THE NEXT TICK. This way the output comes 1 tick after the input, or has a delay of 1 tick. Also called latency of 1 tick.
With the decider combinator it's the same, it's just the condition is checked and the corresponding output generated. This output is then used as input as well to any connected devices the next tick.

Now to that memory cell magic. Or in our case, it's not really a memory cell but a counter.
If you just built the whole thing, there are no signals yet at all. But as soon as the inserter connected to the input of the combinator moves something, and it is configured to "read hand content (pulse mode)", it sends an 1 for the duration of one tick (pulse means "1 tick duration") for every item the hand moves. If it moves 3 red science packs, it sends a 3 for the red science pack signal on the wire, for 1 tick length. The combinator receives this 3 and passes it to its output according to its configuration.

Now you will notice a wire that connects the output with the input of the combinator. A feedback wire. So the next tick, the 3 from the output will again be read as input by the combinator. And since the combinator passes its input to the output, it is again fed back to the input. And so on. This way the 3 persists due to the feedback wire.

If the inserter moves another item or items, it sends another signal. Another pulse with whatever it moves. This again reaches the input of the combinator, in addition to the 3 it already has. Both inputs are added (that's standard circuit behavior) and passed through to the output. And it again loops back and persists through the feedback wire.

So this contraption continuously sums up all pulses it gets from the inserter. This is called a counter. This combinator, in connection with the inserter, counts the things the inserter moves. If you connect multiple inserters this way, the counter will count all items moved by all inserters. If you connect all inserters moving things onto the belt, it counts all the things that are moved on the belt. If the belt was empty before, you have the amount of all items on the belt this way available from the combinator.

Now to the -1. If you have inserters moving things off the belt, and multiply the pulse you get from reading them with -1, then add this to the combinator, you're essentially subtracting the things from the counter taken off the belt. So you always have the actual amount of items on the belt within the counter. You can use this number to stop inserters putting more items on the belt if there are enough.

And that's all. There is no magical "holding a value behind the scenes". It's a useful byproduct of the tick-per-tick processing of the game engine, the signal delay of 1 tick between input and output wire of a combinator, both connected with that feedback wire.


To see how the game processes single ticks within the circuit network, switch to map editor mode: /editor
There is a time tab in the map editor widget, where you're able to start/stop time processing and also advance the game for a single tick. This is a great circuit network debugger, since it doesn't pause the whole game as it does outside of the map editor. Instead you're able to inspect the state of every single item after each single tick step.
J-H
Fast Inserter
Fast Inserter
Posts: 190
Joined: Fri Apr 21, 2017 11:48 pm
Contact:

Re: Circuit network: I don't understand

Post by J-H »

Thanks... I think I sort of get it?
Post Reply

Return to “Gameplay Help”