stray trains

Don't know how to use a machine? Looking for efficient setups? Stuck in a mission?
someone1337
Fast Inserter
Fast Inserter
Posts: 140
Joined: Wed Apr 26, 2017 11:29 pm
Contact:

stray trains

Post by someone1337 »

I was playing with friends and we built an unloading stop and several outposts.

Stuff works somehow decent, but sometimes trains stray to my player station instead of taking the intersection right to the unloader stations.
And then the trains that go to my home depot get stuck, as the locomotive wont ever leave unless manually ordered to.

We experimented a with the signals, but cannot figure out, why this rarely happens.

Any ideas?
Attachments
mp_znojmo2_game2.zip
(12.17 MiB) Downloaded 120 times
stray.png
stray.png (196.17 KiB) Viewed 7156 times
someone1337
Fast Inserter
Fast Inserter
Posts: 140
Joined: Wed Apr 26, 2017 11:29 pm
Contact:

Re: stray trains

Post by someone1337 »

Just a few minutes later, we got another stray one.

Its the iron plates train. It was following another train and decided to go to the top instead of following the other train to the right.
Attachments
stray2.png
stray2.png (200.55 KiB) Viewed 7153 times
mp_znojmo2_game2_2.zip
(12.23 MiB) Downloaded 115 times
User avatar
Optera
Smart Inserter
Smart Inserter
Posts: 2920
Joined: Sat Jun 11, 2016 6:41 am
Contact:

Re: stray trains

Post by Optera »

You built a nice example showcasing an annoying effect of current train path calculation.
Instead of waiting a few seconds at a signal, trains will take long detours just to keep moving.

In your layout you can try adding more fake stops or a force repath signal so trains are less likely to take that route. However that will only combat symptoms.
vanatteveldt
Filter Inserter
Filter Inserter
Posts: 947
Joined: Wed Nov 25, 2015 11:44 am
Contact:

Re: stray trains

Post by vanatteveldt »

I think Optera's diagnosis is correct.

The reason they like your PAX station so much is that it has a loop so it can be used to turn around, and in most situations it will be empty.

You might be able to tweak the path finder by adding 20 dummy stations on the incoming line, stations supposedly add a pathing penalty.
BenSeidel
Filter Inserter
Filter Inserter
Posts: 590
Joined: Tue Jun 28, 2016 1:44 am
Contact:

Re: stray trains

Post by BenSeidel »

I don't believe the dummy stops will make much of a difference as each stop gives a 2000 distance penalty to any path that goes through it. The existing stop should be the only one required. Considering that the extra distance of the actual path traveled should have been sufficient (by a long shot) to cause it not to path there in the first place, I doubt additional stops will prevent it in the future. I have seen this issue a few times, but never since the train stop penalty was introduced, so it's good to know that it's still happening with even greater apparent pathing distances.

I have always suspected that the distance penalty for occupied blocks was incorrect in its calculation (It's supposed to be (block length * 2)/distance from current position). I think that the distance from current position is calculated to be zero, pushing the pathing penalty for that block through the roof (infinity, go you floating point ops!!)

As any train path must follow the preceding train in all the rail blocks except the right hand turn then any pathing issues must be with that turn. Somehow during the path calculations that right hand turn is being assigned a value > 2300-ish (2000 for the stop, 300-ish for the physical distance). As infinity > 2300, then the behaviour seems to fit.

I have no proof of this though, only that it explains these apparent bizarre behaviours.
someone1337
Fast Inserter
Fast Inserter
Posts: 140
Joined: Wed Apr 26, 2017 11:29 pm
Contact:

Re: stray trains

Post by someone1337 »

What I dont understand: Why was that path chosen as a possibly valid path?

My (nuclear) locomotive was parked there the whole time, its on automatic with a somehow impossible leave condition.
vanatteveldt
Filter Inserter
Filter Inserter
Posts: 947
Joined: Wed Nov 25, 2015 11:44 am
Contact:

Re: stray trains

Post by vanatteveldt »

someone1337 wrote:What I dont understand: Why was that path chosen as a possibly valid path?

My (nuclear) locomotive was parked there the whole time, its on automatic with a somehow impossible leave condition.
The pathing system presumably does not check leave conditions; it just assigns a penalty for an occupied block or station, so it will prefer a short, empty route but might prefer a route with a stopped train on it over a very long detour.

But apparently some of the penalties can use a bit of tweaking :)
BenSeidel
Filter Inserter
Filter Inserter
Posts: 590
Joined: Tue Jun 28, 2016 1:44 am
Contact:

Re: stray trains

Post by BenSeidel »

vanatteveldt wrote:The pathing system presumably does not check leave conditions; it just assigns a penalty for an occupied block or station
The pathing system does assign a penalty for stops occupied by a train over and above the 2000 penalty for the stop and the penalty for the occupied block. I am unsure if that penalty is applied for trains pathing through the stop or if it's only applied for trains going to the stop.
a penalty of 6 * "time left before the train leaves" is applied to trains with any form of wait condition (ie, 30 seconds of inactivity, etc).

That has been confirmed by the developers, the following is based upon my observation of pathing behaviours and an extrapolation of the above formula. I have never seen this confirmed anywhere.

There is also a similar penalty for trains with other leave conditions such as "when empty". The penalty applied is 6 * "duration train has been at the stop".
When a train has both a timer condition and another condition, the lesser of the two is selected.
User avatar
impetus maximus
Smart Inserter
Smart Inserter
Posts: 1299
Joined: Sat Aug 20, 2016 10:07 pm
Contact:

Re: stray trains

Post by impetus maximus »

interesting thread. i have this problem on a friends save which the train network it a bit congested.
trains go through a stacker, followed by an unused passenger train stop to bypass traffic.
vortex1967
Inserter
Inserter
Posts: 40
Joined: Fri Apr 15, 2016 8:48 am
Contact:

Re: stray trains

Post by vortex1967 »

Hi all,

There are no signals at the turn off into your Production Stop and as a consequence until your production
train is fully in position it closes off the actual junction itself into your unloading area.
The other trains also close off the junction until they get past that first signal near the Iron junction.
I think that has the effect of increasing the time that a following train has spent behind and therefore might
be the reason for the unnecessary path finding.

Add signals to the Production Stop turn off and also add signals just after each junction as well so that each junction is freed up sooner for a following train.
To keep trains moving in a timely fashion add a signal between the Production turn off and the Iron turn off just to shorten that distance.
I'd be interested to know if that fixes or reduces the path finding.
Frightning
Filter Inserter
Filter Inserter
Posts: 813
Joined: Fri Apr 29, 2016 5:27 pm
Contact:

Re: stray trains

Post by Frightning »

If your personal stop has more than 1 block that is not part of the connected network (the junctions themselves are part of the main network, as any train passing by will enter those blocks, but obviously stay on the main line), then you can have this problem. I was having a similar issue in my old trainworld with my fuel loading stop. I had designed it so that a train wanting to leave could wait not on the block with the stop before entering the 2-way part of the network, but this caused some other trains come over from time to time because they considered it closer than where they would otherwise wait. If I hadn't made it 2-blocks in size, this probably would never have been an issue. So the solution here is to make sure your player stop is a single block.
aaargha
Filter Inserter
Filter Inserter
Posts: 333
Joined: Wed Dec 07, 2016 8:35 am
Contact:

Re: stray trains

Post by aaargha »

I think this bit from the wiki is relevant here, even if it's a bit old:
Wiki, emphasis mine wrote:When the rail block is occupied by a train -> Add a penalty of 2 * length of the block divided by block distance from the start, so the far away occupied paths don't matter much.
If two trains are both heading to the production area at roughly the same time the second one will see this massive occupied block just after the intersection that is only 0-2 (depending on how they calculate it) blocks away. That penalty is apparently large enough to make the path through the PAX station seem like the better option.

A good way to deal with this is, as others have stated, is to increase the number of blocks in the production area by just adding signals to make the blocks smaller. The smaller blocks reduces the penalty both by decreasing the length of the blocks and by increasing the block distance of each occupied block.
Jap2.0
Smart Inserter
Smart Inserter
Posts: 2372
Joined: Tue Jun 20, 2017 12:02 am
Contact:

Re: stray trains

Post by Jap2.0 »

vanatteveldt wrote:I think Optera's diagnosis is correct.

The reason they like your PAX station so much is that it has a loop so it can be used to turn around, and in most situations it will be empty.

You might be able to tweak the path finder by adding 20 dummy stations on the incoming line, stations supposedly add a pathing penalty.
Is the station penalty in the game now or was that for 0.16?
There are 10 types of people: those who get this joke and those who don't.
Greybeard_LXI
Fast Inserter
Fast Inserter
Posts: 123
Joined: Sun Feb 26, 2017 10:48 pm
Contact:

Re: stray trains

Post by Greybeard_LXI »

Jap2.0 wrote:
Is the station penalty in the game now or was that for 0.16?

That was introduced in 0.15.
Jap2.0
Smart Inserter
Smart Inserter
Posts: 2372
Joined: Tue Jun 20, 2017 12:02 am
Contact:

Re: stray trains

Post by Jap2.0 »

Greybeard_LXI wrote:
Jap2.0 wrote:
Is the station penalty in the game now or was that for 0.16?

That was introduced in 0.15.
Yay, less goofiness :).
There are 10 types of people: those who get this joke and those who don't.
SpeedDaemon
Fast Inserter
Fast Inserter
Posts: 124
Joined: Fri May 22, 2015 3:31 pm
Contact:

Re: stray trains

Post by SpeedDaemon »

I virtually never build "loop" type stations without adding a turn-around before the train stops. No matter how hard you try to prevent it, trains will still try to use stops as a turn-around or bypass, and by giving them a path that avoids getting stuck behind eternally-stopped trains, it avoids most of the problems caused by their path-finding weirdness. With the "wait for empty/full" conditions we have now, not doing this can get trains stuck for hours before they get noticed.
Jap2.0
Smart Inserter
Smart Inserter
Posts: 2372
Joined: Tue Jun 20, 2017 12:02 am
Contact:

Re: stray trains

Post by Jap2.0 »

SpeedDaemon wrote:I virtually never build "loop" type stations without adding a turn-around before the train stops. No matter how hard you try to prevent it, trains will still try to use stops as a turn-around or bypass, and by giving them a path that avoids getting stuck behind eternally-stopped trains, it avoids most of the problems caused by their path-finding weirdness. With the "wait for empty/full" conditions we have now, not doing this can get trains stuck for hours before they get noticed.
:O how did I never think of this.
There are 10 types of people: those who get this joke and those who don't.
vanatteveldt
Filter Inserter
Filter Inserter
Posts: 947
Joined: Wed Nov 25, 2015 11:44 am
Contact:

Re: stray trains

Post by vanatteveldt »

Jap2.0 wrote:
SpeedDaemon wrote:I virtually never build "loop" type stations without adding a turn-around before the train stops. No matter how hard you try to prevent it, trains will still try to use stops as a turn-around or bypass, and by giving them a path that avoids getting stuck behind eternally-stopped trains, it avoids most of the problems caused by their path-finding weirdness. With the "wait for empty/full" conditions we have now, not doing this can get trains stuck for hours before they get noticed.
:O how did I never think of this.
If I work with loop stations I generally have a specific loop only for my PAX station. Since that will always be empty unless I'm there, it can also function as a safe turnaround station.

(but current train routing sucks! The penalty for occupied blocks should be a *lot* lower, and I think the system should refuse routes that are X tiles longer than the shortest route that does not cross other stations...)
User avatar
impetus maximus
Smart Inserter
Smart Inserter
Posts: 1299
Joined: Sat Aug 20, 2016 10:07 pm
Contact:

Re: stray trains

Post by impetus maximus »

in most cases my trains never have to turn around as they can go either direction from all stops.
the problem for me is if i have a station that is between two main lines that enters on one,
and exits on the other. stray trains start 'cutting through'. :x
User avatar
Tongs
Inserter
Inserter
Posts: 31
Joined: Wed Jul 06, 2016 9:22 pm
Contact:

Re: stray trains

Post by Tongs »

This is why double-headed trains with terminus-style train stops are ideal. There is literally no way for a train to path through a train stop that way. The only trains that end up there, belong there.
Post Reply

Return to “Gameplay Help”