[1.1.4] Adding manual stops on very long loop causes train to take longer paths

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.
Post Reply
Xalos
Burner Inserter
Burner Inserter
Posts: 10
Joined: Wed Mar 08, 2017 6:03 am
Contact:

[1.1.4] Adding manual stops on very long loop causes train to take longer paths

Post by Xalos »

What did you do?

I have created a very long loop of track around an obstacle, to allow for faster player movement to locations around the obstacle. There is one train and one station along the loop. I then held Ctrl in the train preview to create a manual stop to move somewhere else along the obstacle.

What happened?

For any location along the loop of track, the train turns out of the station in the intuitively wrong direction (i.e. south to go 20 tiles north of the station, and north to go 20 tiles south). This behavior only appears to occur within single track segments.

What did you expect to happen?

I expected the train to take the shortest possible path along the loop.
Attachments
MP 11.zip
Test case demonstrating the manual stop behavior.
(8.71 MiB) Downloaded 89 times
Screenshot 3109.png
Screenshot 3109.png (1.54 MiB) Viewed 1409 times
Screenshot 3110.png
Screenshot 3110.png (2.12 MiB) Viewed 1409 times
Screenshot 3111.png
Screenshot 3111.png (2.13 MiB) Viewed 1409 times

User avatar
5thHorseman
Smart Inserter
Smart Inserter
Posts: 1193
Joined: Fri Jun 10, 2016 11:21 pm
Contact:

Re: [1.1.4] Adding manual stops on very long loop causes train to take longer paths

Post by 5thHorseman »

Hoover your cursor over the other side of the track.

User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 2250
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: [1.1.4] Adding manual stops on very long loop causes train to take longer paths

Post by boskid »

This is known limitation of the trains pathfinder: when counting penalty of last rail segment on the path, it always includes the whole distance of last rail segment. It works properly with regular train stops but because temporary train stops can be in the middle of rail segment (regular ones would split rail segment and bind to one end) this behavior shows up.

In this particular case penalty for the goal is exactly the same for both paths (up and down) because it goes from the start, turns and then counts the whole long segment distance. Reason why it chooses longer path is because of the trains pathfinder heuristic: given 2 nodes (one related to going down and second related to going up), path that goes down is expanded to upper junction (with chain signal on the left and rail signal on the right) while the path going up ends on the lower junction (regular on left, chain on right). Given this setup next node to be checked is one that is for path going down (because its end position is closer to the goal [heuristic]) so it is choosed - it appears that train chooses longer path, but because how penalties are counted, both of those paths have the same penalty.

This issue is minor enough that i am going to move it to "minor issues". You can fix this simply by adding pair of chain signals somewhere on that long section which will break it into 2 segments making one of the path to have higher penalty. I could fix that inside of the pathfinder but it would increase complexity quite a lot (during node expansion i would have to already measure distance to the possible goal, push that solution as a candidate and return that only when pathfinder's base penalty is above that).

Post Reply

Return to “Minor issues”