Highest Signal Combinator Setup

Don't know how to use a machine? Looking for efficient setups? Stuck in a mission?
Post Reply
BraveCaperCat
Long Handed Inserter
Long Handed Inserter
Posts: 50
Joined: Mon Jan 15, 2024 10:10 pm
Contact:

Highest Signal Combinator Setup

Post by BraveCaperCat »

I have say, a power pole with a bunch of different signals, say on the red wire. I want to pass through whichever of those signals on the red wire has greatest value, but without first defining how many signals there are. Is this possible, and if so can i have a blueprint (string) for it?

Qon
Smart Inserter
Smart Inserter
Posts: 2118
Joined: Thu Mar 17, 2016 6:27 am
Contact:

Re: Highest Signal Combinator Setup

Post by Qon »

Qon wrote:
Sun Dec 24, 2023 3:57 pm


The pushbutton is just for resetting, so if you place this in editor mode fully powered it just works without it (once).
The combinators it is wired to are there to isolate the signals, like diodes.
The other missing part for the blueprint in your version was an example input constant combinator, to the left.
Outputs are readable on poles to the right.
  1. The "+" formation on the left do a fast "output max signal" (output visible on leftmost pole). It is pretty fast, like O(log n) in amount of input signals, with like 4 ticks (?) for each iteration, clockless because it is designed to be stable when it outputs max and all signal paths are equal length. It basically calculates averages of all signals and removes the ones below the average. Might fail if the signals combine to get int overflow. I had another massive creation for getting max signal I made before, like slightly more combinators than the entire blueprint I am sending here, now reduced to 7 (or 12 with section (2)).
  2. (1) is wired to a section that takes care of edge case: 2 signals both being equal and max. I think it just does some edge detection to fix issues that would arise otherwise, don't remember more atm. Well it outputs to the 2nd power pole from the left. This part might be skipped for some builds, but is necessary here.
  3. Below those is a memory of what has been sent out, negated so that the combination with the input is annihilation in 0. Once one input is removed the max calculator will find the next highest signal.
  4. 2nd pole connect to the next section which counts how many signals have been received, sets signal to 1 and multiplies by the index number. It also has a memory of what signals have been handled so far so that it only acts on each signal once. If you just input a bunch of signals at once with a constant combinator the it will pick out once at a time with [anything] selector, so this part can be used separately to just get some "index" for a bunch of signals. Useful if you want to assign a unique number to each signal possible in the game or something, just send in all signals with any value and they each get a unique incremented value at the output, the rightmost poles (one pole with reverse order). This part uses a 4 tick clock to assign numbers sequentially.
    Since this thing here now receives signals sequentially from the max selector (1 & 2) it will assign IDs starting with 1 for the highest etc. And the [MAX_ID + 1 - ID] pole has the highest signal as highest ID.
I wrote this in a pm before. The blueprint also makes indexes for the signals, but you can cut that part out. And I wrote a bit more on how it works in a follow up mesage that I could share if someone cares enough to ask.

mmmPI
Smart Inserter
Smart Inserter
Posts: 2747
Joined: Mon Jun 20, 2016 6:10 pm
Contact:

Re: Highest Signal Combinator Setup

Post by mmmPI »

That blueprint is high tech ! The explanations were helpul to me but i was already familiar with circuits. If you are after something simpler, it is possible that more explanations on the use case would allow some simpler blueprints by slighlty altering the initial demand. " what was the purpose ?" rather than the function may gives different answers maybe easier to implement if such logic is needed at every train stop or something.

BraveCaperCat
Long Handed Inserter
Long Handed Inserter
Posts: 50
Joined: Mon Jan 15, 2024 10:10 pm
Contact:

Re: Highest Signal Combinator Setup

Post by BraveCaperCat »

Qon wrote:
Fri Feb 09, 2024 9:06 am
Qon wrote:
Sun Dec 24, 2023 3:57 pm


The pushbutton is just for resetting, so if you place this in editor mode fully powered it just works without it (once).
The combinators it is wired to are there to isolate the signals, like diodes.
The other missing part for the blueprint in your version was an example input constant combinator, to the left.
Outputs are readable on poles to the right.
  1. The "+" formation on the left do a fast "output max signal" (output visible on leftmost pole). It is pretty fast, like O(log n) in amount of input signals, with like 4 ticks (?) for each iteration, clockless because it is designed to be stable when it outputs max and all signal paths are equal length. It basically calculates averages of all signals and removes the ones below the average. Might fail if the signals combine to get int overflow. I had another massive creation for getting max signal I made before, like slightly more combinators than the entire blueprint I am sending here, now reduced to 7 (or 12 with section (2)).
  2. (1) is wired to a section that takes care of edge case: 2 signals both being equal and max. I think it just does some edge detection to fix issues that would arise otherwise, don't remember more atm. Well it outputs to the 2nd power pole from the left. This part might be skipped for some builds, but is necessary here.
  3. Below those is a memory of what has been sent out, negated so that the combination with the input is annihilation in 0. Once one input is removed the max calculator will find the next highest signal.
  4. 2nd pole connect to the next section which counts how many signals have been received, sets signal to 1 and multiplies by the index number. It also has a memory of what signals have been handled so far so that it only acts on each signal once. If you just input a bunch of signals at once with a constant combinator the it will pick out once at a time with [anything] selector, so this part can be used separately to just get some "index" for a bunch of signals. Useful if you want to assign a unique number to each signal possible in the game or something, just send in all signals with any value and they each get a unique incremented value at the output, the rightmost poles (one pole with reverse order). This part uses a 4 tick clock to assign numbers sequentially.
    Since this thing here now receives signals sequentially from the max selector (1 & 2) it will assign IDs starting with 1 for the highest etc. And the [MAX_ID + 1 - ID] pole has the highest signal as highest ID.
I wrote this in a pm before. The blueprint also makes indexes for the signals, but you can cut that part out. And I wrote a bit more on how it works in a follow up mesage that I could share if someone cares enough to ask.
It doesn't really want to work the way i want it to. When a signal which was previously being sent stops being sent, the negative of that signal stays in the input. And that still says it is the greatest signal.

mmmPI
Smart Inserter
Smart Inserter
Posts: 2747
Joined: Mon Jun 20, 2016 6:10 pm
Contact:

Re: Highest Signal Combinator Setup

Post by mmmPI »

have you pressed the reset button ? or automate the reseting ? Otherwise it will only work once.

Qon
Smart Inserter
Smart Inserter
Posts: 2118
Joined: Thu Mar 17, 2016 6:27 am
Contact:

Re: Highest Signal Combinator Setup

Post by Qon »

BraveCaperCat wrote:
Fri Feb 09, 2024 10:01 am
It doesn't really want to work the way i want it to. When a signal which was previously being sent stops being sent, the negative of that signal stays in the input. And that still says it is the greatest signal.
The largest signal finding part just updates it's output from input without memory. The input just needs to be stable long enough for the max to be calculated and stabilize as well. If you have the full max finder (the first 2 parts to the left) then it only outputs a max signal and nothing while calculating.

The memory cells are all part of the indexing/sorting process. You didn't ask for that so just remove those parts if you don't want them.

Qon
Smart Inserter
Smart Inserter
Posts: 2118
Joined: Thu Mar 17, 2016 6:27 am
Contact:

Re: Highest Signal Combinator Setup

Post by Qon »

mmmPI wrote:
Fri Feb 09, 2024 10:07 am
have you pressed the reset button ? or automate the reseting ? Otherwise it will only work once.
Resetting is only needed for indexing, not for finding max. At least if you remove the parts not relevant for finding max.

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

Re: Highest Signal Combinator Setup

Post by Tertius »

Almost everything has been done before, this is a possible solution:

https://factorioprints.com/view/-NQHYf_XCsdl_ChkKKMW

BraveCaperCat
Long Handed Inserter
Long Handed Inserter
Posts: 50
Joined: Mon Jan 15, 2024 10:10 pm
Contact:

Re: Highest Signal Combinator Setup

Post by BraveCaperCat »

EVERYONE! I realised that the thing i am making with some modded combinators, well that modded combinator picks the largest signal when there are multiple so i don't actually need this anymore.

Post Reply

Return to “Gameplay Help”