Combinators 101

This board is to show, discuss and archive useful combinator- and logic-creations.
Smart triggering, counters and sensors, useful circuitry, switching as an art :), computers.
Please provide if possible always a blueprint of your creation.
zerohourrct
Inserter
Inserter
Posts: 28
Joined: Sun Apr 10, 2016 2:57 pm
Contact:

Re: Combinators 101

Post by zerohourrct »

I tried to textually describe some of the basic logic gates over on the wiki here https://wiki.factorio.com/index.php?tit ... r_Tutorial. It should probably be moved into a new page with a different title, so that it will show up well in wiki search results. Or maybe merge the entire 4 pages on combinators into a single page wikipedia style. I plan on adding to it over the next couple days, please ask questions if anything confuses you, or anything appears wrong.

I'm shooting for a layman's description of the gritty functionality of the combinators. I feel like a lot of the major users of combinators already have in-depth understanding of logic gates and higher complicated digital circuits and that makes it hard for those of us that don't already have that knowledge. Not that the concepts are impossible to understand, it just seems like a lot of the explanations are from a higher conceptual understanding down towards that of how combinators work. I'm trying to create a description that teaches in the other direction; starting with the simple mechanics of combinators and going upwards from there.
User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3724
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: Combinators 101

Post by DaveMcW »

Logic gates are a step backwards. You could build a computer using a NAND gate on 0's and 1's, but that's only useful for theoreticians. Delete the whole logic gate section from the article.

There should be 2 articles, one on practical ways to integrate combinators into a factory, and one on advanced combinator programming.

For the programming article, give them more useful building blocks. For loop. Delay loop. Array lookup. Modulo operator.

Every paragraph should have a picture of a sample build.
User avatar
brunzenstein
Smart Inserter
Smart Inserter
Posts: 1117
Joined: Tue Mar 01, 2016 2:27 pm
Contact:

Re: Combinators 101

Post by brunzenstein »

zerohourrct wrote:I tried to textually describe some of the basic logic gates over on the wiki here https://wiki.factorio.com/index.php?tit ... r_Tutorial. It should probably be moved into a new page with a different title, so that it will show up well in wiki search results. Or maybe merge the entire 4 pages on combinators into a single page wikipedia style. I plan on adding to it over the next couple days, please ask questions if anything confuses you, or anything appears wrong.

I'm shooting for a layman's description of the gritty functionality of the combinators. I feel like a lot of the major users of combinators already have in-depth understanding of logic gates and higher complicated digital circuits and that makes it hard for those of us that don't already have that knowledge. Not that the concepts are impossible to understand, it just seems like a lot of the explanations are from a higher conceptual understanding down towards that of how combinators work. I'm trying to create a description that teaches in the other direction; starting with the simple mechanics of combinators and going upwards from there.
thank you indeed for your dedication focusing on the 90% of folks here not born programmers but eager to learn- without easy understandable basics (and that's badly lacking) this whole game will end up in an ivory tower for a few..
zerohourrct
Inserter
Inserter
Posts: 28
Joined: Sun Apr 10, 2016 2:57 pm
Contact:

Re: Combinators 101

Post by zerohourrct »

DaveMcW wrote:There should be 2 articles, one on practical ways to integrate combinators into a factory, and one on advanced combinator programming.

For the programming article, give them more useful building blocks. For loop. Delay loop. Array lookup. Modulo operator.
Every paragraph should have a picture of a sample build.
Yeah, the article was pre-existing with no text written for anything. I just want to focus on the simpler practical applications, and get progressively more complicated. I try my hardest to not delete stuff for the sake of deleting it; it should generally be moved into a different page or different section within that page. It's wiki principle that you don't delete information unless its superfluous. Like I said it probably would have been better to just start a new page, but someone had already made that one :D
User avatar
brunzenstein
Smart Inserter
Smart Inserter
Posts: 1117
Joined: Tue Mar 01, 2016 2:27 pm
Contact:

Re: Combinators 101

Post by brunzenstein »

This page is incredible valuable indeed! More pictures would be highly appreciated as not everyone is a programmer but many laymen eager to learn
rufflezau
Inserter
Inserter
Posts: 23
Joined: Fri Apr 15, 2016 12:43 am
Contact:

Re: Combinators 101

Post by rufflezau »

Yea way to complex for me requester chests and logistic robots with limits seems to do just as well XD
garlicbug
Manual Inserter
Manual Inserter
Posts: 1
Joined: Fri Apr 15, 2016 4:27 am
Contact:

Re: Combinators 101

Post by garlicbug »

Thanks for the write-ups, especially to zerohourrct. I signed up to the forums to ask how to make what is basically the Set-Reset switch. Of course, a few minutes ago I realised the problem I was trying to solve would be much better solved by building a better assembly line rather than creating a circuit network, but learning new things is fun :D
User avatar
brunzenstein
Smart Inserter
Smart Inserter
Posts: 1117
Joined: Tue Mar 01, 2016 2:27 pm
Contact:

Re: Combinators 101

Post by brunzenstein »

zerohourrct wrote:
DaveMcW wrote:There should be 2 articles, one on practical ways to integrate combinators into a factory, and one on advanced combinator programming.
Exactly!
I kindly ask you ( I stand for many laymen here who are not born programmer but look for extending their understanding how stuff works) to extend the documentation with real world examples with easy to follow pictures like:

- "I have enough robots so lube production may be reduced"
- "switch chemical production to another product before the whole thing shuts up bcs all tanks are soon becoming full"
- "Power gets low, so switch the auxiliary steam engines on, put a warning light up until the problem is solved, and then shut the helper steam engines down"

Something like that

Thanks in advance.
A lot...
Serenity
Smart Inserter
Smart Inserter
Posts: 1017
Joined: Fri Apr 15, 2016 6:16 am
Contact:

Re: Combinators 101

Post by Serenity »

Even if you've studied computer science and electronics, the way this is implemented in the game is overly complicated once you get beyond the absolute basics. There is a whole layer of abstraction and changes between theory and practice. Some of the signals and conditions have weird names like "anything" instead of "or", "each" instead of "and". Other things aren't straightforward and have to be worked around and implemented with other stuff. It's just confusing.

Also, given how important latches are for advanced circuits, they should just make that its own component. But instead of the RS-FF maybe the JK-FF. That doesn't have the undecided state and can also be used to toggle.
EnderTheXenocide
Burner Inserter
Burner Inserter
Posts: 17
Joined: Sat Apr 02, 2016 6:23 pm
Contact:

Re: Combinators 101

Post by EnderTheXenocide »

I'm trying to figure out a way to use this to make a splitter that uses a different ratio than 1:1

For example, for every 7 plates that come down a belt, I want 6 to move onto one belt, and the 7th to go onto a second belt.

I'm very new to this but did manage to make a setup in which I could fill chests to the desired ratio using arithmetic on the chest quantity. However the system completely falls apart if I want to be able to keep filling the chests to that ratio while also using the stored material. It seems to me that what I really need is a way to respond to inserter events.

Is there a way to do this that isn't really complicated?
Serenity
Smart Inserter
Smart Inserter
Posts: 1017
Joined: Fri Apr 15, 2016 6:16 am
Contact:

Re: Combinators 101

Post by Serenity »

You don't need combinators for that. Just splitters:
viewtopic.php?f=18&t=5280#p40680
EnderTheXenocide
Burner Inserter
Burner Inserter
Posts: 17
Joined: Sat Apr 02, 2016 6:23 pm
Contact:

Re: Combinators 101

Post by EnderTheXenocide »

Serenity wrote:You don't need combinators for that. Just splitters:
viewtopic.php?f=18&t=5280#p40680
Thanks, I hadn't thought of using them like that!
Lurkily
Inserter
Inserter
Posts: 47
Joined: Mon Jan 11, 2016 1:55 am
Contact:

Re: Combinators 101

Post by Lurkily »

I am only beginning to wrap my head around combinators . . . but I'm trying to use them for a specific task right now, and am having trouble. Is it possible to use a combinator to tell a smart inserter to ONLY insert an object type that is ALREADY in a chest? No matter what that item type is? This would enable me to set up storage arrays that would attempt to self-order themselves so that each item type being poured into the array had a chest reserved for it - and perhaps multiple chests, if the array became inundated. This would also make it possible to feed items from this storage array back into a sorting facility in a semi-mixed fasion. That is, run some of every item in the facility down a mixed belt to get sorted into useful belts - which, if they were overloaded and didn't sort out, would return to storage.

Yeah, I know it's overly complex, but I'm hopped up on caffeine right now, and this is the marble run that I'm building at this moment.
terror_gnom
Fast Inserter
Fast Inserter
Posts: 121
Joined: Wed Apr 06, 2016 4:01 am
Contact:

Re: Combinators 101

Post by terror_gnom »

Hi,

poorly it isnt possible to set the filter of the inserters by a singal. You can only turn them on/off by network condition :(
Lurkily
Inserter
Inserter
Posts: 47
Joined: Mon Jan 11, 2016 1:55 am
Contact:

Re: Combinators 101

Post by Lurkily »

So I would have to have a smart chest with all but one slot blocked, and have the inserter run only when the 'anything' signal is >1, and then load into a second smart chest. Hum. Messy.
User avatar
brunzenstein
Smart Inserter
Smart Inserter
Posts: 1117
Joined: Tue Mar 01, 2016 2:27 pm
Contact:

Re: Combinators 101

Post by brunzenstein »

Could anyone please set up a consistent video tutorial series on combinators and their practical use!?
So that also non-programers and folks with robust math knowledge only being able to make good use of it.
Lurkily
Inserter
Inserter
Posts: 47
Joined: Mon Jan 11, 2016 1:55 am
Contact:

Re: Combinators 101

Post by Lurkily »

I've never found a tutorial more enlightening than just hooking up random bits and pieces with a single pole somewhere, and watching what the signals do. Nobody's explanations were more useful than poking and prodding, though some usage examples were helpful.
BlakeMW
Filter Inserter
Filter Inserter
Posts: 962
Joined: Thu Jan 21, 2016 9:29 am
Contact:

Re: Combinators 101

Post by BlakeMW »

I learned another interesting thing about circuit network.

When you do a comparison like Everything > A then the signal on the right hand side is not included in the Everything, that is it doesn't compare A > A and return false, instead it compares everything except A against A.

When I actually thought this through I was like "well gee duh" because if the compared against signal wasn't excluded from Everything then you could never use Everything in > or < comparisons because A > A and A < A is logically always false. As sensible as this behavior is, until I saw it working I had assumed Everything > A would always be by the definition of Everything a false condition. Instead the devs have made it do something practical instead of something useless.
User avatar
siggboy
Filter Inserter
Filter Inserter
Posts: 988
Joined: Tue Mar 29, 2016 11:47 am
Contact:

Re: Combinators 101

Post by siggboy »

BlaatMekker wrote:A simpler S-R latch design: two binary (0/1) signals (A and B) being fed into one signal decider combinator which feeds back into itself. Because the signals need to be binary you require additional decider combinators when hooking up chests.
[... screenshot ...]
The condition on the light is "A > 0". It holds the S or R signal, which ever was active first. I don't think it can flicker either.
This is in every aspect the better latch design than the one shown in the OP:
  • Uses only 1 combinator instead of two... duh. BIG advantage. A lot more economical, and also easier to understand than two gates feeding into each other.
  • It does not have the significant limitation of being unable to handle 1-tick inputs; and it can't be created in an unstable state, even if you blueprint it. OP spends a lot of time explaining how to work around the single-tick limitation (pulse clock and all...). It's simply not necessary with this version.
  • It not only handles 1-tick inputs correctly, it handles inputs of any length. You can pulse "A=1" or you can hold it for any length and the end result will always be a stable state.
  • There are several ways to flip the state, and it's not very picky about the input. Apply any positive "A", and it will remain in the "A" state after the signal drops. Disable it by applying any positive "B", or any negative "A", it's your choice. Very easy to use.
The "B" signal is not even necessary. An even simpler way to make it is: "A > 0; Output A = 1" (and feed it back to itself). This one is toggled on with any positive "A" (of any length), and toggled off with any negative "A".

The original post should be updated to reflect that.

(BTW I'm not blaming OP for falling into the trap of trying to emulate a "traditional" SR-latch in Factorio. I did the same thing, but then at some point it hit me that the above design is just better; I also realized the 1-tick unstable behavior after a while and wasted time with work-arounds.)

Traditional EE knowledge and trying to apply it to Factorio is a fallacy (it's useful with higher level concepts such as multiplexing).
Serenity wrote:Even if you've studied computer science and electronics, the way this is implemented in the game is overly complicated once you get beyond the absolute basics. There is a whole layer of abstraction and changes between theory and practice. Some of the signals and conditions have weird names like "anything" instead of "or", "each" instead of "and". Other things aren't straightforward and have to be worked around and implemented with other stuff. It's just confusing.
Yes, I absolutely agree with you. It's very arcane, and even with a solid background in hardware design or EE it's incredibly quirky and very difficult. Not least because there is no debugging instrumentation available (observing single tick signals is next to impossible unless you build make-shift infrastructure, again, out of combinators...).

The devs keep saying that they want combinators for "simple" factory automation, and that they were never made to create "complicated" circuits, even though that's possible.

Unfortunately, by saying that they ignore the fact that nobody uses combinators to make simple circuits. The players who use them to make anything actually useful in the game build very complicated machines, i.e. they use them for things they weren't "made for". There's a huge gap between "toy applications" and "circuits that enhance the factory". Crossing that gap is next to impossible unless you devote a LOT of time to it.

Combinators are quite useless unless you create actual circuits with them. But creating actual circuits is a black art, nothing less (that's what Serenity pointed out).

Maybe this situation will improve a little with version 0.13, when additional possibilities exist to interface with the factory. But in my opinion it would be better to forget about that idea of "simple applications" and create combinators that make it easy to build real circuits instead.
Also, given how important latches are for advanced circuits, they should just make that its own component. But instead of the RS-FF maybe the JK-FF. That doesn't have the undecided state and can also be used to toggle.
Well, a latch is only a single combinator (see above), it could hardly be any simpler.

What's actually missing is a simple way to store and retrieve values, i.e. a register or memory cell. This is extremely limiting, until you've invented these building blocks, and they take up quite a lot of space and are rather finicky.
Is your railroad worrying you? Doctor T-Junction recommends: Smart, dynamic train deliveries with combinator Magick
Yes-Man
Inserter
Inserter
Posts: 27
Joined: Tue May 24, 2016 1:23 pm
Contact:

Re: Combinators 101

Post by Yes-Man »

Your tutorial is the first basic and understandable explanation about networks and circuits I found.
Thank you!

(although there seems to be room for improvement, I now have a basic understanding what's going on)
Post Reply

Return to “Combinator Creations”