[2.0.11] Train pathfinding takes much longer path

We are aware of them, but they have low priority. We have more important things to do. They go here in order not to take space in the main bug thread list.
mirpa
Burner Inserter
Burner Inserter
Posts: 5
Joined: Fri Sep 09, 2022 3:25 am
Contact:

[2.0.11] Train pathfinding takes much longer path

Post 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.
Attachments
Edit: Adding signals moves incriminated spot.
Edit: Adding signals moves incriminated spot.
20241029013420_1.jpg (261.31 KiB) Viewed 741 times
20241029013415_1.jpg
20241029013415_1.jpg (253.39 KiB) Viewed 741 times
Edit: Or creates additional one.
Edit: Or creates additional one.
20241029013404_1.jpg (261.24 KiB) Viewed 741 times
Rails are connected, train can get through.
Rails are connected, train can get through.
20241029011558_1.jpg (600.99 KiB) Viewed 749 times
20241029011550_1.jpg
20241029011550_1.jpg (210.99 KiB) Viewed 749 times
20241029011548_1.jpg
20241029011548_1.jpg (219.95 KiB) Viewed 749 times
20241029011521_1.jpg
20241029011521_1.jpg (218.96 KiB) Viewed 749 times
20241029011517_1.jpg
20241029011517_1.jpg (212.55 KiB) Viewed 749 times
This is where I discovered the bug in my gameplay. I used same rail layout in the editor (middle bottom section).
This is where I discovered the bug in my gameplay. I used same rail layout in the editor (middle bottom section).
20241029005516_1.jpg (379.96 KiB) Viewed 749 times
PathingBug.zip
(2.02 MiB) Downloaded 11 times
SteelGiant
Long Handed Inserter
Long Handed Inserter
Posts: 50
Joined: Thu Sep 11, 2014 12:14 pm
Contact:

Re: [2.0.11] Train pathfinding takes much longer path

Post 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.
Attachments
SASP.zip
(19.72 MiB) Downloaded 16 times
TrainPathShort.png
TrainPathShort.png (142.22 KiB) Viewed 645 times
TrainPathManual.png
TrainPathManual.png (2.4 MiB) Viewed 645 times
TrainPathLong.png
TrainPathLong.png (147.38 KiB) Viewed 645 times
TrainPathChunks.png
TrainPathChunks.png (2.89 MiB) Viewed 645 times
User avatar
BraveCaperCat
Filter Inserter
Filter Inserter
Posts: 304
Joined: Mon Jan 15, 2024 10:10 pm
Contact:

Re: [2.0.11] Train pathfinding takes much longer path

Post 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.
Creator of multiple mods, including Quality Assurance - My most popular one. Expect multiple modding-related questions, answers and other posts.
SteelGiant
Long Handed Inserter
Long Handed Inserter
Posts: 50
Joined: Thu Sep 11, 2014 12:14 pm
Contact:

Re: [2.0.11] Train pathfinding takes much longer path

Post 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.
SteelGiant
Long Handed Inserter
Long Handed Inserter
Posts: 50
Joined: Thu Sep 11, 2014 12:14 pm
Contact:

Re: [2.0.11] Train pathfinding takes much longer path

Post 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.
jagholin
Inserter
Inserter
Posts: 32
Joined: Mon Jan 06, 2020 7:19 pm
Contact:

Re: [2.0.11] Train pathfinding takes much longer path

Post 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.
robot256
Filter Inserter
Filter Inserter
Posts: 938
Joined: Sun Mar 17, 2019 1:52 am
Contact:

Re: [2.0.11] Train pathfinding takes much longer path

Post 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.
User avatar
BraveCaperCat
Filter Inserter
Filter Inserter
Posts: 304
Joined: Mon Jan 15, 2024 10:10 pm
Contact:

Re: [2.0.11] Train pathfinding takes much longer path

Post 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.
Creator of multiple mods, including Quality Assurance - My most popular one. Expect multiple modding-related questions, answers and other posts.
SteelGiant
Long Handed Inserter
Long Handed Inserter
Posts: 50
Joined: Thu Sep 11, 2014 12:14 pm
Contact:

Re: [2.0.11] Train pathfinding takes much longer path

Post 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.
SteelGiant
Long Handed Inserter
Long Handed Inserter
Posts: 50
Joined: Thu Sep 11, 2014 12:14 pm
Contact:

Re: [2.0.11] Train pathfinding takes much longer path

Post 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?
robot256
Filter Inserter
Filter Inserter
Posts: 938
Joined: Sun Mar 17, 2019 1:52 am
Contact:

Re: [2.0.11] Train pathfinding takes much longer path

Post 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.
Rseding91
Factorio Staff
Factorio Staff
Posts: 14360
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [2.0.11] Train pathfinding takes much longer path

Post by Rseding91 »

Thanks for the report. This is an edge case in the path-finding logic that has no nice solution.
If you want to get ahold of me I'm almost always on Discord.
User avatar
BlueTemplar
Smart Inserter
Smart Inserter
Posts: 3210
Joined: Fri Jun 08, 2018 2:16 pm
Contact:

Re: [2.0.11] Train pathfinding takes much longer path

Post by BlueTemplar »

I have a 'worse' example :
two-steps_no_path.png
two-steps_no_path.png (246.42 KiB) Viewed 496 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)).
BobDiggity (mod-scenario-pack)
robot256
Filter Inserter
Filter Inserter
Posts: 938
Joined: Sun Mar 17, 2019 1:52 am
Contact:

Re: [2.0.11] Train pathfinding takes much longer path

Post 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.
User avatar
BlueTemplar
Smart Inserter
Smart Inserter
Posts: 3210
Joined: Fri Jun 08, 2018 2:16 pm
Contact:

Re: [2.0.11] Train pathfinding takes much longer path

Post by BlueTemplar »

Why not ?
And what schedule entry, we're (mostly) not talking about automated schedules here, but about temporary train stops.
BobDiggity (mod-scenario-pack)
Kyralessa
Filter Inserter
Filter Inserter
Posts: 576
Joined: Thu Sep 29, 2016 5:58 pm
Contact:

Re: [2.0.11] Train pathfinding takes much longer path

Post 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.
User avatar
BlueTemplar
Smart Inserter
Smart Inserter
Posts: 3210
Joined: Fri Jun 08, 2018 2:16 pm
Contact:

Re: [2.0.11] Train pathfinding takes much longer path

Post 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.
BobDiggity (mod-scenario-pack)
robot256
Filter Inserter
Filter Inserter
Posts: 938
Joined: Sun Mar 17, 2019 1:52 am
Contact:

Re: [2.0.11] Train pathfinding takes much longer path

Post 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.
Kyralessa
Filter Inserter
Filter Inserter
Posts: 576
Joined: Thu Sep 29, 2016 5:58 pm
Contact:

Re: [2.0.11] Train pathfinding takes much longer path

Post 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.
User avatar
BlueTemplar
Smart Inserter
Smart Inserter
Posts: 3210
Joined: Fri Jun 08, 2018 2:16 pm
Contact:

Re: [2.0.11] Train pathfinding takes much longer path

Post 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» ?)
BobDiggity (mod-scenario-pack)
Post Reply

Return to “Minor issues”