I wish to have a train, when it pulls into a certain stop, set a stop in the schedule using a wildcard for the item which is common in its inventory.
Given the internal evaluation order for wildcards, this requires some basic circuitry, however because I must first read the train contents onto the circuit network to do so, the wildcard always evaluates to whatever comes first in the trains inventory, regardless of downstream circuitry selecting most common item signal.
Concretely
- given a train with inventory of say 100 rails and 50 medium power poles
- stopped at a station with read contents and send to train
- with a selector combinator selecting rails
- and a wildcard interrupt setting wildcard signal
The train always sets medium power poles as the destination
Unless there is some way to filter signal wildcards based on color of attached circuit networks, I'm not sure how to resolve this other than to set the interrupt at a separate station
Wildcard train schedule, set dest to must numerous item in inventory
-
- Manual Inserter
- Posts: 4
- Joined: Wed May 14, 2025 6:56 pm
- Contact:
Re: Wildcard train schedule, set dest to must numerous item in inventory
You might be able to nullify the minor signals by sending negative values.
-
- Manual Inserter
- Posts: 4
- Joined: Wed May 14, 2025 6:56 pm
- Contact:
Re: Wildcard train schedule, set dest to must numerous item in inventory
I tried that, the straighforward approach results in rapidly oscillating signals
Re: Wildcard train schedule, set dest to must numerous item in inventory
Yeah, you would need a memory cell of the signal that resets when the train leaves.
Re: Wildcard train schedule, set dest to must numerous item in inventory
With the most devices connected to the circuit network, all signals "coming out of" the device are ignored by the stuff working inside the device, but this doesn't seem the case with stations. Just with production machines and things like asteroid collectors, where this is crucial for setting recipes and filters and at the same time reading the content of the machine.
So it seems all we need to do is negating every signal except the one with the largest amount to cancel them, so just the signal with the largest amount is still positive. Then use > 0 as interrupt condition.
Example: The decider:
Important: Feed the negative values with a different wire color, so the wire feeding the selector and decider is never polluted with the negative values. The above setup works properly if the largest amount continuously changes while the train is being loaded. You never need to feed back any positive value, since the positive values are already provided by the station itself.
So it seems all we need to do is negating every signal except the one with the largest amount to cancel them, so just the signal with the largest amount is still positive. Then use > 0 as interrupt condition.
Example: The decider:
Important: Feed the negative values with a different wire color, so the wire feeding the selector and decider is never polluted with the negative values. The above setup works properly if the largest amount continuously changes while the train is being loaded. You never need to feed back any positive value, since the positive values are already provided by the station itself.
-
- Manual Inserter
- Posts: 4
- Joined: Wed May 14, 2025 6:56 pm
- Contact:
Re: Wildcard train schedule, set dest to must numerous item in inventory
wow! I don't understand how this works, but thanks for the design
Re: Wildcard train schedule, set dest to must numerous item in inventory
I try to explain.
First, look at the station. It's configured to read train content. This will send it to any wire connected to the station. It's also configure to send any circuit signal to the train, where it can be processed by waiting conditions and interrupts. If you activate both of these settings at the same time, the train will read its own signals, which is the current train cargo.
The one interrupt (called "test") triggers on any circuit signal that's > 0. If there are multiple signals > 0, the game picks the one that comes first in the hardcoded game internal signal order. So if we want the one with the largest amount, we need to make sure this largest is the only signal that's > 0, so it's impossible any other signal is picked.
So our task is to create very high negative numbers for every signal except for the signal with the largest amount. These negative number override any positive amount from the train, so the only signal left positive is our wanted signal.
Look at the selector combinator: it's picking the signal with the highest amount. This is the only signal we want NOT negative, and every other signal we want to make negative.
Then look at the decider combinator. To the green input, we feed the signal from the station. This wire has all signals. To the red input, we feed the signal from the selector, the signal with the largest amount. This wire has only this one signal.
Now look at the two decider conditions. The first one matches all non-null signals from the green wire. This is just matching everything.
The second one matches all signals with zero value from the red wire. It matches every signal except the one with the largest value, because the one with the largest value is non-zero. Both conditions are combined with AND, so the combined result are all signals for which both conditions are true. In our case, it's comparing power poles(green=50) with power poles (red=0), which is both true. And it's comparing rails (green=100) with rails(red=100), which is false, because on red it only matches if they are 0. But they are 100, so this signal isn't matched for the combined condition.
As output, we output EACH with the constant -2147483648. This each outputs all matching signals from the conditions, which were power poles. So the decider outputs power poles=-2147483648. If there were other items on the train, all less than 100, they would also get a -2147483648 here.
So the output of the decider as -2147483648 for every signal that's not the largest amount from the train. We send this signal to the station, and this way the waiting condition/interrupt will see these signals not > 0, so the signal with the largest amount is the only one left.
We send this with red wire to not influence the train content value from green wire - after all, we still need to continuously check if the largest signal changes while the train is being loaded. If we send the back with green wire, all signals except the first largest will get negative and never have a chance to become the largest.
First, look at the station. It's configured to read train content. This will send it to any wire connected to the station. It's also configure to send any circuit signal to the train, where it can be processed by waiting conditions and interrupts. If you activate both of these settings at the same time, the train will read its own signals, which is the current train cargo.
The one interrupt (called "test") triggers on any circuit signal that's > 0. If there are multiple signals > 0, the game picks the one that comes first in the hardcoded game internal signal order. So if we want the one with the largest amount, we need to make sure this largest is the only signal that's > 0, so it's impossible any other signal is picked.
So our task is to create very high negative numbers for every signal except for the signal with the largest amount. These negative number override any positive amount from the train, so the only signal left positive is our wanted signal.
Look at the selector combinator: it's picking the signal with the highest amount. This is the only signal we want NOT negative, and every other signal we want to make negative.
Then look at the decider combinator. To the green input, we feed the signal from the station. This wire has all signals. To the red input, we feed the signal from the selector, the signal with the largest amount. This wire has only this one signal.
Now look at the two decider conditions. The first one matches all non-null signals from the green wire. This is just matching everything.
The second one matches all signals with zero value from the red wire. It matches every signal except the one with the largest value, because the one with the largest value is non-zero. Both conditions are combined with AND, so the combined result are all signals for which both conditions are true. In our case, it's comparing power poles(green=50) with power poles (red=0), which is both true. And it's comparing rails (green=100) with rails(red=100), which is false, because on red it only matches if they are 0. But they are 100, so this signal isn't matched for the combined condition.
As output, we output EACH with the constant -2147483648. This each outputs all matching signals from the conditions, which were power poles. So the decider outputs power poles=-2147483648. If there were other items on the train, all less than 100, they would also get a -2147483648 here.
So the output of the decider as -2147483648 for every signal that's not the largest amount from the train. We send this signal to the station, and this way the waiting condition/interrupt will see these signals not > 0, so the signal with the largest amount is the only one left.
We send this with red wire to not influence the train content value from green wire - after all, we still need to continuously check if the largest signal changes while the train is being loaded. If we send the back with green wire, all signals except the first largest will get negative and never have a chance to become the largest.