How to handle train loading with generic wildcard interrupts?

Don't know how to use a machine? Looking for efficient setups? Stuck in a mission?
pylonminer
Manual Inserter
Manual Inserter
Posts: 2
Joined: Sun Feb 02, 2025 5:59 pm
Contact:

How to handle train loading with generic wildcard interrupts?

Post by pylonminer »

All my train stations are named "[item] Pusher" or "[item] Receiver", with circuits to disable the station when it's empty/full. I have train groups that are named "[item] Supplier" to move each item type.

I created a wildcard interrupt that triggers when a train has any items in it so it goes to the matching receiver. Pretty cool!
super simple wildcard interrupt
super simple wildcard interrupt
hascargointerrupt.png (94.56 KiB) Viewed 711 times

That's a slick approach for unloading trains, but loading trains is still a problem. The problem is that when the train is empty, I can't use the wildcard approach, because there's nothing to match. The train won't know what type of item it's supposed to pick up. I can create interrupts for when the train is empty, but then I have to do that for each type of item, which is tedious. I have a whole page of interrupts that look like this, just with different items.
I must have fifty of these of these on Fulgora
I must have fifty of these of these on Fulgora
listofinterrupts.png (12.87 KiB) Viewed 711 times
Each one looks like
example.png
example.png (42.94 KiB) Viewed 711 times

I thought about avoiding the item type in the Pusher stations altogether, so that all supplier train stations would just be "Pusher" instead of "[item] Pusher", and then an empty train would just go to the nearest available Pusher station that isn't full or disabled. That means I'd only need one train type, and it'd work for all items.

That seems like it'd work.... but it creates a load balancing problem. If I'm producing a lot of iron gears and not a lot of superconductors, then eventually, the "[Iron gear] Receiver" stations will fill up, but the "[Iron gear] Pusher" stations will keep producing. Eventually, all the trains will fill up with iron gears, and I won't have any empty trains available to move superconductors, and the factory will grind to a halt.

I thought about doing something with circuits, but it turns out you can't read the name of trains, just an ID, so that doesn't work either.


Is there a simpler way to manage all these interrupts? Wildcards are super cool and it feels like there's gotta be an easier way, since it solves literally half the problem (the unloading) but I can't figure out how to solve loading.
Tertius
Smart Inserter
Smart Inserter
Posts: 1180
Joined: Fri Mar 19, 2021 5:58 pm
Contact:

Re: How to handle train loading with generic wildcard interrupts?

Post by Tertius »

pylonminer wrote: Sun Feb 02, 2025 6:34 pm I thought about avoiding the item type in the Pusher stations altogether, so that all supplier train stations would just be "Pusher" instead of "[item] Pusher", and then an empty train would just go to the nearest available Pusher station that isn't full or disabled. That means I'd only need one train type, and it'd work for all items.
That's how I do it. All loading stations have the same name.

However, I never disable/enable stations. Instead, I'm using static train limits and dynamic priority. And enough trains to fill all stations. If all is running as intended, all stations are occupied with a train and the train is either being loaded or being unloaded. There is a interrupt controlled depot to buffer empty trains, otherwise empty trains could clog the unloading stations.

In this setup, full trains first populate all the unloading stations. All my unloading stations have train limit 2, so there is 1 train currently at the station and a 2nd train either on the way or waiting in front of the station. If one material isn't being consumed, the trains stay and continuously occupy the limit of 2. Trains at the loading stations with the corresponding material stay at the station, so it stays occupied, because trains cannot leave, because there isn't a free slot at the corresponding unloading stations. Since I also have a train limit of 2 for every loading station, there can be at most 2 * loading stations + 2 * unloading stations trains for each material. For example, if you have 1 iron ore unloading station and 3 iron ore loading stations, at most 1 * 2 + 3 * 2 = 8 trains are occupied. No more, since all places where iron ore trains could be present are full. This is guaranteed by the train limits.
So for handling iron ore, you dispatch 8 trains. If you add one more station, you add 2 more trains.
For every other material do the corresponding calculation and add a corresponding amount of trains for these.

If you observe this setup running, you will notice empty trains will go to the nearest loading station, even if it already has 1 train at the station (remember we have a train limit of 2). An empty station more far away stays empty. For this case, I have a small circuit at every loading station. It reads the train reservation at the station. If it is 0, it raises the station priority to 51. If it is > 0, station priority stays at 50. This way empty stations have prio 51, and non-empty stations have prio 50, so trains will first fill the empty loading stations, then fill the 2nd spot in the waiting are in front of the station.
Last edited by Tertius on Sun Feb 02, 2025 8:46 pm, edited 1 time in total.
mergele
Fast Inserter
Fast Inserter
Posts: 204
Joined: Sat Aug 20, 2016 5:45 am
Contact:

Re: How to handle train loading with generic wildcard interrupts?

Post by mergele »

If you add a depot trains go to if no station is available (and they are not at a loading station) you can have a bunch of extra trains prepared and don't need to do exact adjustment every time you build a new station. If you don't see a train in the depot just put down 20 more and forget about it again.
waterBear
Fast Inserter
Fast Inserter
Posts: 101
Joined: Thu Apr 23, 2020 2:05 pm
Contact:

Re: How to handle train loading with generic wildcard interrupts?

Post by waterBear »

Renaming all stations to pusher is also how I did it. You can see an overview of my approach here: 123723 although at this point I'm almost reluctant to point to it without a rewrite. Folks are finding it confusing.
pylonminer
Manual Inserter
Manual Inserter
Posts: 2
Joined: Sun Feb 02, 2025 5:59 pm
Contact:

Re: How to handle train loading with generic wildcard interrupts?

Post by pylonminer »

mergele wrote: Sun Feb 02, 2025 8:43 pm If you add a depot trains go to if no station is available (and they are not at a loading station) you can have a bunch of extra trains prepared and don't need to do exact adjustment every time you build a new station. If you don't see a train in the depot just put down 20 more and forget about it again.
No, this doesn't work. I already have a waiting zone that trains go to, but the issue is that this provides no backpressure on the stations which produce. So "iron gear" in this case will just eat up any new trains and eventually fill the loading zone with trains full of iron gears, because they have nowhere to go.

Tertius's suggestion of forcing the train to stay at the loading station until the unloading station is ready might work. Right now I have some train stations that block each other because they're in serial (small Fulgora islands) but if I refactor those it might actually work.
mergele
Fast Inserter
Fast Inserter
Posts: 204
Joined: Sat Aug 20, 2016 5:45 am
Contact:

Re: How to handle train loading with generic wildcard interrupts?

Post by mergele »

pylonminer wrote: Sun Feb 02, 2025 9:31 pm
mergele wrote: Sun Feb 02, 2025 8:43 pm If you add a depot trains go to if no station is available (and they are not at a loading station) you can have a bunch of extra trains prepared and don't need to do exact adjustment every time you build a new station. If you don't see a train in the depot just put down 20 more and forget about it again.
No, this doesn't work. I already have a waiting zone that trains go to, but the issue is that this provides no backpressure on the stations which produce. So "iron gear" in this case will just eat up any new trains and eventually fill the loading zone with trains full of iron gears, because they have nowhere to go.

Tertius's suggestion of forcing the train to stay at the loading station until the unloading station is ready might work. Right now I have some train stations that block each other because they're in serial (small Fulgora islands) but if I refactor those it might actually work.
Yeah my comment was meant as a expansion on Tertius system, not a seperate solution.
Shins
Burner Inserter
Burner Inserter
Posts: 18
Joined: Wed Dec 18, 2024 10:32 pm
Contact:

Re: How to handle train loading with generic wildcard interrupts?

Post by Shins »

Sooo, let me give you an idea how to handle loading only these trains, what are necessary.

Let all of your receive station send to the network signal, when they need new train. The value they send should be L-C (L - max. number of trains, C - actual number of train), I like when this is send with - value. Here you have to decide if this station always order 1 train, or you would like to let it order more of them. For example if you decide that when number of Copper is less than 2000 then you set L on this station to 1, and to network you send signal Copper with value -1 (here helpfull are radars, if you connect them to station then all stations connected with radars will be in 1 network).

Then in train station for loading you can use not signakl from cargo, but signal from network and check, if this signal is lower than 0.

When train will go to the loading station, this station should send the same signal with +value, that will make no more trains than you need is send to this type of stations. If you would like to make loading station with more than 1 slot for train and you have also more than 1 station for material then is good to set priority to 100/C, then trains will go to the most empty stations, not to the closest station.

Here we have 1 big disadvantege - your station have to send request for trainnquite early, other way it will wait for material. Here I have an idea that for material I need most I send static negative value to the network, then always in system there are few extra trains with this material.

Important thing - all empty trains have to stay in station with access to network to get new target.
Afroman
Burner Inserter
Burner Inserter
Posts: 17
Joined: Fri Jan 06, 2017 3:28 am
Contact:

Re: How to handle train loading with generic wildcard interrupts?

Post by Afroman »

My solution to this is the interrupt "Circuit condition" option.
And the fact that signals sent to a radar can be read from any radar anywhere(blew my mind my I realised this).

My setup is as follow:
Requester stations:
- Send a green signal into a radar of the resource the request and a value representing how many full trains it will need to be satisfied.
- The stations train limit is set to the value of the signal.

Provider station:
- Send a red signal into a radar of the resource it provides and the value to identify the type of train it needs(I have 1-4-1, 1-4 and fluid). But only if:
- There is a positiv green signal for that resource in the radar(meaning there is a demand).
- There is enough resources at this station to fill 2(configurable) trains.
- The stations train limit is set to 2 if a signal is sent from this station. (To avoid having too many trains booked by one station at once)

Trains then have an loading interrupt stating the following:
- If circuit condition is "wildcard signal" > 0 AND cargo empty
- Go to station "wildcard signal" PROV (All my provider stations are named "iron ore" PROV, "copper plates" PROV and so on) until full.

The problem I face is having a good way to differentiate between the different types of trains. easy enough with two types though.
Post Reply

Return to “Gameplay Help”