Find the intersection of two signals (or chests items)

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.
Post Reply
mboxdk
Burner Inserter
Burner Inserter
Posts: 12
Joined: Wed Dec 28, 2022 7:27 pm
Contact:

Find the intersection of two signals (or chests items)

Post by mboxdk »

This blueprint allows you to show the number of items in the first chest, but only from those that are available in the second chest.
The number of actual uses in the game is large :D
Capture.PNG
Capture.PNG (405.71 KiB) Viewed 1657 times


s.PNG
s.PNG (2.19 MiB) Viewed 1657 times
Last edited by mboxdk on Tue Jan 24, 2023 11:58 pm, edited 1 time in total.
Senior Combinator Developer :lol:

mboxdk
Burner Inserter
Burner Inserter
Posts: 12
Joined: Wed Dec 28, 2022 7:27 pm
Contact:

Re: Find the intersection of two signals (or chests items)

Post by mboxdk »

A bit different version that returns "item -1" if such item exists in the second chest but not exists in the first chest. By chests I mean signals.
Capture.PNG
Capture.PNG (447.27 KiB) Viewed 1633 times
Last edited by mboxdk on Tue Jan 24, 2023 11:58 pm, edited 1 time in total.
Senior Combinator Developer :lol:

Tertius
Filter Inserter
Filter Inserter
Posts: 848
Joined: Fri Mar 19, 2021 5:58 pm
Contact:

Re: Find the intersection of two signals (or chests items)

Post by Tertius »

I didn't have a use case yet for the combinator combinations you posted previously, but this kind of filtering is something I actually use. However, my solution is slightly smaller:
screenshot_899h_01m_26s 1.png
screenshot_899h_01m_26s 1.png (109.68 KiB) Viewed 1628 times


Works with bit operations for positive numbers only, because it uses the sign bit for filtering.
If you're sure the filtering input (right constant combinator) isn't arbitrary numbers but 1 for everything you want as output, you can even shave off the bottom right combinator and directly connect to the next that moves the 1 to the sign bit.

Bonus:
If you reverse the condition in the left combinator, you get the items NOT present in the right and don't need the AND combinator.

mboxdk
Burner Inserter
Burner Inserter
Posts: 12
Joined: Wed Dec 28, 2022 7:27 pm
Contact:

Re: Find the intersection of two signals (or chests items)

Post by mboxdk »

Tertius thanks!

Your solution is certainly more elegant, I should think about it, but you should also add additional signal delay combinators to avoid incorrect output with a rapidly changing signal.

I use my blueprints myself, so I see the point in them)) All my blueprints are designed for frequent signal changes.

I'm playing Space Exploration and more complex combinators are needed.
Senior Combinator Developer :lol:

Nidan
Filter Inserter
Filter Inserter
Posts: 254
Joined: Sat Nov 21, 2015 1:40 am
Contact:

Re: Find the intersection of two signals (or chests items)

Post by Nidan »

Here are the blueprints I have for filtering. The first three I found in a blueprint book somewhere, the last two are my adaptions for the filtering signal being boolean (0/1). All use 5 to 7 combinators and 2 ticks.



Shameless plug with the complete blueprint books where I took these from. My adaptions are in the OP, the other blueprint book is in the (currently) second to last post.

Post Reply

Return to “Combinator Creations”