Train Stacker weird behavior

Don't know how to use a machine? Looking for efficient setups? Stuck in a mission?
frayien
Inserter
Inserter
Posts: 25
Joined: Sun Apr 15, 2018 10:34 am
Contact:

Train Stacker weird behavior

Post by frayien »

Hi ! I have a strange issue, sometimes a train will absolutely want to go to a specific slot in the stacker even if another train is already in it, resulting in it being stuck, any idea on what I am doing wrong ?
Image

Yoyobuae
Filter Inserter
Filter Inserter
Posts: 499
Joined: Fri Nov 04, 2016 11:04 pm
Contact:

Re: Train Stacker weird behavior

Post by Yoyobuae »

What I think happens: The next train arrives at the chain signal BEFORE the train entering the stacker has fully entered the respective slot. So the train trying to enter the stacker sees the chain signal as RED. The train DOES NOT repath because all paths are equally blocked.

Fix: Make sure that the next train does not try to enter the stacker before the previous train has already entered it's stacker slot fully. You can achieve this by redesigning the rails and/or signals to allow for more spacing (and thus more time for acceleration).

Alternate fix using circuit network: Place a rail signal right before the chain signal. Make the rail signal to always be red whenever the chain signal is also red.

User avatar
valneq
Smart Inserter
Smart Inserter
Posts: 1157
Joined: Fri Jul 12, 2019 7:43 am
Contact:

Re: Train Stacker weird behavior

Post by valneq »

I believe that a train waiting at a blue chain signal will repath after some time. Not sure exactly when, but they do eventually.

Yoyobuae
Filter Inserter
Filter Inserter
Posts: 499
Joined: Fri Nov 04, 2016 11:04 pm
Contact:

Re: Train Stacker weird behavior

Post by Yoyobuae »

Wiki says they should repath every 5 seconds which makes it weird for that specific train to be stuck there.

astroshak
Filter Inserter
Filter Inserter
Posts: 614
Joined: Thu May 10, 2018 9:59 am
Contact:

Re: Train Stacker weird behavior

Post by astroshak »

Don’t expect this to fix your issue, but I tend to put Chain Signals at the end of every parking space in a stacker. I then have Rail Signals at the end of where the train parked at the Station will be. This allows me to have multiple Stations fed by the same stacker.

That bit of unasked for advice aside, I got nuthin for your posted problem.

User avatar
valneq
Smart Inserter
Smart Inserter
Posts: 1157
Joined: Fri Jul 12, 2019 7:43 am
Contact:

Re: Train Stacker weird behavior

Post by valneq »

Yoyobuae wrote:
Sun Sep 13, 2020 10:57 pm
Wiki says they should repath every 5 seconds which makes it weird for that specific train to be stuck there.
Information from the wiki could mean the train will repath at the latest after waiting for 30 seconds. Not sure exactly how to read "multiple of 5s" and "multiple of 30s" in this context.

Loewchen
Global Moderator
Global Moderator
Posts: 8596
Joined: Wed Jan 07, 2015 5:53 pm
Contact:

Re: Train Stacker weird behavior

Post by Loewchen »

It will check for validity every 5s and will repath every 30s unless the check fails, I do not know what would invalidate a path though.

Yoyobuae
Filter Inserter
Filter Inserter
Posts: 499
Joined: Fri Nov 04, 2016 11:04 pm
Contact:

Re: Train Stacker weird behavior

Post by Yoyobuae »

valneq wrote:
Mon Sep 14, 2020 1:07 am
Information from the wiki could mean the train will repath at the latest after waiting for 30 seconds. Not sure exactly how to read "multiple of 5s" and "multiple of 30s" in this context.
I don't know what the "If the trains has waited for a multiple of 30 seconds ..." means. I just know that when a train is stopped at a chain signal it will repath every 5 seconds. There' a debug option to show when train repaths and it shows the train repathing every 5 seconds when at a chain signal.

User avatar
disentius
Filter Inserter
Filter Inserter
Posts: 694
Joined: Fri May 12, 2017 3:17 pm
Contact:

Re: Train Stacker weird behavior

Post by disentius »

This one drives everybody crazy:)

Trains choose their path when they leave the source station.

This means that when they arrive at the stacker, the situation is almost always different vs when they left.
The best solution is to make the train repath just before entering the stacker.
Look at the repath events on the wiki, you can force a train to repath in different ways.
An easy one is to add a station just before the stacker, and set the schedule to wait 0 seconds. the train will repath when leaving that station.
[edited for clarity]

frayien
Inserter
Inserter
Posts: 25
Joined: Sun Apr 15, 2018 10:34 am
Contact:

Re: Train Stacker weird behavior

Post by frayien »

Wow so many answers ! Thanks !
According to the wiki the train reevaluate if the path is still valid every 5 seconds and force repath every 30 seconds.
If i understand well the train should recalculate if it is braking to a signal it cant reserve, I have been watching my trains for long and yeah sometimes it recalculates.
Also the issue appends even if all trains are stopped before the new train arrives, so it is not due to a bad timing.
I dont exactly know what it means the trains cant reserve a signal, but I will try to explore this, if it leads nowhere i will just put a dummy train station.

Also I dont understand how I have bean using trains and making stackers for hundreds of hours but I never noticed this behavior ...

Theikkru
Filter Inserter
Filter Inserter
Posts: 402
Joined: Wed Mar 27, 2019 2:18 pm
Contact:

Re: Train Stacker weird behavior

Post by Theikkru »

Important terminology distinction: "repath" only means "revalidate the existing path to make sure it's not broken". That is a very low bar to clear, and does not account for potential delays such as red signals or other trains. "Recalculate", is when the train actually (re)tries to find the fastest path to its destination using the pathfinding algorithm (which always happens once when the train leaves a station).
In the Repath events section of the wiki, it details the conditions under which a "repath" or "revalidation" will occur. Some of these ALSO force the train to do a full "recalculation", which is the only thing that would convince the train to pick a different stacker slot. Unless one of the conditions to force a recalculation is met, the train will keep whatever path it had in mind, even if that path is now longer due to other trains.

In this stacker example, it's actually the opposite of what some people have suggested. The train in the stacker MUST have already fully pulled into the stacker and cleared the chain signal section before the problem train even came within braking distance of the chain signal, because of the following repath triggers:
The train is preparing to stop at a signal (chain or regular) that changes so that the train can now continue. The train is forced to recalculate its path.
The train is braking for a signal (chain or regular) it cant reserve and the train is not inside a chain signal block. The train is forced to recalculate its path.
If either of these had been triggered, the train would have recalculated, and found the other stacker slots preferable.
The key here is to do something that triggers a recalculation, and not just a repath/revalidation. That's why a passthrough train stop at the stacker entrance is the simplest solution: trains can go through a stop at full speed if there are no conditions in the schedule for that stop, and because they always recalculate their path when leaving a station, they will update their path with the latest info about the occupancy state of the stacker.

Another weird workaround would be to simply put down a second train stop with the same name as the destination train stop somewhere. It doesn't even have to be connected:
The train has waited at a chain signal for a multiple of 5 seconds.
If the trains has waited for a multiple of 30 seconds or if multiple train stops with the name of the destination exist, the train is forced to recalculate its path.
Hilariously, getting hit by the train would also do the trick:
The train collides with something that is not a train (like a player). The train is forced to recalculate its path.

User avatar
Impatient
Filter Inserter
Filter Inserter
Posts: 883
Joined: Sun Mar 20, 2016 2:51 am
Contact:

Re: Train Stacker weird behavior

Post by Impatient »

Nice and helpful insights Theikkru.

Theikkru
Filter Inserter
Filter Inserter
Posts: 402
Joined: Wed Mar 27, 2019 2:18 pm
Contact:

Re: Train Stacker weird behavior

Post by Theikkru »

frayien wrote:
Mon Sep 14, 2020 7:26 pm
Also I dont understand how I have bean using trains and making stackers for hundreds of hours but I never noticed this behavior ...
Can you post a save or demo? I'm kind of curious how exactly the train controller got confused like that and I'm having trouble reproducing the problem.
P.S. Just to make sure, are you playing on version 1.0?

User avatar
disentius
Filter Inserter
Filter Inserter
Posts: 694
Joined: Fri May 12, 2017 3:17 pm
Contact:

Re: Train Stacker weird behavior

Post by disentius »

Thanks for the detailed explanation Theikkru:)
The way I read your post implies a Waypoint station (stop with no conditions in the schedule) would work. is this true?

Theikkru
Filter Inserter
Filter Inserter
Posts: 402
Joined: Wed Mar 27, 2019 2:18 pm
Contact:

Re: Train Stacker weird behavior

Post by Theikkru »

I don't see any reason a waypoint station would be different from any other station. Unfortunately I'm unable to reproduce the problem, so I can't confirm it as a solution directly.

frayien
Inserter
Inserter
Posts: 25
Joined: Sun Apr 15, 2018 10:34 am
Contact:

Re: Train Stacker weird behavior

Post by frayien »

Theikkru wrote:
Tue Sep 15, 2020 4:42 am
frayien wrote:
Mon Sep 14, 2020 7:26 pm
Also I dont understand how I have bean using trains and making stackers for hundreds of hours but I never noticed this behavior ...
Can you post a save or demo? I'm kind of curious how exactly the train controller got confused like that and I'm having trouble reproducing the problem.
P.S. Just to make sure, are you playing on version 1.0?
Yes I am playing on 1.0, but what may be important is that I am playing on a server. (linux headless server)

here is a backup : https://www.dropbox.com/s/jx8vwg65szp9v ... e.zip?dl=1

Theikkru
Filter Inserter
Filter Inserter
Posts: 402
Joined: Wed Mar 27, 2019 2:18 pm
Contact:

Re: Train Stacker weird behavior

Post by Theikkru »

Thanks, I was able to reproduce the issue and verify that it is in fact caused by stale pathing info that the train never got triggered to recalculate. This seems like it could be a bug or oversight in the coding for the repathing triggers, so I'm going to crosslink to the bugs forum and see what the devs think.

Crosslink.

Now that I know more about the issue, I've discovered that simply deleting the chain signal also works around the issue. The caveat is that the trains entering the stacker must have enough momentum that their braking point will reach any occupied slot before the train itself passes the entrance to all open slots, but with this specific stacker, and with those cargo-heavy train configurations, the condition is easily met.

Theikkru
Filter Inserter
Filter Inserter
Posts: 402
Joined: Wed Mar 27, 2019 2:18 pm
Contact:

Re: Train Stacker weird behavior

Post by Theikkru »

This behavior is now marked as a bug fixed for 1.1.0.
(Turns out I was a bit off about the root cause.)

frayien
Inserter
Inserter
Posts: 25
Joined: Sun Apr 15, 2018 10:34 am
Contact:

Re: Train Stacker weird behavior

Post by frayien »

I know, i have been reading the bug post you made ! Thank you for the time you took to help me and to ensure the bug was correctly reported and understood !

Mr. Tact
Filter Inserter
Filter Inserter
Posts: 460
Joined: Sat Mar 26, 2016 3:37 pm
Contact:

Re: Train Stacker weird behavior

Post by Mr. Tact »

I don't know if it is still the case, but the problem described here used to be "fixed" by using two regular signals close together and wired together.

Signals:
parking signal.gif
parking signal.gif (69.84 KiB) Viewed 5446 times

First signal:
front signal.gif
front signal.gif (226.95 KiB) Viewed 5446 times

Second signal:
back signal.gif
back signal.gif (179.67 KiB) Viewed 5446 times

Although I have to say, looking at it now, if it does work I don't understand it any longer. Or maybe I messed this one up... ? :mrgreen:
IIRC, the idea is the changing signal forces a recalculation of the route, hence if a train has taken your spot, you will pick a new one.
Professional Curmudgeon since 1988.

Post Reply

Return to “Gameplay Help”