Selector Combinator: Output signals which appear on both input channels

Ideas that are too old (too many things have changed since) and ones which won't be implemented for certain reasons or if there are obviously better suggestions.

Moderator: ickputzdirwech

mochito
Burner Inserter
Burner Inserter
Posts: 5
Joined: Fri Sep 15, 2023 6:00 pm
Contact:

Selector Combinator: Output signals which appear on both input channels

Post by mochito »

TLDR: a mode for selector combinator that outputs the signals which appear on both red and green input channels

Example:

Input:
Red: 20 Iron Plate, 19 Steel Plate, 17 plastic bar
Green: 14 Iron Plate, 10 Copper Plate, 5 plastic bar

Output: 34 Iron Plate, 22 plastic bar

(Optionally output mode could have a setting to output 1 instead of the input count)

Why: I build logistic delivery trains that can supply outposts with arbitrary items. At the receiving station, the inserter must remove the desired items from the train. I do this by using combinators to set the inserter’s filters to the intersection of desired items with items that are in the train. Currently the way I do this requires a lot of combinators that could be obviated by support for this behavior in selector combinators

Here’s how I did this in 1.1
Variables:
train_contents (read from station)
network_needs (abstracting away how this is calculated; assume that as soon as an item is inserted into the chest at the station the needs are updated to reflect this)

Combinators:
# First normalize signals to 1
## normalize train contents
decider_1(train_contents):
IF anything > 0 OUTPUT each = 1

## normalize network needs
decider_2(network_needs):
IF anything > 0 OUTPUT each = 1

# Next, Intersect normalized signals
## Anything appearing on both channels sums to two on the input side
## Anything appearing on one channel inputs as 1
## Subtracting 1 from each signal yields only those signals which appeared on both channels
arithmetic_1(decider_1, decider_2):
each - 1 OUTPUT each

I then route the output of this arithmetic combinator to an inserter with “set filters” enabled

A single selector combinator could replace all three combinators in this example with support for the behavior outlined above. In the relatively tight quarters around an outpost train stop, this is a huge boon.

I’ve also used this design to great effect for supplying multi-item rockets off a sushi belt with 400 unique items in Space Exploration 0.6, where the ability to limit inserters’ filters to the items actually available to them was critical to the effectiveness of the design.
Last edited by mochito on Sun Nov 10, 2024 5:03 pm, edited 1 time in total.
User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 3251
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: Selector Combinator: Output signals which appear on both input channels

Post by boskid »

No. This is solvable using decider combinator "each[R] != 0 AND each[G] != 0 output Each[r+g]"
mochito
Burner Inserter
Burner Inserter
Posts: 5
Joined: Fri Sep 15, 2023 6:00 pm
Contact:

Re: Selector Combinator: Output signals which appear on both input channels

Post by mochito »

You’re totally right, I was still thinking with 1.1 brain!
Post Reply

Return to “Outdated/Not implemented”