Page 1 of 2
[2.0.11] Train pathfinding takes much longer path
Posted: Tue Oct 29, 2024 12:25 am
by mirpa
I wanted to add temporary train stop using Ctrl+LeftClick
Train took much longer path, seemingly unable to path through certain spot.
It happens on both sides of incriminated spot. Train can pass through it when driven manually.
I copied incriminated rail spot into map editor to create small save file. Bug happened again, but in slightly different spot.
Edit: Adding some rail signals (on both sides of the rail) moves the incriminated spot and might create new ones.
Re: [2.0.11] Train pathfinding takes much longer path
Posted: Mon Nov 11, 2024 10:09 am
by SteelGiant
Just to add, I have encountered this situation too, while using elevated rails and double headed trains on Fulgora. The rail is a single unsignalled loop of elevated rail with a single double headed train. This is on the latest experimental 2.0.16.
When I drive manually there is no problem getting round the corner.
Attached screenshots show the path chosen being short just before the top of the bend, then going the wrong way to get slightly further, then showing chunk boundaries (if relevant) and finally showing that manually driving round the corner is fine. Save file attached.
Re: [2.0.11] Train pathfinding takes much longer path
Posted: Mon Nov 11, 2024 10:13 am
by BraveCaperCat
A temporary solution for now, is not using double-headed trains on loops of track. Or not using double-headed trains at all.
Re: [2.0.11] Train pathfinding takes much longer path
Posted: Mon Nov 11, 2024 12:27 pm
by SteelGiant
And one follow up test: if I remove the rear train then the train happily paths forward in the expected way. Re-adding the rear facing train and the oddity reappears. I presume this is something to do with the internal representation of loops of rail.
Re: [2.0.11] Train pathfinding takes much longer path
Posted: Mon Nov 11, 2024 12:32 pm
by SteelGiant
BraveCaperCat wrote: ↑Mon Nov 11, 2024 10:13 am
A temporary solution for now, is not using double-headed trains on loops of track. Or not using double-headed trains at all.
I don't think anyone is suggesting that they can't play the game because of this, but this is a rather obviously strange situation that should not be occurring.
I haven't used double headed trains in the past, but was just thinking about experimenting with them on Fulgora, due to the difficulty of getting two parallel rails placed on the islands and shallow oil oceans. This pathing issue makes this solution less attractive, and I don't think that the devs want to force a particular style of railways because of pathing oddities.
Re: [2.0.11] Train pathfinding takes much longer path
Posted: Mon Nov 11, 2024 12:41 pm
by jagholin
This usually indicates a break in the rail or (what I think is happening here) an unpaired signal somewhere, making a section of the rail one-way only. I can't tell that this isn't a bug, but also I don't see all signals in the screenshots to definitely prove one way or the other.
Re: [2.0.11] Train pathfinding takes much longer path
Posted: Mon Nov 11, 2024 12:59 pm
by robot256
I think what might be going on here is that double headed trains on bidirectional or unsignalled track pick a direction arbitrarily, and if they find any path then just go. I don't think they check both directions unless the first one fails.
You normally don't notice this because they are starting from one-way-signalled or dead-end station tracks.
Re: [2.0.11] Train pathfinding takes much longer path
Posted: Mon Nov 11, 2024 3:11 pm
by BraveCaperCat
SteelGiant wrote: ↑Mon Nov 11, 2024 12:32 pm
BraveCaperCat wrote: ↑Mon Nov 11, 2024 10:13 am
A temporary solution for now, is not using double-headed trains on loops of track. Or not using double-headed trains at all.
I don't think anyone is suggesting that they can't play the game because of this, but this is a rather obviously strange situation that should not be occurring.
I haven't used double headed trains in the past, but was just thinking about experimenting with them on Fulgora, due to the difficulty of getting two parallel rails placed on the islands and shallow oil oceans. This pathing issue makes this solution less attractive, and I don't think that the devs want to force a particular style of railways because of pathing oddities.
You can use single-headed trains on "non-loops", by adding a mini-loop on each end of the track (which would be on land anyway) for the train(s) to turn around. Of course, if you want to run multiple trains you will need some extra bits of track in between to allow trains to pass by each other when travelling in opposite directions.
Re: [2.0.11] Train pathfinding takes much longer path
Posted: Mon Nov 11, 2024 4:16 pm
by SteelGiant
jagholin wrote: ↑Mon Nov 11, 2024 12:41 pm
This usually indicates a break in the rail or (what I think is happening here) an unpaired signal somewhere, making a section of the rail one-way only. I can't tell that this isn't a bug, but also I don't see all signals in the screenshots to definitely prove one way or the other.
From my example, neither of these options are possible. The rail has no signals at all anywhere, and there is no break in the rail as shown in the last screenshot with the train manually driving round the bend without issue. Further, taking off the back engine allows the train to path correctly (round that corner and everywhere else), while adding on the second engine again makes it take the long way at the exact same point again. See save if you want to test more hypotheses.
Re: [2.0.11] Train pathfinding takes much longer path
Posted: Mon Nov 11, 2024 4:17 pm
by SteelGiant
robot256 wrote: ↑Mon Nov 11, 2024 12:59 pm
I think what might be going on here is that double headed trains on bidirectional or unsignalled track pick a direction arbitrarily, and if they find any path then just go. I don't think they check both directions unless the first one fails.
You normally don't notice this because they are starting from one-way-signalled or dead-end station tracks.
Hmmm... Is this documented anywhere, and is this intended behaviour by the devs?
Re: [2.0.11] Train pathfinding takes much longer path
Posted: Mon Nov 11, 2024 4:47 pm
by robot256
I looked and couldn't find anything direct. I do know that trains won't change direction at all when they are waiting at a signal, even if that would get them there faster.
Re: [2.0.11] Train pathfinding takes much longer path
Posted: Mon Nov 11, 2024 5:09 pm
by Rseding91
Thanks for the report. This is an edge case in the path-finding logic that has no nice solution.
Re: [2.0.11] Train pathfinding takes much longer path
Posted: Mon Nov 11, 2024 5:28 pm
by BlueTemplar
I have a 'worse' example :
- two-steps_no_path.png (246.42 KiB) Viewed 459 times
The pathfinder is thinking that there's no path from Taw to the northern bridge.
Of course, as you can easily see, you can get there by going to Phyire first and then reverse course.
Two-headed trains are pretty much «second-class citizens» in Factorio, for better (general train performance, especially single-headed) or worse (these kinds of issues, which are sadly more common for new players, and also in Space Age in general (even on Nauvis, without cliff explosives ??),
see also (though I haven't tried this one in 2.0 again yet)).
Re: [2.0.11] Train pathfinding takes much longer path
Posted: Mon Nov 11, 2024 6:18 pm
by robot256
That's a completely different issue and easily solved if you add a station and schedule entry where it can reverse directions. It's not reasonable to expect the pathfinder to figure out where to change directions mid path on its own.
Re: [2.0.11] Train pathfinding takes much longer path
Posted: Mon Nov 11, 2024 6:27 pm
by BlueTemplar
Why not ?
And what schedule entry, we're (mostly) not talking about automated schedules here, but about temporary train stops.
Re: [2.0.11] Train pathfinding takes much longer path
Posted: Mon Nov 11, 2024 6:29 pm
by Kyralessa
BlueTemplar wrote: ↑Mon Nov 11, 2024 6:27 pm
Why not ?
And what schedule entry, we're (mostly) not talking about automated schedules here, but about temporary train stops.
Trains in Factorio have never worked this way. They don't add stations themselves as waypoints, and they don't spontaneously reverse direction.
However, you can add the station to the train schedule yourself with no leaving conditions, and then I think it should work.
Re: [2.0.11] Train pathfinding takes much longer path
Posted: Mon Nov 11, 2024 6:43 pm
by BlueTemplar
Trains in Factorio have never worked this way.
A new player isn't going to know that. They will think there is really an issue with the train/track, or that there's a bug with the pathfinder.
they don't spontaneously reverse direction
seems to be the issue with the original post, that's why I posted mine here.
Re: [2.0.11] Train pathfinding takes much longer path
Posted: Mon Nov 11, 2024 8:13 pm
by robot256
BlueTemplar wrote: ↑Mon Nov 11, 2024 6:43 pm
Trains in Factorio have never worked this way.
A new player isn't going to know that. They will think there is really an issue with the train/track, or that there's a bug with the pathfinder.
Yeah, like a third of the bug reports lately have been first-time posters who don't know how things are supposed to work yet and just assume it's a bug. For some things maybe the tutorials would help if they did them. For others, not much we can do besides increase the volume of posts and videos in the hopes they find them before getting too confused.
Re: [2.0.11] Train pathfinding takes much longer path
Posted: Mon Nov 11, 2024 8:29 pm
by Kyralessa
BlueTemplar wrote: ↑Mon Nov 11, 2024 6:43 pm
Trains in Factorio have never worked this way.
A new player isn't going to know that. They will think there is really an issue with the train/track, or that there's a bug with the pathfinder.
That may be the case, but so what?
A new player plays the game, experiments, finds out what works and what doesn't. Spontaneous train reversal doesn't work.
Re: [2.0.11] Train pathfinding takes much longer path
Posted: Mon Nov 11, 2024 11:08 pm
by BlueTemplar
My point is that there is a bug : there is a possible path, and the pathfinder can't find it (or finds the wrong one in OP's case).
It's just (probably) not one that is worth fixing. (But why needs to be explained to new players.)
(This is probably also why this has been classified in «Minor issues», rather than «Not a bug» ?)