Combinator cookbook 2.0

Post pictures and videos of your factories.
If possible, please post also the blueprints/maps of your creations!
For art/design etc. you can go to Fan Art.

gGeorg
Filter Inserter
Filter Inserter
Posts: 483
Joined: Wed Jun 19, 2019 8:06 pm
Contact:

Re: Combinator cookbook 2.0

Post by gGeorg »

Tertius wrote: Tue Mar 11, 2025 1:37 pm This stack size computation is truly great.
I prefer word genius. Well, I did it myself. ;)
Tertius wrote: Tue Mar 11, 2025 1:37 pm I developed a multi wagon supply train loading and unloading station,
Could you post it to other thread ?
I will add my Supply train station, so we could compare other ideas, at work.
coffee-factorio
Long Handed Inserter
Long Handed Inserter
Posts: 92
Joined: Thu Oct 17, 2024 10:56 pm
Contact:

Re: Combinator cookbook 2.0

Post by coffee-factorio »

Tertius wrote: Thu Dec 19, 2024 7:57 pm
Multi combinator setups
Now to some more complex setups with 2 and more combinators.
Memory cell
Store an arbitrary signal composition.
One combinator passes the incoming signals if the set condition is true, the other one passes the output via loopback as long as the set condition is false. Both combined create a memory cell: either the first combinator sends the outgoing signal or the second one.
The given example stores the incoming signal on red while S<>0 on green and holds it as memory while S=0.
This is quite the convoluted little monster but it is the result of studying this example and doing some reading on Wikipedia.
I was having a signal issue with controlling a circuit for vending machine creation (everyone's favorite past time nowadays, the creation of a single machine unit that will spit out everything).

For a flat dependency object this is trivial. For one that isn't you need 2 sets of stars to align: objects in good sorted (which the game thankfully provides) and smooth data flow with memory. You also need a few circuit conditions which I have rigged up to a train and infinite chests which let me obfuscate the really fun jobs of workspace cleanup, because the data flow part was rough.

Of course I do this because I like space platforms, and while I can't rain down cargo pods on arbitrary objects like I should be able to (the biters want bioflux and banana) I can make everything that doesn't take unobtanium like rare earth metals and common stones basically infinite. I also made a mechanically intensive priority queue which I think I can improve dramatically.

Wikipedia noted that you can have a master slave memory cell and that got me excited! You basically just have to have one memory cell feed into another. I then have an enable condition control one part of the cell, and a master condition control the other. The enable driven cell can performs reads whenever it sees an enable, in the example provided it is on a 2 tick period that repeats every 1/6th of a second.

This turned out to be the part that was easy to solve but required practical testing, just using a constant combinator destablizes the memory output and you get a machine that doesn't know what it is doing (and inventory flying everywhere) when recipes need to change.

The hard part was figuring out the various conditions when to raise the master flag that is on a constant combinator - the reset flag is raised at the end of the job. So the slave just grabs whatever input it sees, which could be say, a yellow inserter, when it is enabled by the timer so it has something solid. The master then decides whether or not to pass that information on to based on what it knows - and if it is holding a value it continues to broadcast it.

Done properly a machine will start building red inserters while it can from an assembly line of components, but when it runs out of a logistic item it flips around and begins making those. Once it is done, because the game has things in a sorted order it will restock its supply of a dependent item to the maximum value.
Screenshot 2025-03-16 210022.jpg
Screenshot 2025-03-16 210022.jpg (38.22 KiB) Viewed 828 times



And about that operations stack.

I realized I could do it in ten minutes.
Screenshot 2025-03-16 210339.jpg
Screenshot 2025-03-16 210339.jpg (45.96 KiB) Viewed 828 times
Also that you can count inputs with a single decider combinator. The alternative option is to use an advanced circuit.

Anyways -> with a table of priorities and a table of quantities and an inventory (a combinator pretending to be a space platform).
Get the count of all items. When an item is greater than a quantity, output negative 1 (I think they just changed the circuit to output a constant).
When the stack index p matches the priority in the table, output the item associated with that index.




That was pretty fun but I thought to myself: "Well can you do better?" An obvious disadvantage is that if things are done out of order, as they often are, the stack priority breaks. Say you use rare beacons you just built.
Screenshot 2025-03-16 211216.jpg
Screenshot 2025-03-16 211216.jpg (58.65 KiB) Viewed 828 times


So this last one uses a select switch. The main difference from the previous priority mapping blueprint is that select is not being done on the basis of "most available" but rather "what I'd like done first". It also outputs the internal priority assigned - which might not be preferable overall. This can be fixed by reading anything and outputting 1 of anything on a trivial circuit. This lets you break the predefined game order, which can be important with quality targeting systems: what do you like more, crushers or asteroid collectors? Or do you have spacious cargo? This ought to let you choose. My original design took... many individual circuits to do this.

But with a simple modification it selects the item with the highest priority with a count that is less than that of a monitored inventory.

It's been some time. So if I've missed my mark, I did try and do a check to make sure these are novel. They definitely use circuits that have been done.
mmmPI
Smart Inserter
Smart Inserter
Posts: 4405
Joined: Mon Jun 20, 2016 6:10 pm
Contact:

Re: Combinator cookbook 2.0

Post by mmmPI »

I have searched on the forum but didn't found a 2.0 blueprint for a trigger Schmitt so i'm posting it here, it was made from this one : viewtopic.php?p=189046#p189046
snip.png
snip.png (36.41 KiB) Viewed 629 times


Uses a upper bound and a range to then define the lower bound.
From a set of different fluid as input on the constant combinator, can be arbitrary.
Lit the lamp when a fluid is at the upper bound.
Untill it drop under the lower bound.
Or turn off the lamp if no fluid is available.
SuperBananaBomb
Manual Inserter
Manual Inserter
Posts: 4
Joined: Thu May 07, 2020 9:50 pm
Contact:

Re: Combinator cookbook 2.0

Post by SuperBananaBomb »

Alternative way to "Include only filtered items".


Attachments
04-13-2025, 18-53-25.png
04-13-2025, 18-53-25.png (259.83 KiB) Viewed 574 times
Tertius
Smart Inserter
Smart Inserter
Posts: 1250
Joined: Fri Mar 19, 2021 5:58 pm
Contact:

Re: Combinator cookbook 2.0

Post by Tertius »

I updated the images in the top post to include combinator settings as well. I guess that's better than having to look inside the blueprints. I also added a few new contraptions that came up in this thread.
User avatar
Hares
Filter Inserter
Filter Inserter
Posts: 819
Joined: Sat Oct 22, 2022 8:05 pm
Contact:

Re: Combinator cookbook 2.0

Post by Hares »

Tertius wrote: Tue Apr 15, 2025 2:34 pm I updated the images in the top post to include combinator settings as well. I guess that's better than having to look inside the blueprints. I also added a few new contraptions that came up in this thread.
I wish (
again
) the forum engine to be Discourse so I could like the post above.
Also
Fulgora is the best planet. Vulcanus needs rework. Feel free to proof me wrong.
coffee-factorio
Long Handed Inserter
Long Handed Inserter
Posts: 92
Joined: Thu Oct 17, 2024 10:56 pm
Contact:

Re: Combinator cookbook 2.0

Post by coffee-factorio »

Tertius wrote: Thu Dec 19, 2024 7:56 pm
Find the minimum/maximum of 2 inputs
For finding the minimum, the first combinator outputs all signals from green wire whose values are lower than or equal to the corresponding signals on red wire.
The other combinator outputs all signals from red wire whose values are lower than the corresponding signals on green wire.
The combined output represents the minimum values of both inputs.

The maximum works the same, just the conditions reversed.
2 min.png

Minimum:
Maximum:
This is not exactly the minimum or the maximum. This emits the lower of two signal of each signal. And I think I have to be a little careful in saying that. So it is a lowest or highest filter as I'd phrase it and I see some value in that. Knowing which inventory has the most or least of a part seems like it has good value.

Here's the issue.

I need to find the maximum or minimum value of an inventory. As in one. If use two lines, it will output all the same because they are all >= to one another. If I select any signal from that line it's order appears to be arbitary.

The selector function takes a signal and returns it at its maximum value.
And boy.

I have twelve space ships running 27kt and each one wants a standardized legendary components line.
Each strategy I use to get to legendary, I am not using legendary then it jams. And that prevents such joyful upcycles as "cliff explosives in -> calcite out" or just "make a bulk inserter".

Below is the blueprint for a garbage arm that can deliver the most of an offending part based on count into the void of space where, for practical purposes, it must go. Only limited things can feasibly be broken to down and not into a reliable material stream off a platform.

Nidan
Filter Inserter
Filter Inserter
Posts: 308
Joined: Sat Nov 21, 2015 1:40 am
Contact:

Re: Combinator cookbook 2.0

Post by Nidan »

coffee-factorio wrote: Thu May 08, 2025 4:22 am
Tertius wrote: Thu Dec 19, 2024 7:56 pm
Tertius' setup gives the pairwise minima min(Each[red], Each[green]), the selector combinator min(all input signals). Calling both operations minimum is perfectly fine. You just need to be precise and indicate which of them is meant, if there's risk of confusion.
User avatar
Hares
Filter Inserter
Filter Inserter
Posts: 819
Joined: Sat Oct 22, 2022 8:05 pm
Contact:

Re: Combinator cookbook 2.0

Post by Hares »

Nidan wrote: Thu May 08, 2025 6:57 am
coffee-factorio wrote: Thu May 08, 2025 4:22 am
Tertius wrote: Thu Dec 19, 2024 7:56 pm
Tertius' setup gives the pairwise minima min(Each[red], Each[green]), the selector combinator min(all input signals). Calling both operations minimum is perfectly fine. You just need to be precise and indicate which of them is meant, if there's risk of confusion.
Happens when you are working with matrices and/or arrays. More proper way is to say it's per-element operation. IIRC, MATLAB has dot-operators for describing per-element ones. I.e. `a .* b` is a dotproduct oh wait it's not. `a .* b` is a new vector where all elements are products of respective elements from a and b.
Fulgora is the best planet. Vulcanus needs rework. Feel free to proof me wrong.
Tertius
Smart Inserter
Smart Inserter
Posts: 1250
Joined: Fri Mar 19, 2021 5:58 pm
Contact:

Re: Combinator cookbook 2.0

Post by Tertius »

coffee-factorio wrote: Thu May 08, 2025 4:22 am I need to find the maximum or minimum value of an inventory. As in one. If use two lines, it will output all the same because they are all >= to one another. If I select any signal from that line it's order appears to be arbitary.

The selector function takes a signal and returns it at its maximum value.
And boy.
Sorry, but I struggle to understand what you wrote. I don't get what you mean with "As in one", "If use two lines", "and boy".
From the blueprint you posted, it seems you want to get the single highest signal from an input, but only if it is greater than some threshold.

What you posted does work this way, but it's coincidence. You used the ANY wildcard on both the condition and on the output as well. This will only output the intended signal, if you feed a single signal on input. Otherwise the ANY on output will pick one from the input, not necessarily the intended one. By coincidence it will not pick your "Fire" signal you chose for the threshold, because as virtual signal it has a lower position in the hardcoded game signal order, so it's guaranteed that it's never being picked as long as there are also item signals present. [note to self: add an explanation of signal order to the cookbook]

The proper solution is to first filter eligible signals from the source, in your case all signals greater than the threshold. A decider, with condition EACH > threshold and EACH as output. You can feed this output directly to the inserter as filter.

You can also have individual thresholds for each item. Use the "Limit filtered items" blueprint from the cookbook. In case there are arbitrary other items on the wire you need to ignore, add a second condition to the decider as shown in the "Include only filtered items" blueprint to limit the output to just the items configured via constant combinator.

Now the inserter will move anything that's above the threshold eventually. Not necessarily the largest amount first, but eventually. Keep in mind the other items will be moved as well, as soon as the current item vanishes from the filter because it went below the threshold. If you always must move the largest amount first, you can feed this to a selector combinator to pick the largest signal only, then feed this to the inserter.
coffee-factorio
Long Handed Inserter
Long Handed Inserter
Posts: 92
Joined: Thu Oct 17, 2024 10:56 pm
Contact:

Re: Combinator cookbook 2.0

Post by coffee-factorio »

So I think where I need to start is:

Hares' is the smarter of all of us :lol:

Because in one, he's got it. It'd doing pairwise minimum.
I want to stand on as that does as advertised and it does as it should from a logical point of view, but there's a problem that demands some kind of cookbook entry that the selector -> max count handles well.

I've run into a bit of a spot. This is complicated.

Here's what signaling looks like:

Fact 1:
When we generate a signal we generate a pair (key, value).
As a set these pairs are broadcast on a line so you get (k, v) , (k_1, v_1), (k_2, v_2). Based on the sum of all values on that line.

Fact 2:
The key values are based on where the item appears in the games tables, the first cell on the first table is the first key. Then quality is applied then the next key is item to the right of that.

As an Excercise to verify fact 2, get an automall to run chemical plants prior to telephone poles.

Fact 3: If you select any signal from a set of signals that that are true, any signal will be returned in the order given by Fact 2.

Fact 4: A select combinator returns the top or bottom value of a list of (k, v), sorted based on the (v_i <= v_i + 1)

I did not arrive at my solution by coincidence: I will now cherry pick the most horrible example of how any > thresh hold goes wrong when used with monitoring quality.

You have a distribution of 5 each of 4 parts in a chemical lab. Any pipe > thresh hold goes; it's a logistic item - the rest are components. On 3 states that occur with the same frequency. For any quality of pipe. So three stacks of parts fill up to thresh hold then pull till just under it. Pipes are added in an equal distribution, so when any of those parts occur simultaneously with pipes, you pull pipes. The belt advances while the pull occurs on a sushi belt, so it's possible for 5 steel to throw out more than 5 pipes as it escape the belt when the pull occurs, then arrives with 5 pipes. In your own time you may try a not sushi belt. Think before you do. And think about the implications of doing that in a chest, although the tested use case was on a space platform.

All are relevant to build a chemical plant. With stacking 5 items can occur in a cell 8 deep in 4 high stacks. And given fact 2, if you have a pile of high quality pipes, but banal steel, that happens to hit an arbitrary threshhold on cells that can hold 8 of 1 to 4 values given at random. Pipes high quality are the first choice to remove. And it's down to luck that doesn't happen.

You can, in your own time, prove that a sushi belt removing parts is equivalent to a Turing machine. If you arrive at a FSM, remember that a circular belt means an instruction can reoccur. Which is equivalent to telling a belt to move backwards to an instruction. And jamming is it halting when it should continue. Any > thresh hold is the equivalent of a turing machine that removes one set of several instructions if it sees any one of four accepting states. Since if no pipes after a limit do not reach the assembler on a mis-constructed line and pull inserters before assemblers can put parts inside to finish labs; that throws out pipes prior to them reaching the assembler. This machine has a passable chance of out running the computer simulating it. To make it the virtual machine that kills any perfect logic, you need to deliberately sabotage the line in a way such that it jams before it completes a parts order (I think you need to read assembly machine contents and then kill the input belt). However, the hypothetical case of inappropriately redistributing parts is bad here. In Bulk inserters you can throw out a 1 in 32 fast inserter in the same way. But two of those lines go at speed 15 and two go at speed 1.

As it is a Turing machine, "select max" gets around a lot of issues because it stops, counts the most, then throws out the most. So the even distribution that offends randomly is unpacked randomly at least. If you fix input on a perfectly linked circular list that the inserter sees that'd cause it to run infinite, but in practice that'd be hard to do.

You can also tool to meet the problem at its level by modifying the contents with parts that you'd otherwise throw out but after a delay. And recognize "hostile instruction sets".

Like biolabs. Think about unloading with belts alone (chests can help) the parts distribution with either any beats thresh hold or max select on jam.
Post Reply

Return to “Show your Creations”