Hi all,
I'm wondering if it is possible to invert ALL entries of a circuit signal. So for example if the circuit signal contains iron, I want a signal which contains everything but iron. My plan was to use a decider combinator where the condition would be *(each) = 0, and the output would be 1 to *(each), so I wanted the combinator to invert all entries separately. It doesn't work, because I guess it ignores all the entries where the value is 0, so it will only invert those where the value is not 0. So the output of the combinator will be zero.
Thanks in advance
Inverting circuit signal
Re: Inverting circuit signal
Depends on the inversion - numerically or logically. Mathematically you'd do EACH *-1 and output Value to EACH with an arithmatic combinator.
Logically, an EACH = 0 with output 1 to EACH via a decider combi in theory should work. Not sure how the game responds to this, because it -should- set any unused channel to 1 in the output, potentially making for a rather messy cluster inverter.
[Edit] I suppose inactive channels are ignored. Additional option: Add a constant combinator with value 1 on each channel you want to test for, then connect that up to the decider combi via the other color cable. Then test for "EACH = 1" with an output of 1 to EACH instead. Bit of a kludge, but it should work.
Logically, an EACH = 0 with output 1 to EACH via a decider combi in theory should work. Not sure how the game responds to this, because it -should- set any unused channel to 1 in the output, potentially making for a rather messy cluster inverter.
[Edit] I suppose inactive channels are ignored. Additional option: Add a constant combinator with value 1 on each channel you want to test for, then connect that up to the decider combi via the other color cable. Then test for "EACH = 1" with an output of 1 to EACH instead. Bit of a kludge, but it should work.
Re: Inverting circuit signal
Yes, that is what I was expecting too. But it seems the theory do not match the practice here:
The constant combinator has 100 conveyor belts, that is the input for the decider comb as you can see. But there is no output at all, I would expect the output to be 1 for each item type except the conveyor belt. If I change the comb to a fixed item type instead of the EACH wild card it works as expected:
So I think that the EACH wild card is not working the way we think it would work. If the input is zero for a given item type, the operation is not executed, and the output will be zero as well. I don't think it is a bug, I guess it is a design decision. However I'm not sure it is correctly documented.
The constant combinator has 100 conveyor belts, that is the input for the decider comb as you can see. But there is no output at all, I would expect the output to be 1 for each item type except the conveyor belt. If I change the comb to a fixed item type instead of the EACH wild card it works as expected:
So I think that the EACH wild card is not working the way we think it would work. If the input is zero for a given item type, the operation is not executed, and the output will be zero as well. I don't think it is a bug, I guess it is a design decision. However I'm not sure it is correctly documented.
- Deadly-Bagel
- Smart Inserter
- Posts: 1498
- Joined: Wed Jul 13, 2016 10:12 am
- Contact:
Re: Inverting circuit signal
You're assuming that a signal of 0 has a value of 0, that is not technically the case. Sure, you can add a condition for [signal] = 0, but actually the value is null.
Basically those options only work for signals with a value, and nobody wants this to work any other way. You would need to set up a chain of Constant Combinators outputting the signals you want, or you might be able to write a mod for an item to do it for you.
Basically those options only work for signals with a value, and nobody wants this to work any other way. You would need to set up a chain of Constant Combinators outputting the signals you want, or you might be able to write a mod for an item to do it for you.
Money might be the root of all evil, but ignorance is the heart.
Re: Inverting circuit signal
Sorry I'm a bit confused. Are you saying that when a signal is empty, it is different than having the value zero? If so, why my second example worked? I'm checking if the lab signal is zero, and that condition becomes true, as you can see on my second shot the output of the combinator is one. If it is working for a specific item, why isn't it working for each?Deadly-Bagel wrote:You're assuming that a signal of 0 has a value of 0, that is not technically the case. Sure, you can add a condition for [signal] = 0, but actually the value is null.
Basically those options only work for signals with a value, and nobody wants this to work any other way. You would need to set up a chain of Constant Combinators outputting the signals you want, or you might be able to write a mod for an item to do it for you.
Re: Inverting circuit signal
Well, I am not so sure about that last part. Every once in a while I find myself thinking that propagating a zero signal would be useful. This could be done by propagating explicitly output zeroes (e.g. by a constant combinator) and otherwise let it be null (which is not propagated at all). I suppose the argument against it is that it is not very intuitive.Deadly-Bagel wrote:You're assuming that a signal of 0 has a value of 0, that is not technically the case. Sure, you can add a condition for [signal] = 0, but actually the value is null.
Basically those options only work for signals with a value, and nobody wants this to work any other way.
You can sort of work around the problem by shifting the entire domain and correcting afterwards, but it is not very clean.
Re: Inverting circuit signal
Wires carry a vector of signals with their values. Zero signals are dropped from the vector to save memory and processing.
When comparing specific items a missing signal is equal to 0. Not so for the 3 specials: Everything, Anything and Each. Those only consider the signals actually present. Note that Everything whatever is true if no signals are present while Anything whatever needs at least one signal.
When comparing specific items a missing signal is equal to 0. Not so for the 3 specials: Everything, Anything and Each. Those only consider the signals actually present. Note that Everything whatever is true if no signals are present while Anything whatever needs at least one signal.
Re: Inverting circuit signal
Thanks, that perfectly explains it and matches what I experienced. Meanwhile I was able to solve my problem without the need to invert the signal vector: viewtopic.php?f=8&t=58231mrvn wrote:Wires carry a vector of signals with their values. Zero signals are dropped from the vector to save memory and processing.
When comparing specific items a missing signal is equal to 0. Not so for the 3 specials: Everything, Anything and Each. Those only consider the signals actually present. Note that Everything whatever is true if no signals are present while Anything whatever needs at least one signal.
-
- Inserter
- Posts: 23
- Joined: Fri Feb 02, 2018 3:05 pm
- Contact:
Re: Inverting circuit sign
You would have to manually construct a signal with everything set to 1 (eg by chaining constant combis with a batch in each) then you can subtract your input signal from your “all signal” wire (you want -1 in each of your input signals) and anything that’s > 0 will be your result.
Edit: I guess you could add a Each != 0 decider after the arith+diode, but it doubles the latency and adds a third combi to the single signal filter case.
Edit2: actually it could replace the diode if you can guarantee the signal to be filtered isn’t 0 itself.
Currently the only way to remove a signal out of a set is be setting its value to zero, explicit zeros would break that.Caine wrote:Well, I am not so sure about that last part. Every once in a while I find myself thinking that propagating a zero signal would be useful. This could be done by propagating explicitly output zeroes (e.g. by a constant combinator) and otherwise let it be null (which is not propagated at all). I suppose the argument against it is that it is not very intuitive.Deadly-Bagel wrote:You're assuming that a signal of 0 has a value of 0, that is not technically the case. Sure, you can add a condition for [signal] = 0, but actually the value is null.
Basically those options only work for signals with a value, and nobody wants this to work any other way.
You can sort of work around the problem by shifting the entire domain and correcting afterwards, but it is not very clean.
Edit: I guess you could add a Each != 0 decider after the arith+diode, but it doubles the latency and adds a third combi to the single signal filter case.
Edit2: actually it could replace the diode if you can guarantee the signal to be filtered isn’t 0 itself.
Re: Inverting circuit sign
Yes that are pros and cons. E.g. the fact that quantification works only on propagated signals is confusing a lot of people regarding the behaviour of any and all.TheOnefinn wrote:Currently the only way to remove a signal out of a set is be setting its value to zero, explicit zeros would break that.
Edit: I guess you could add a Each != 0 decider after the arith+diode, but it doubles the latency and adds a third combi to the single signal filter case.
Edit2: actually it could replace the diode if you can guarantee the signal to be filtered isn’t 0 itself.
I am still undecided which one is best, so I am letting the idea incubate for a while. We should collect those pros and cons some day (if it has not been done already).