Forbid trains from changing destination

Post your ideas and suggestions how to improve the game.

Moderator: ickputzdirwech

TheBuzzSaw
Burner Inserter
Burner Inserter
Posts: 16
Joined: Fri Sep 08, 2023 4:02 pm
Contact:

Forbid trains from changing destination

Post by TheBuzzSaw »

TL;DR
There needs to be a way to prevent trains from switching destinations (automatically) once a destination has been selected.

What?
If a train is heading toward a train stop with a duplicate name, the train is apparently allowed to switch to a different train stop under the right conditions. Many situations can trigger rerouting, which is usually a good thing. We definitely do not want trains just running into congestion and giving up; they should make the effort to go around the problem and still reach the target. However, switching to a different train stop entirely is a big problem. This should only happen if there is no longer a possible route to that specific train stop... as in the rail was actually destroyed or removed.

If this behavior cannot be altered wholesale, I would very much appreciate a setting on the train or group to mandate that trains commit to one destination.
Why?
I had developed a nice circuit for altering train stop priority: P = 50 - C where C is the number of trains en route. So, if I have three iron drop stations all at priority 50, the moment that a train heads to one of them, that train stop drops to priority 49. So, any subsequent trains will pick one of the other two as their priorities are now higher. My factory finally became big enough and complex enough that I started noticing trains just giving up on their destinations. If trains can switch destinations like this, it completely destroys my entire system for organizing trains. Honestly, I'm no longer certain how to solve this problem knowing this behavior exists. I do not want to return to the crummy old days of creating three distinct trains with distinct schedules all stupidly going to their one assigned dropoff point.
robot256
Smart Inserter
Smart Inserter
Posts: 1332
Joined: Sun Mar 17, 2019 1:52 am
Contact:

Re: Forbid trains from changing destination

Post by robot256 »

AFAIK, trains are not supposed to change destination as long as the path remains valid and the station remains existing with the same name. I wonder if changing the priority signal is having some unintended consequences. If you can, it's worth looking into the exact causes of the destination change. It's also possible there is a timing glitch in your circuit network system, and the priority of "full" stations is being set too high for a few ticks.

FWIW, before train stop priority was a thing in vanilla, we mostly solved this problem using dynamic train limits and a global circuit network. This has the side effect of making sure that if a train does decide to choose a new destination mid route, the "overpopulated" stations have no slots available so they can't be chosen.
My mods: Multiple Unit Train Control, RGB Pipes, Shipping Containers, Rocket Log, Smart Artillery Wagons.
Maintainer of Auto Deconstruct, Cargo Ships, Vehicle Wagon, Honk, Shortwave.
TheBuzzSaw
Burner Inserter
Burner Inserter
Posts: 16
Joined: Fri Sep 08, 2023 4:02 pm
Contact:

Re: Forbid trains from changing destination

Post by TheBuzzSaw »

It's actually pretty easy to reproduce. No circuits required.
Screenshot From 2026-04-06 08-33-08.png
Screenshot From 2026-04-06 08-33-08.png (498.7 KiB) Viewed 223 times
Send the train to a station. It will pick one.
Screenshot From 2026-04-06 08-34-47.png
Screenshot From 2026-04-06 08-34-47.png (21.45 KiB) Viewed 223 times
Remove the cargo wagon blocking the other station. Observe the destination change.
Screenshot From 2026-04-06 08-36-12.png
Screenshot From 2026-04-06 08-36-12.png (21.7 KiB) Viewed 223 times
Now, increase the priority of one of the stations. The train will stubbornly target that station even when the other one is free.

Here is the demo blueprint.

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

Re: Forbid trains from changing destination

Post by mmmPI »

the rules for repathing can be found there : https://wiki.factorio.com/Railway/Train_path_finding , you can also use the debug menu to show "train repathing" it shows some text poping above trains when it occurs, it allows to show when the train repath to the same destination, which would otherwise be unnoticed, if that can help making sense of the rules.
TheBuzzSaw wrote: Mon Apr 06, 2026 2:40 pm Now, increase the priority of one of the stations. The train will stubbornly target that station even when the other one is free.
As far i understand that is the intended purpose of the priority, to "force" a train to go to the highest priority station, no matter if the "others" are available, this is what i think you can use to forbid a train from changing destination.

The logic you have if i'm not mistaken is to try and distribute train evenly to station that could receive them, if you have station A and B that can receive train, you expect the distribution to be A B A B A B when the priority system is rather AAAA BBBB. If you change priority dynamically when a train is en-route, it can and will repath to the new highest priority station if there slots available.

To distribute evenly trains, it's "easier" to have the priority fixed, and you open limit slot in the lower priority one only when the high priority one has a train en route. If you have 2 station A and B, and A has the highest priority, it will have 1 limit slot open, and when this limit train is occupied by a en-route train, you can open a limit slot in the B station, so the next train will go there, then if you open a slot for the A station again, it is possible that the train going to B change destination, UNLESS there is another train that has departed to A, because in such case the limit is full. It prevent the train going to B to steal the newly open slot in high priority A station.

The suggestion to prevent a train from changing destination i feel i read about it several time, specifically related to how the mod LTN function, i thought the priority system was a "solution" for "some cases", but i'm not sure i got the context right.
Check out my latest mod ! It's noisy !
TheBuzzSaw
Burner Inserter
Burner Inserter
Posts: 16
Joined: Fri Sep 08, 2023 4:02 pm
Contact:

Re: Forbid trains from changing destination

Post by TheBuzzSaw »

I appreciate the feedback, but I chose a simple example just to explain the _beginning_ of problems that come from this.
To distribute evenly trains, it's "easier" to have the priority fixed, and you open limit slot in the lower priority one only when the high priority one has a train en route. If you have 2 station A and B, and A has the highest priority, it will have 1 limit slot open, and when this limit train is occupied by a en-route train, you can open a limit slot in the B station, so the next train will go there, then if you open a slot for the A station again, it is possible that the train going to B change destination, UNLESS there is another train that has departed to A, because in such case the limit is full. It prevent the train going to B to steal the newly open slot in high priority A station.
The whole problem with this solution is that you have to now spread some centralized logic across A and B. Meanwhile, if this behavior were adjusted, the train stops remain fully distributed and independent.

I'm debating migrating this "suggestion" to a full on bug report. I simply cannot fathom how the existing behavior is ever desirable. The beauty of my proposed fix is that it lets you set the priority of the next train. Just because stations are named the same doesn't mean they serve the same output/system/factory. Once a train has decided where to go, it's really important that it goes there.
robot256
Smart Inserter
Smart Inserter
Posts: 1332
Joined: Sun Mar 17, 2019 1:52 am
Contact:

Re: Forbid trains from changing destination

Post by robot256 »

It seems the root of your complaint is that changing train limits does not cause trains to seek a new destination (this is distinct from just repathing to the current destination), but changing priorities does cause them to seek a new destination.

If the change you suggest is made, then someone will inevitably complain that their highest priority station is empty while trains are moving to a distant low priority station (which happened to open up first). I think it's interesting to have an option that does allow interrupting trains while they are en route, but also can't deny that it is inconsistent with most other train behaviors. And interrupting trains mid journey can potentially result in them changing destination continuously until they run out of fuel.
My mods: Multiple Unit Train Control, RGB Pipes, Shipping Containers, Rocket Log, Smart Artillery Wagons.
Maintainer of Auto Deconstruct, Cargo Ships, Vehicle Wagon, Honk, Shortwave.
Post Reply

Return to “Ideas and Suggestions”