The following is NOT a solution that was asked for, but may be of use to some as it deals with a similar type of a problem. Specifically, how to quickly time sort many signals into relatively few time slots. There are 5 time slots In the diagram, although the circuit can be extended indefinitely provided one is willing to pay for 2 deciders per additional slot.
sts.jpg (41.09 KiB) Viewed 12640 times
How it works. The signals value correspond to the desired time slot. All the signals are dumped into the sorter in a pulse 1 tick wide. The deciders on the left select all the signals that belong in the desired time slot and inject them into the delay line formed by the deciders on the right.
Re: Combinator Contraptions
Posted: Wed Mar 16, 2016 10:58 am
by Amegatron
Dr. Walrus wrote:This one is a little more specific. It inputs the rising edge of a signal, and outputs it later after being delayed by a custom number of ticks. The tick length of the delay is set by the value of the blue signal in the top-right constant combinator. For this contraption to work properly It has to receive a signal with at least 1 positive number and It can't contain any blue signals. The minimum delay is 5 ticks, and the maximum is 99,999,999 in case you want to input a signal and have it output once you finish college.
Damn, this is what I was looking for. But still I cannot understand how does it work :/ I've already started a topic nearby about delayed pulse generator. Seems your solution could help me. Could you please explain or maybe just post this layout more spaced so I could clearly see all wires?
Re: Combinator Contraptions
Posted: Wed Mar 16, 2016 8:05 pm
by XKnight
Amegatron wrote:
Dr. Walrus wrote:This one is a little more specific. It inputs the rising edge of a signal, and outputs it later after being delayed by a custom number of ticks. The tick length of the delay is set by the value of the blue signal in the top-right constant combinator. For this contraption to work properly It has to receive a signal with at least 1 positive number and It can't contain any blue signals. The minimum delay is 5 ticks, and the maximum is 99,999,999 in case you want to input a signal and have it output once you finish college.
Damn, this is what I was looking for. But still I cannot understand how does it work :/ I've already started a topic nearby about delayed pulse generator. Seems your solution could help me. Could you please explain or maybe just post this layout more spaced so I could clearly see all wires?
Your task gave me an idea of interesting challenge:
Signal delayer challenge
Task: delay input signal for X ticks (X may be set by user)
Expected result: the same as X series-connected arithmetic combinators (input: Each + 0; output: Each)
Example of delay 3
Tick: Input signal/Output signal
1: 10/empty
2: 20/empty
3: 30/empty
4: 40/10
5: 50/20
6: 60/30
7: 70/40
8: empty/50
9: empty/60
10: empty/70
Main focus: amount of combinators
Re: Combinator Contraptions
Posted: Thu Mar 17, 2016 4:02 pm
by Dr. Walrus
Amegatron wrote:
Quotes
Dr. Walrus wrote:This one is a little more specific. It inputs the rising edge of a signal, and outputs it later after being delayed by a custom number of ticks. The tick length of the delay is set by the value of the blue signal in the top-right constant combinator. For this contraption to work properly It has to receive a signal with at least 1 positive number and It can't contain any blue signals. The minimum delay is 5 ticks, and the maximum is 99,999,999 in case you want to input a signal and have it output once you finish college.
Damn, this is what I was looking for. But still I cannot understand how does it work :/ I've already started a topic nearby about delayed pulse generator. Seems your solution could help me. Could you please explain or maybe just post this layout more spaced so I could clearly see all wires?
I've been a bit busy with work lately and I'm away from my factorio computer so I'll give you a quick rundown on how it works. IF you are still confused I'll post a complete breakdown in a few days.
The input signal is run through a 1 tick limiter that only outputs the first tick of a signal. It is then run through a memory cell, which is connected to the output. When the input signal passes through the 1 tick limiter it then gets stored in the memory cell and simultaneously starts a clock that goes up by 1 every tick. The clock keeps going up until it hits the user specified value of how many ticks you want to delay the signal. When this happens, simultaneously the memory cell is told to output its contents and clear its memory (which generates a 1 tick pulse for the output) and the clock gets reset.
It's a fairly kludgy design and there's probably better ways to set up the internal logic to reduce the number of combinators.
XKnight wrote:Your task gave me an idea of interesting challenge:
That's quite an interesting challenge again XKnight. In your example, it seems like you would need at least 7 memory cells, one to save the value of each individual tick in the input signal. Waiting a variable amount of time wouldn't be too hard, just affix a blue signal of the value of the input tick to each input and then output when a clock = that signal + user selected delay. However if you wanted to use less memory cells than the number of individual ticks, that would be tricky. You would have to encode your signals somehow so multiple signals could fit on the same combinator. hmmmm... Once again you've given me another idea for my next combinator contraption, but an elegant solution to your challenge eludes me.
Re: Combinator Contraptions
Posted: Thu Mar 17, 2016 7:30 pm
by XKnight
Dr. Walrus wrote:You would have to encode your signals somehow so multiple signals could fit on the same combinator. hmmmm... Once again you've given me another idea for my next combinator contraption, but an elegant solution to your challenge eludes me.
Right direction, keep going!
Re: Combinator Contraptions
Posted: Sat Mar 19, 2016 7:03 pm
by Dr. Walrus
I've just posted a new contraption, The Basic Encoder. It takes any individual signal under 10M and changes it into a single blue signal that contains both the type and value of the signal. This one could be the starting point of a device that allows you to store multiple signals of the same or of different types in one memory cell if you have those signals encode as different item depending on their order.
Re: Combinator Contraptions
Posted: Sat Mar 19, 2016 7:47 pm
by piriform
I could not load blue print due to error: Unknown entity basic-pressure-plate. In the meantime my WAG is that you are using a form of Godelization .
Re: Combinator Contraptions
Posted: Sun Mar 20, 2016 3:13 pm
by Dr. Walrus
piriform wrote:I could not load blue print due to error: Unknown entity basic-pressure-plate. In the meantime my WAG is that you are using a form of Godelization .
Oops! Good catch. It's fixed now.
And yes it does use Godel numbering, but only in the most primitive sense of the concept. The amount of the input signal is just converted to blue, and the type of the signal is converted into a number where wooden chest = 1, iron chest = 2, etc. and then multiplied by 10M. When added together the amount of the blue signal contains both the type and amount of the signal without going over the game's 32 bit signed integer limit. Using the true Godel numbering system with the product of a series of primes raised to the numbers you wish to encode would be huge, slow and really cool but would probably go over the integer limit really quickly. And the decoder would require me to build a contraption that calculates the nth root [ x^(1/n)] which is too big of an undertaking for me.
*Edit to avoid double posting*
Since I accidentally included pressure plates in my last contraption, the next contraption is all about pressure plates. The pressure plate stopwatch, for when you want to play factorio at 6:00 but you've got a track meet at 4:30.
Re: Combinator Contraptions
Posted: Thu Apr 14, 2016 4:39 pm
by Black Ice
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.
Computer in Factroio.png (6.82 MiB) Viewed 12335 times
Re: Combinator Contraptions
Posted: Thu Apr 14, 2016 8:32 pm
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.
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.
Re: Combinator Contraptions
Posted: Fri Apr 15, 2016 12:25 pm
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.
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?
PS AFAIK the smallest chess program has about 1/4K of instructions, but that's X86 code
the piece position evaluation loops more than 4000 times per move at say 20 instruction/loop. How much time do you have?
Re: Combinator Contraptions
Posted: Sun Apr 17, 2016 7:30 pm
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 (33.12 KiB) Viewed 11984 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.
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
Input:
- ~150 different signals in input
- each signal has unique value (I don't know, maybe this information will help you)
- each value is less than 1M (this value may be reduced/increased by your demand; it is preferable to increase this value)
Expected output:
- each signal should be presented in output without others during 1 tick
- whole process should take exactly N ticks (where N is the amount of signals in input) + fixed amount of ticks (you may use any number here; it is preferable to decrease this value)
- output sequence doesn't matter, but each signal should be presented in output once
- gaps between output signals are forbidden
Main focus: reduce "fixed amount of ticks", amount of combinators
Example:
0 tick: input A 10, B 30, C 20, D 50, E 40, F 60
1 tick:
2 tick:
3 tick:
4 tick: output A 10
5 tick: output B 30
6 tick: output C 20
7 tick: output D 50
8 tick: output E 40
9 tick: output F 60
Signal delayer challenge
Task: delay input signal for X ticks (X may be set by user)
Expected result: the same as X series-connected arithmetic combinators (input: Each + 0; output: Each)
Example of delay 3
Tick: Input signal/Output signal
1: 10/empty
2: 20/empty
3: 30/empty
4: 40/10
5: 50/20
6: 60/30
7: 70/40
8: empty/50
9: empty/60
10: empty/70
Main focus: amount of combinators
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
Input:
- N signals on the red wire; each signal has its own range: first signal - 0..10M, second - 10M..20M, third - 20M...30M, and so on;
- blue signal on the green wire; range - 1..N;
Output:
- value of the K-th signal where K is the "blue" value.
Main focus: as fast as possible; 1 tick is desired.
Am I right?
Re: Combinator Contraptions
Posted: Sun Apr 17, 2016 9:51 pm
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).
Re: Combinator Contraptions
Posted: Sun Apr 17, 2016 10:04 pm
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.
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.
Re: Combinator Contraptions
Posted: Mon Apr 18, 2016 2:33 pm
by XKnight
XKnight wrote:
Task
Input:
- N signals on the red wire; each signal has its own range: first signal - 0..10M, second - 10M..20M, third - 20M...30M, and so on;
- blue signal on the green wire; range - 1..N;
Output:
- value of the K-th signal where K is the "blue" value.
Main focus: as fast as possible; 1 tick is desired.
2 ticks are really simple:
1.png (45.78 KiB) Viewed 11897 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.
Re: Combinator Contraptions
Posted: Mon Apr 18, 2016 4:45 pm
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.
Re: Combinator Contraptions
Posted: Mon Apr 18, 2016 5:14 pm
by XKnight
Ok, next time you will write requirements by yourself
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