Page 1 of 1

[0.16.51] Train stops slightly in front of station under certain conditions

Posted: Sun Oct 14, 2018 3:09 am
by Seaish
I tried searching for this, but I'm not sure what to call it so it might already be reported.

Image

When a train has a two-stop schedule, or a schedule where all but two stops are disabled, and the second stop is disabled about half a second after the train leaves the first station (depending on acceleration and braking force), the train will stop up to two blocks ahead of the station. This causes two problems: the rear inserter for each car will now be aligned with the car behind the intended car, and fluid pumps will no longer connect. Either of these issues can cause problems depending on your specific train setup.

This happens very infrequently in my actual games, and will cause the first wagon of a train to fill up with fuel. Since it's waiting for empty cargo, it'll get stuck and never leave the station.

I'm on the fence whether to consider this a bug or not. It definitely seems purposefully coded such that the train is able to stop at any place within the two blocks of the station, and is easily fixed with changes to layout or circuit conditions, but it breaks some gameplay assumptions of what trains on automatic will do.

In the attached save, I have set it up so that the train will get stuck every time.

If this functionality is actually intended, I would like to know why. And if this is unintended and isn't going to be changed, I'd be fine with that since it really isn't that big of a problem.

Re: [0.16.51] Train stops slightly in front of station under certain conditions

Posted: Sun Oct 14, 2018 12:47 pm
by disentius
I would assume the train stops because the pathfinder can't find a valid path anymore, since you disabled the train's only destination. So the train stops the moment it tries to recalculate the path.
You can find when and how the path recalculates here. https://wiki.factorio.com/Railway/Train_path_finding

Re: [0.16.51] Train stops slightly in front of station under certain conditions

Posted: Sun Oct 14, 2018 4:10 pm
by Jap2.0
disentius wrote:
Sun Oct 14, 2018 12:47 pm
I would assume the train stops because the pathfinder can't find a valid path anymore, since you disabled the train's only destination. So the train stops the moment it tries to recalculate the path.
You can find when and how the path recalculates here. https://wiki.factorio.com/Railway/Train_path_finding
I would think so as well, but I also thought that in automatic mode cargo would only load/unload while at a station.

Re: [0.16.51] Train stops slightly in front of station under certain conditions

Posted: Sun Oct 14, 2018 4:24 pm
by disentius
Well... You got one:)
Played around with your save, and this behavior only happens if i put the rail signal directly behind staion 1.

Re: [0.16.51] Train stops slightly in front of station under certain conditions

Posted: Sun Oct 14, 2018 4:28 pm
by Seaish
disentius wrote:
Sun Oct 14, 2018 12:47 pm
I would assume the train stops because the pathfinder can't find a valid path anymore, since you disabled the train's only destination.
The train in the example always has its first stop enabled. Only the second stop is disabled.

It stops there because it considers this position as a valid position for this station, which is a problem because it breaks expectations. Under all other circumstances, the train would go all the way around and line up with the stop correctly. As far as I know, this is the only way for a train to stop in such a location (with cargo open) with automatic mode enabled. It would seem to almost all players that train stations are a single point on the rail, but this shows that the station is actually two squares long.

Plus, if it couldn't find a path, it would say "no path" and wouldn't open for cargo, as the last guy said. It's just on a simple loop.

Re: [0.16.51] Train stops slightly in front of station under certain conditions

Posted: Sun Oct 14, 2018 6:57 pm
by disentius
trainstop extends after the station pole, between the signal and the pole, leading to weird behavior.
Made another save to showcase this.
I disable stop2 on a yellow from the first signal after stop1.
Breakdancing train.
train stuc at station after leaving.gif
train stuc at station after leaving.gif (4.41 MiB) Viewed 3135 times




EDIT:
Stop exists on the whole rail segment where the station is attached.

Re: [0.16.51] Train stops slightly in front of station under certain conditions

Posted: Wed Oct 24, 2018 8:02 am
by Seaish
Okay, so I was looking at old stuff from well-known Factorian arrow in my gluteus, and found this video which takes advantage of this behavior:

Grid station for ethereal trains
Circuit details

Basically, with certain circuit work, it allows trains to stop at any point on straight rail with more flexibility than exploiting no-path situations, which is useful for a small number of use cases like this one.

This specific case isn't too good since you can't have signals/more than one train per line, but there could be others.

Re: [0.16.51] Train stops slightly in front of station under certain conditions

Posted: Mon Jan 07, 2019 5:02 am
by Rseding91
Thanks for the report. I'm not sure if there's anything here worth working on. The entire rail that the train stop sits on is a valid location for a train to be stopped at. In the scenario you've described - disabling stations - you force strange things to happen with the train and get strange results.

At the moment the best I can say is: don't do that if you don't want it to happen.