Is there a way to check if two circuit signals are the same?
-
- Manual Inserter
- Posts: 2
- Joined: Wed May 23, 2018 5:03 am
- Contact:
Is there a way to check if two circuit signals are the same?
I'm attempting to make a needlessly complex train system, and part of it requires being able to tell if two wires are carrying the same signal, or at least being able to tell if they use the same symbol/icon.
For example, I have a red wire carrying the signal A=1, and a green wire carrying the signal B=1. I know how to check that the values are the same, by simply passing them through a combinator to check if A = B. What I need is a way to tell whether the two wires are carrying the same signal. In this case, that would be false, as one is A and one is B.
I know this gets more complex with wires carrying multiple values, but my use case should only ever deal with wires carrying one signal.
Is this at all possible in Factorio?
For example, I have a red wire carrying the signal A=1, and a green wire carrying the signal B=1. I know how to check that the values are the same, by simply passing them through a combinator to check if A = B. What I need is a way to tell whether the two wires are carrying the same signal. In this case, that would be false, as one is A and one is B.
I know this gets more complex with wires carrying multiple values, but my use case should only ever deal with wires carrying one signal.
Is this at all possible in Factorio?
Re: Is there a way to check if two circuit signals are the same?
Put a decider combinator on each network: Each ≠ 0 → Each = 1
Use that as input for a third decider combinator: Each = 2 → S = 1
S will contain the number of matching signals.
There is also a way to test for identical signals (same icon and value).
Use an arithmetic combinator to make network #1 negative: Each * -1 → Each
Feed the arithmetic combinator result and network #2 into a decider combinator: Everything = 0 → S = 1
If you don't want two empty networks to match, use a third decider combinator to test network #2: Anything ≠ 0 → S = 1
Connect the two decider combinator results together, if S = 2 then they are identical.
Use that as input for a third decider combinator: Each = 2 → S = 1
S will contain the number of matching signals.
There is also a way to test for identical signals (same icon and value).
Use an arithmetic combinator to make network #1 negative: Each * -1 → Each
Feed the arithmetic combinator result and network #2 into a decider combinator: Everything = 0 → S = 1
If you don't want two empty networks to match, use a third decider combinator to test network #2: Anything ≠ 0 → S = 1
Connect the two decider combinator results together, if S = 2 then they are identical.
Last edited by DaveMcW on Wed May 23, 2018 5:59 am, edited 1 time in total.
Re: Is there a way to check if two circuit signals are the same?
Easy.fishercat5 wrote:Is this at all possible in Factorio?
Connect first network to arithmetic combinator A, which is set to Each * 1 = Each. It essentially copies the signals from first network without contaminating it.
Connect second network to arithmetic combinator B, which is set to Each * -1 = Each. This one does the same with second network, but inverts the values.
Connect outputs of both combinators and route them to a decider combinator, which is set to IF Any != 0 THEN 1.
This will check the equality of any signal or any combination of signals in two networks.
-
- Fast Inserter
- Posts: 208
- Joined: Tue Apr 24, 2018 5:42 am
- Contact:
Re: Is there a way to check if two circuit signals are the same?
Won't work.
To illustrate the problem -
Imagine a red wire with 1 copper plate and a green wire with 1 iron plate.
Combinator A = 1 Copper Plate.
Combinator B = -1 Iron Plate.
IF Any != 0 THEN 1 outputs 1.
The stated goal is false
To illustrate the problem -
Imagine a red wire with 1 copper plate and a green wire with 1 iron plate.
Combinator A = 1 Copper Plate.
Combinator B = -1 Iron Plate.
IF Any != 0 THEN 1 outputs 1.
The stated goal is false
Last edited by ColonelSandersLite on Wed May 23, 2018 8:27 pm, edited 3 times in total.
-
- Fast Inserter
- Posts: 208
- Joined: Tue Apr 24, 2018 5:42 am
- Contact:
Re: Is there a way to check if two circuit signals are the same?
Here's a way. Suppose you want to know if both wires carry a value for A.fishercat5 wrote:For example, I have a red wire carrying the signal A=1, and a green wire carrying the signal B=1. I know how to check that the values are the same, by simply passing them through a combinator to check if A = B. What I need is a way to tell whether the two wires are carrying the same signal. In this case, that would be false, as one is A and one is B.
I know this gets more complex with wires carrying multiple values, but my use case should only ever deal with wires carrying one signal.
Is this at all possible in Factorio?
Connect the red wire to a decider.
If A != 0 Output 1 Green
Connect the green wire to a decider.
If A != 0 Output 1 Green
Connect both deciders to a third decider.
If Green > 1
If it returns true, both wires have a value for A.
Edit: Some bad info was cut.
Edited again:
I need to stop trying to post accurate information when I should be in bed.
Last edited by ColonelSandersLite on Thu May 24, 2018 5:20 am, edited 1 time in total.
Re: Is there a way to check if two circuit signals are the same?
I don't understand you. Output of 1 indicates the network signals are not equal. Which they aren't in your example.ColonelSandersLite wrote:Won't work.
To illustrate the problem -
Imagine a red wire with 1 copper plate and a green wire with 1 iron plate.
Combinator A = 1 Copper Plate.
Combinator B = -1 Iron Plate.
IF Any != 0 THEN 1 outputs 1.
The stated goal is false
-
- Fast Inserter
- Posts: 208
- Joined: Tue Apr 24, 2018 5:42 am
- Contact:
Re: Is there a way to check if two circuit signals are the same?
Edit: Oh, I see, let me rephrase.
Try this on for size then.
Imagine. Network A has 1 iron plate. Network b has 1 iron plate and one copper plate.
Since both networks have an iron plate signal, the desired output is true. Your method would return false.
Edit 2:
Another situation that would return undesired results:
Network A has 1 iron plate. Network b has 2 iron plates.
Since both networks have iron plates, the desired output is true. Your method, again, returns false.
Try this on for size then.
Imagine. Network A has 1 iron plate. Network b has 1 iron plate and one copper plate.
Since both networks have an iron plate signal, the desired output is true. Your method would return false.
Edit 2:
Another situation that would return undesired results:
Network A has 1 iron plate. Network b has 2 iron plates.
Since both networks have iron plates, the desired output is true. Your method, again, returns false.
Re: Is there a way to check if two circuit signals are the same?
Methinks we're solving two very different tasks. Perhaps OP's clarification is necessary for what "the two wires are carrying the same signal" actually means. Full match of all values, or match of any single value among multiples, or match of one specific value. The last option is pretty trivial and can be easily resolved by translating the signal from one resource to another.ColonelSandersLite wrote:Network A has 1 iron plate. Network b has 1 iron plate and one copper plate.
Since both networks have an iron plate signal, the desired output is true.
Re: Is there a way to check if two circuit signals are the same?
this?
Constant combinators are input simulators, send signals with value 1
If incoming signals are actual amounts, convert them to 1 first.
Output: Duplicate signals onlyConstant combinators are input simulators, send signals with value 1
If incoming signals are actual amounts, convert them to 1 first.
-
- Fast Inserter
- Posts: 231
- Joined: Fri Jan 05, 2018 8:47 pm
- Contact:
Re: Is there a way to check if two circuit signals are the same?
Yes. Check the first reply. It's the same suggestion. I don't know why this topic keeps going when the problem was solved with the first post.disentius wrote:this?
Re: Is there a way to check if two circuit signals are the same?
Cranky, aren't we?
I put a picture in for clarity, and forgot to mention it was an illustration to the first answer.
I put a picture in for clarity, and forgot to mention it was an illustration to the first answer.