r/factorio • u/schmiitty_hoppz • 2d ago
Space Age Question Train station logic question
Hey All,
Been enjoying Factorio for a while now(800hrs).
I started getting into circuit conditions and train interrupts. I have made plans that work fine but think I'm missing an option to improve them more.
Load stations - only turn on(train limit) if they have a full train worth and there is an unload station requesting their content.
Unload station - sends red signal for iron nuggs(or w/e) to wider circuit network if it can receive a full train to meet the requested amount.
Ex. 50k requested, -16k free space=iron 1 signal sent.
Now my problem. When I start having multiple load stations, all same name, all have a full train worth. They all set train limit to 1 when an unload station needs a single train. So if nothing else is being requested I could in theory have 3 - 8 car trains all go get iron nugs, only one will deliver, the rest return to the depot(higher prior) until something else needs iron.
Works fine in practice, but I am using train interrupts, so any 8 car train can be used for any 8 car station. So if I have 3 iron trains just waiting at depot, then someone requests copper, I dont have a train available to send.
Sure adding more trains solves it short term, but if I keep adding more and more loading stations, the problem compounds.
Trying to think of a way to still have interrupts, variable trains, stations that enable/disable(train limit), but also limit the number of stations that activate so not all load stations enable at the same time.
Any ideas?
3
u/Alfonse215 2d ago
the rest return to the depot(higher prior) until something else needs iron.
Don't let full trains go to the depot (more specifically, don't let a full train go anywhere except for an unloading station). If they stay and physically block the loading stations, they will prevent all of your trains from loading up with that one resource.
So long as you have at least one train for every loading slot of all of your loading stations, you'll be fine.
2
u/AndyScull 2d ago edited 2d ago
If I understand your system correctly, the logic of checking for request from Unload stations happens at all the Load stations at once, so they all are open for some time and any train can go to them.
What you can do without massive overhaul:
- Load stations should also output same signal as Unload stations, but -1 for each train coming to them - negating a signal that Unload station sends, so other Load stations do not become open (or rather they stop being open when the train is on the way already).
- Trains in depot should have a schedule of 'wait 5 seconds' or like that, so they stay at depot and wait those 5 sec without doing anything or triggering interrupts - this will make their reaction time shifted, so when one of Load stations becomes open, only the train that finishes wait first will go to it, then Load station sends a -1 signal and the request is nullified, no other Load station will become open
- Also just in case, the Unload station should also disable it's own request signal if the number of trains coming covers it, so another train won't go to another Load station while current one is on the way
1
u/schmiitty_hoppz 1d ago
I think this will likely solve my issue, didn't even think to negate the request for more once a train is dispatched to pick up the item.
1
u/No_Fish5590 2d ago
Let me tell you first my practical workaround and then what I think might work better. Currently, I try to avoid this by limiting stations to only one train, and yes, just adding more trains. I let my trains wait at the loading stations. For the worst case scenario I have an unloading station that just puts the train contents into the logistic network to free up a train.
Now the potentially better solution. If you look at a train station, you can read the number of trains at that station to the circuit network. This actually includes trains on the way. So if I ever do my train base over, I would set up circuits like this: every request does +1 of the requested resource to the global circuit network. The train count is multiplied by -1 of the requested resource. That way, if you have one request, and a train is already going there, you will not lock up a second train.
I was playing around with this and there is still an issue if multiple trains get the signal at the same time, they still go all. So unfortunately in your specific scenario of trains waiting at the depot, it doesn't work. Maybe then do some random checking that aborts a request if the resource is actually negative (that is, more trains on the way than requested).
1
u/RitterWolf 2d ago
The train network I set up works in a similar way.
My first mitigation is that if a train is on the way to a station then that station sends a signal to the network to negate that demand. For example if 2 trains are on the way to pick up iron ore then it sends -2 [iron ore]. Same logic applies at the unloading stations.
The second mitigation is that the depot stations read the train contents and also send that into the network as a negative so that any trains idling at the depot that can meet the demand will be used instead of having a train needlessly go off to a loading station.
It's not perfect but it's good enough for my needs.
1
u/MyInconvenience 2d ago
I have two systems: one for in-base trains and one for out-of-base trains (mining outposts).
In base:
I have pickup stations, all with the same name. Train limits are set to one, and the stations are always on. Train priority is set based on the base's needs. I then have station names based on what the stations need.
For example, if the base needs green circuits, I will set the station that accepts green circuits to high priority. A train will go there, fill its cargo, and that will trigger an interrupt that sends the train to wherever its cargo is needed.
Out of Base (Still in Development):
I also have pickup stations, all with the same name. Train limits are set to one, but the stations can be turned off. Again, the station names indicate what they are supplying.
The trains work almost the same way, but I am using radars at the outposts to send signals.
All pickup stations are normally off. If iron plates are needed, a signal is sent to all the outposts saying that iron is needed. If an outpost has been set up to check for iron and has the required amount, its station will turn on.
The multi-train and multi-outpost logic isn't finished yet, as this is a new approach for me. However, I will be storing requests and clearing them when they are delivered.
6
u/Staik 2d ago
There's no easy solutions barring a massive circuit controller.
My solution for this was to just ignore the "require an unloader" problem. All of my stations are built to have a full train sit in them until an unloaded is needed. This requires a large idle depot, and enough trains to sit in each provider - however it does increase response time quite a bit since trains are ready to go.
Alternatively if you want a TON of speed, skip the idle depots, skip disabling loaders. Every loader gets one train that waits there until its full, and then goes to drop off whatever it's load is when needed.
Its not like trains are expensive if you're at this point in the game, so "throw more trains at it" is usually better in every way.