Is there a way to check if two circuit signals are the same?

Don't know how to use a machine? Looking for efficient setups? Stuck in a mission?
Post Reply
fishercat5
Manual Inserter
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?

Post by fishercat5 »

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?

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

Re: Is there a way to check if two circuit signals are the same?

Post by DaveMcW »

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.
Last edited by DaveMcW on Wed May 23, 2018 5:59 am, edited 1 time in total.

User avatar
Lav
Filter Inserter
Filter Inserter
Posts: 384
Joined: Mon Mar 27, 2017 10:12 am
Contact:

Re: Is there a way to check if two circuit signals are the same?

Post by Lav »

fishercat5 wrote:Is this at all possible in Factorio?
Easy.

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.

ColonelSandersLite
Fast Inserter
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?

Post by ColonelSandersLite »

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
Last edited by ColonelSandersLite on Wed May 23, 2018 8:27 pm, edited 3 times in total.

ColonelSandersLite
Fast Inserter
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?

Post by ColonelSandersLite »

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?
Here's a way. Suppose you want to know if both wires carry a value for A.

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.

User avatar
Lav
Filter Inserter
Filter Inserter
Posts: 384
Joined: Mon Mar 27, 2017 10:12 am
Contact:

Re: Is there a way to check if two circuit signals are the same?

Post by Lav »

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
I don't understand you. Output of 1 indicates the network signals are not equal. Which they aren't in your example.

ColonelSandersLite
Fast Inserter
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?

Post by ColonelSandersLite »

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.

User avatar
Lav
Filter Inserter
Filter Inserter
Posts: 384
Joined: Mon Mar 27, 2017 10:12 am
Contact:

Re: Is there a way to check if two circuit signals are the same?

Post by Lav »

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.
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.

User avatar
disentius
Filter Inserter
Filter Inserter
Posts: 694
Joined: Fri May 12, 2017 3:17 pm
Contact:

Re: Is there a way to check if two circuit signals are the same?

Post by disentius »

this?
Find duplicates.png
Find duplicates.png (366.62 KiB) Viewed 5299 times
Output: Duplicate signals only
Constant combinators are input simulators, send signals with value 1
If incoming signals are actual amounts, convert them to 1 first.

Hedning1390
Fast Inserter
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?

Post by Hedning1390 »

disentius wrote:this?
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.

User avatar
disentius
Filter Inserter
Filter Inserter
Posts: 694
Joined: Fri May 12, 2017 3:17 pm
Contact:

Re: Is there a way to check if two circuit signals are the same?

Post by disentius »

Cranky, aren't we? :twisted:

I put a picture in for clarity, and forgot to mention it was an illustration to the first answer.

Post Reply

Return to “Gameplay Help”