Combinator Contraptions

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.
XKnight
Filter Inserter
Filter Inserter
Posts: 329
Joined: Thu May 28, 2015 10:40 pm
Contact:

Re: Combinator Contraptions

Post by XKnight »

Black Ice wrote:This is my first attempt at a computer in factorio. It's 256, 5 by 7 displays arranged in a 16 by 16 grid and it can type, by placing copper plates in the "keyboard", do very basic maths and algebra and has some basic memory. Was hoping to put in a game next (chess??) and any advice would be appreciated. :D
Computer in Factroio.png
Sorry for harsh truth, but I think you should completely destroy your CPU and start building it from the very beginning.
Fortunately, Factorio is not Minecraft, and you really don't need to put thousands kilometers of wires/redstones to build something with combinators. Here we have a lot more possibilities, but not all of them are obvious. Instead of building something huge you can try to create something smart, this will be much more interesting and you will recieve a good experience.

I admire your persistence and patience, but you've chosen the wrong path. The best what you can do is to go back and try again.

piriform
Fast Inserter
Fast Inserter
Posts: 117
Joined: Mon Jan 25, 2016 10:02 pm
Contact:

Re: Combinator Contraptions

Post by piriform »

This is my first attempt at a computer in factorio. It's 256, 5 by 7 displays arranged in a 16 by 16 grid and it can type, by placing copper plates in the "keyboard", do very basic maths and algebra and has some basic memory. Was hoping to put in a game next (chess??) and any advice would be appreciated. :D
So you are building a computer - Great!
And you published your 1st attempt- Even Better! ( I wish more people would- Hopefully we can all learn what works well and what does not)
Are you looking for specific feedback or just proud that the darn thing works? :D

PS AFAIK the smallest chess program has about 1/4K of instructions, but that's X86 code :roll:
the piece position evaluation loops more than 4000 times per move at say 20 instruction/loop. How much time do you have?
Last edited by piriform on Mon Apr 18, 2016 4:56 pm, edited 1 time in total.

piriform
Fast Inserter
Fast Inserter
Posts: 117
Joined: Mon Jan 25, 2016 10:02 pm
Contact:

Re: Combinator Contraptions

Post by piriform »

Dr. Walrus encoding/decoding method led me to create a mux circuit in which a value of a specific signal can be selected from several (many) signals, via numeric address (1..N).
EDIT ------
XKnight kindly provided a more complete description of requirements (in lieu of the above vagueness). In summary, the circuit selects one of multiple input signals via number (address) and outputs a value of that (selected) signal.
I should probably add the following:
- The address range is 1..N where N is the number of selectable input signals, however successive addresses need not be consecutive (ex. the following address sequence should be valid 1,4,5,10 ,1,12.. etc).
-Delay of several (< 6) ticks between successive addresses is acceptable.
--------

This is what the mux looks like
mux.jpg
mux.jpg (33.12 KiB) Viewed 10029 times
The leftmost constant contains interval separated signals (to be muxed) . i.e. if the interval is 10M then 1st signal will have a value of 10M second 20M etc.
These values are added to the input signals that come in via red wire into an adder with setting Each+0:Each, and adder above that inverts (i.e. each*-1:each) the signals and the intervals.
Address (blue) comes in via green wire (on the left), is multiplied by the interval (i.e. 10M) in the bottom adder, then fed into decider (Each> blue: Each) and the two arithmetic conbinators ( Each+0:Each, Each-Blue:Green). Address is also incremented and inverted (i.e. Blue+1 *-1:Blue) by the adder below the constant and then fed to a decider (Each<Blue:Each).
The outputs of the two deciders are summed then fed into a final adder that normalizes the result (Each-Blue: Green).

While this circuit works, the biggest problem I have with it is the speed. Unfortunately I need a 1 tick solution and this circuit can only do 3. I don't think a 1 tick solution is possible but would love to be proven wrong.
blueprint string
Last edited by piriform on Mon Apr 18, 2016 1:45 am, edited 1 time in total.

XKnight
Filter Inserter
Filter Inserter
Posts: 329
Joined: Thu May 28, 2015 10:40 pm
Contact:

Re: Combinator Contraptions

Post by XKnight »

piriform wrote:While this circuit works, the biggest problem I have with it is the speed. Unfortunately I need a 1 tick solution and this circuit can only do 3. I don't think a 1 tick solution is possible but would love to be proven wrong.
I recommend you to use some pattern when you are asking for help with combinators... Like this:
XKnight wrote:
MY TASK 2
Signal delayer challenge
Because it is not so easy to understand what is needed when you already present your solution. Also, given solution may knock off from the right way.

You task looks like:
Task
Am I right?

piriform
Fast Inserter
Fast Inserter
Posts: 117
Joined: Mon Jan 25, 2016 10:02 pm
Contact:

Re: Combinator Contraptions

Post by piriform »

Am I right?
Yes, of course! Your (re)statement of the problem is correct, and I should have started with a formal problem statement ( my fault).

User avatar
Dr. Walrus
Long Handed Inserter
Long Handed Inserter
Posts: 96
Joined: Fri Nov 20, 2015 6:30 am
Contact:

Re: Combinator Contraptions

Post by Dr. Walrus »

Black Ice wrote:This is my first attempt at a computer in factorio. It's 256, 5 by 7 displays arranged in a 16 by 16 grid and it can type, by placing copper plates in the "keyboard", do very basic maths and algebra and has some basic memory. Was hoping to put in a game next (chess??) and any advice would be appreciated. :D
Awesome work. You should post your own forum topic and maybe post a blueprint string or download link so we could see a more in depth view of your computer in action. While I think chess is definitely possible, it's a big step up from snake or tetris which other guys have made in the past. At least with chess the game doesn't move on its own so you wouldn't have to optimize your computer for speed. You could take 100 game ticks for the computer to calculate a move without hindering the players ability to play.
piriform wrote:Dr. Walrus encoding/decoding method led me to create a mux circuit in which a value of a specific signal can be selected from several (many) signals, via numeric address (1..N).
Could you post a blueprint string of your contraption so far so I could see how it works. And I agree with XKnight, with the wording you have now it's a little difficult to to understand what you are trying to accomplish.

My guess is:
Tick 1: Input A = (54 Wooden Chest, 22 Iron Chest, 22 Steel Chest, 10 Smart Chest), Input B = (1 Signal Blue)
Tick 2: Output = (54 Wooden Chest) <-- First signal type in order if Wooden Chest corresponds to 1, Iron Chest to 2, Steel chest to 3, etc.

or is it like this:
Tick 1: Input A = (54 Wooden Chest, 22 Iron Chest, 22 Steel Chest, 10 Smart Chest), Input B = (3 Signal Blue)
Tick 2: Output = (22 Signal Blue) <-- Value of third signal type in order if Wooden Chest corresponds to 1, Iron Chest to 2, Steel chest to 3, etc.

Doing this in 1 tick is might be tricky, 2 ticks seems very doable because I think the encoder part of my encoder/decoder combo does something pretty similar in the first 2 ticks it receives the signal.

*EDIT* I was writing this post when you replied to XKnight's question.

XKnight
Filter Inserter
Filter Inserter
Posts: 329
Joined: Thu May 28, 2015 10:40 pm
Contact:

Re: Combinator Contraptions

Post by XKnight »

XKnight wrote:
Task
2 ticks are really simple:
1.png
1.png (45.78 KiB) Viewed 9942 times
Also, second "Blue*10M" combinator may be removed if input red wire can be modified.

By the way, it looks like this task can be completed in 1 tick only when "Blue" has 10M, 20M, 30M values (instead of 1,2,3).
Probably better results will be achieved when input system will be included in task.

piriform
Fast Inserter
Fast Inserter
Posts: 117
Joined: Mon Jan 25, 2016 10:02 pm
Contact:

Re: Combinator Contraptions

Post by piriform »

Nice, clean design, but I have to apologize for wasting your and everybody's time (again).
I read your spec (on a remote monitor) and saw this
Input: 123 "A" , 0000246 "B", 0000500 "C", 2 "Blu
instead of
Input: 123 "A" , 10000246 "B", 20000500 "C", 2 "Blu
i.e. I thought you had zero padded B & C values. So DR. Walrus question
or is it like this:
Tick 1: Input A = (54 Wooden Chest, 22 Iron Chest, 22 Steel Chest, 10 Smart Chest), Input B = (3 Signal Blue)
Tick 2: Output = (22 Signal Blue) <-- Value of third signal type in order if Wooden Chest corresponds to 1, Iron Chest to 2, Steel chest to 3, etc.
is actually what I intended (Duh!).

The intended application for this is a computer input port which will collect external factory signals (i.e. ores, plates, products etc). Conventional translate,select technique requires 2 combinators per signal which can quickly add up. This method would allow signal collection at a lower cost.
In this particular application I don't have any leeway in timing. It's 1 tick or nothing, so I'm falling back to plan B which involves issuing successive addresses and reading the previous (already derived signal value). Given a fixed signals list this will entail 1 extra read instruction ( "preset") and does not appear too expensive. By using this method , actual mux delay will not matter provided the timing between successive reads is greater than that of a mux.

Even though this is a specific application for a multiplexer, I do think that this type of a circuit (and a corresponding demultiplexer) will find other uses. Once again, thanks for all the help and apologies for lack of clarity.

XKnight
Filter Inserter
Filter Inserter
Posts: 329
Joined: Thu May 28, 2015 10:40 pm
Contact:

Re: Combinator Contraptions

Post by XKnight »

Ok, next time you will write requirements by yourself :D

Here is the solution for your renewed task:
1.png
1.png (167.68 KiB) Viewed 9910 times
Details
Tests
Blueprint

piriform
Fast Inserter
Fast Inserter
Posts: 117
Joined: Mon Jan 25, 2016 10:02 pm
Contact:

Re: Combinator Contraptions

Post by piriform »

I don't have time to test it right now but it looks Really Good.

I think that this approach will be very useful. Off the top of my head I can think of the following apps
1. Input port
2. Your memory "compactification" scheme reader
3. A big one- Lookup Tables - fix the inputs in a constant and select arbitrary values in a sequence -alphabet anyone?
4.couple of these , a binary decoder, a bit of glue (and a lot of lights) and you have a very nice status display

Thanks again

Killavirus
Long Handed Inserter
Long Handed Inserter
Posts: 56
Joined: Wed Apr 13, 2016 10:39 am
Contact:

Re: Combinator Contraptions

Post by Killavirus »

This thread scares me, Not only do I have no idea whats going on I know one day I am going to test this out, My addiction is bad enough as is, WTF is going to happen to me on the day that I start to understand and use these !!!
Addiction Thy Name be Factorio, FACTORIO IS NOT A LIE.

terror_gnom
Fast Inserter
Fast Inserter
Posts: 117
Joined: Wed Apr 06, 2016 4:01 am
Contact:

Re: Combinator Contraptions

Post by terror_gnom »

Hi,
first: Nice thread and very helpfull people :) I like it :D

I like to build some kind of logistic network with trains. For this purpose I need to find the biggest and smallest amount for each Item. (smallest is easy because max > 0, min < 0 so its just a matter of changing the sign)
My first thought was: Pretty easy, just do if each > each output each itemcount, but that clearly doesnt work :(

I want to build it scalable for up to 1023 signals (I dont like the 0 in factorio^^).
To preserve the address of the signal, I code the address in the 10 least significant bits of each item, so dont change these ;)

So to sum it up:
each value per Item is unique (even with the same itemcount, the address in the 10 lsb will make them distinguishable)
there will be a max > 0 (and min < 0)

Question: Is there a way to build it without building a comperator for each Item?
task
A thought that came at the moment: Maybe some kind of sorting algorithm with a second, sorted memorystack. It needs to handle 2 different update-cycles though (1024 ticks/update from the train stations and 30-60 ticks/update from the controller). I need to think about that... probably its way to slow and doesnt save any combinators :/

XKnight
Filter Inserter
Filter Inserter
Posts: 329
Joined: Thu May 28, 2015 10:40 pm
Contact:

Re: Combinator Contraptions

Post by XKnight »

terror_gnom wrote:
task
Solution:
2.png
2.png (217.64 KiB) Viewed 8817 times
Tested with:
Input: 120 "0", 50 "1"; 12 "0" 650 "1" Output: 120 "0", 650 "1"
Input: 1120 "0", 510 "1"; 1232 "0" 610 "1" Output: 1232 "0", 610 "1"
Details
Blueprint

terror_gnom
Fast Inserter
Fast Inserter
Posts: 117
Joined: Wed Apr 06, 2016 4:01 am
Contact:

Re: Combinator Contraptions

Post by terror_gnom »

thanks for the quick answer, I like the idea :) would have never thougth about testing the difference against zero.

Another question I probably know the answer (NO!):

My brother (2nd semester software engineering) told me, the comparison of the memory blocks can be handled in at least n log n steps, with the build in parallelisation of factorio its down to log n (so with 1024 cells 10 ticks). is there a possibility to utilize the parallelisation further?

User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3700
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: Combinator Contraptions

Post by DaveMcW »

You would have to explain the exact task you are trying to accomplish in log(n) ticks. But for some tasks, you can use 1024 combinators to sort everything in one tick.

terror_gnom
Fast Inserter
Fast Inserter
Posts: 117
Joined: Wed Apr 06, 2016 4:01 am
Contact:

Re: Combinator Contraptions

Post by terror_gnom »

I have 2^10 memory cells and want to find the biggest stored value (my own logik tells me, that you need at least 10 comparisons)

User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3700
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: Combinator Contraptions

Post by DaveMcW »

Simply ( :lol: ) build a million >= operators, count each row of the 1024x1024 table, and select the row that scored a perfect 1024. In theory it is possible, in practice maybe parallelization isn't the best answer.

https://en.wikipedia.org/wiki/Space–time tradeoff

User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3700
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: Combinator Contraptions

Post by DaveMcW »

Here is a contraption that identifies a mystery signal and returns its unique ID.
signal.jpg
signal.jpg (380.7 KiB) Viewed 8701 times

terror_gnom
Fast Inserter
Fast Inserter
Posts: 117
Joined: Wed Apr 06, 2016 4:01 am
Contact:

Re: Combinator Contraptions

Post by terror_gnom »

Is Dr. Walrus still with us, so he can probably add all those nice little helpers to to first post? Probably someone is looking for it and doesnt like to check every page in this topic ;)

Next task (I did already solve it via bruteforce, but I´m sure here will be postet a way more elegant solution :P)
task Itemfilter
*edit* Can you tell me, what tool you use for the schematic? I like to use them for my build. If you just build it ingame, it gets incredibly confusing and after 2 days you have no clue how it works or even what it does^^

XKnight
Filter Inserter
Filter Inserter
Posts: 329
Joined: Thu May 28, 2015 10:40 pm
Contact:

Re: Combinator Contraptions

Post by XKnight »

terror_gnom wrote:
task Itemfilter
After reading your task I was a little bit angry, because I thought that people have forgotten how to think using their own head.
But later I calmed down and found this task quite interesting...

Obvious solution which definitely you should have to implement by yourself:
- transform each signal to 1 using (Each > -GG, Output: Each, 1)
- collect these values from A and B, check whether they are equal to 2
- multiply these signals with G
- calculate sum "A + dummy constant -G + multiplied value" and check is it bigger than 0
(some adjustments are needed if you want to work with negative values).
This solution requires 4 ticks and 5 combinators + 3 dummy combinators to propagate A to the last step.

Non-obvious solution:
2.png
2.png (182.3 KiB) Viewed 8639 times
Tested with:
Input A: 120 "A", -1234 "B", 4 "C", 10 "D", 9 "E"
Input B: "1" C, 50 "D", 12 "B", 80 "F"
Output: 10 "D", 4 "C", -1234 "B"
Details
Blueprint
You can use any diagramming software to clearly describe your builds (most popular apps).
Personally, I am using yEd for my designs, this app is free, cross-platform, and has a nice automatic layout feature.
Last edited by XKnight on Mon Apr 25, 2016 8:58 pm, edited 1 time in total.

Post Reply

Return to “Combinator Creations”