Page 1 of 1

[2.0.14] Train Path finding fault.

Posted: Sat Nov 02, 2024 5:33 pm
by KiiWiiWii
Trains leaving the IRON stop will path find with a much longer path inexplicably when a 180 turn is placed seeminlgy irrelevantly further away. Found by KiiWii and kmui.


Re: [2.0.13] Train Path finding fault.

Posted: Sat Nov 02, 2024 6:00 pm
by Loewchen
Post the save please, see 3638.

Re: [2.0.13] Train Path finding fault.

Posted: Sat Nov 02, 2024 6:26 pm
by KiiWiiWii
Save is now in the original post

Re: [2.0.14] Train Path finding fault.

Posted: Mon Nov 04, 2024 12:26 am
by Muche
The issue seems to be that the train stop is in the rail split/intersection. Moving it a step back fixes it.
A minimal blueprint to reproduce it might be:

Re: [2.0.14] Train Path finding fault.

Posted: Wed Nov 06, 2024 1:27 am
by robot256
Confirmed with the minimal reproduction blueprint in 2.0.15. Here's a video:
Untitled video - Made with Clipchamp.mp4
(7.67 MiB) Downloaded 12 times
The train is leaving the station and departing on a curved rail that actually starts before the rail the train stop is on:
Screenshot 2024-11-05 202533.png
Screenshot 2024-11-05 202533.png (1.18 MiB) Viewed 268 times
Placing a train stop on the long path causes the train to pick the shorter path again. I suspect that because of the train stop's position, it is counting as a penalty on the straight route but not the curved route.

There are two possible fixes for this behavior:
1. Make sure the path penalty is not affected by the stop you are in the process of leaving.
2. Make sure the train cannot take a curved path that starts before the rail its station is on.

Re: [2.0.14] Train Path finding fault.

Posted: Mon Nov 11, 2024 1:01 am
by boskid
Hm... in general the trains pathfinder is correct given the existing rules as it selects a path with lower penalty and in this case since split of rails happens exactly 1 rail before the train stop, the train stop only binds to the rail segment that goes straight. When trains pathfinder turns left it simply does not see the train stop, and when trains pathfinder goes straight it is out of initial rail segment (in which case the train stop would be ignored) so the train stop is not ignored.

I have some ideas how i could change the trains penalty rules to account for this case slightly more nicely (by ignoring all train stops that are in the same rail block as the train) but that would create some additional corner cases i am not sure i want to handle (train could be in multiple rail blocks at the same time if its parked at train stop and there are multiple rail signals on sides). Core of this penalty rule is for trains to not go through train stops that are unrelated as this would make them occupied possibly blocking slots for legit trains, however since the train is in the same rail block as the train stop, it is already kind of occupied by the train so there is no value in avoiding that train stop.

For now i will move this to minor issues but i will keep this in mind that it may need to be handled if i see more people struggling about this. In general this train stop is in a place that it would not be buildable when rails are already placed but the train stop does not block placement of rails turning left.