stray trains
-
- Fast Inserter
- Posts: 140
- Joined: Wed Apr 26, 2017 11:29 pm
- Contact:
stray trains
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?
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 (196.17 KiB) Viewed 7156 times
-
- Fast Inserter
- Posts: 140
- Joined: Wed Apr 26, 2017 11:29 pm
- Contact:
Re: stray trains
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.
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 (200.55 KiB) Viewed 7153 times
-
- mp_znojmo2_game2_2.zip
- (12.23 MiB) Downloaded 115 times
Re: stray trains
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.
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.
My Mods: mods.factorio.com
-
- Filter Inserter
- Posts: 947
- Joined: Wed Nov 25, 2015 11:44 am
- Contact:
Re: stray trains
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.
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.
Re: stray trains
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.
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.
-
- Fast Inserter
- Posts: 140
- Joined: Wed Apr 26, 2017 11:29 pm
- Contact:
Re: stray trains
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.
My (nuclear) locomotive was parked there the whole time, its on automatic with a somehow impossible leave condition.
-
- Filter Inserter
- Posts: 947
- Joined: Wed Nov 25, 2015 11:44 am
- Contact:
Re: stray trains
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.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.
But apparently some of the penalties can use a bit of tweaking
Re: stray trains
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.vanatteveldt wrote:The pathing system presumably does not check leave conditions; it just assigns a penalty for an occupied block or station
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.
- impetus maximus
- Smart Inserter
- Posts: 1299
- Joined: Sat Aug 20, 2016 10:07 pm
- Contact:
Re: stray trains
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.
trains go through a stacker, followed by an unused passenger train stop to bypass traffic.
-
- Inserter
- Posts: 40
- Joined: Fri Apr 15, 2016 8:48 am
- Contact:
Re: stray trains
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.
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.
-
- Filter Inserter
- Posts: 813
- Joined: Fri Apr 29, 2016 5:27 pm
- Contact:
Re: stray trains
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.
Re: stray trains
I think this bit from the wiki is relevant here, even if it's a bit old:
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.
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.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.
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.
Re: stray trains
Is the station penalty in the game now or was that for 0.16?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.
There are 10 types of people: those who get this joke and those who don't.
-
- Fast Inserter
- Posts: 123
- Joined: Sun Feb 26, 2017 10:48 pm
- Contact:
Re: stray trains
Jap2.0 wrote:
Is the station penalty in the game now or was that for 0.16?
That was introduced in 0.15.
Re: stray trains
Yay, less goofiness .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.
There are 10 types of people: those who get this joke and those who don't.
-
- Fast Inserter
- Posts: 124
- Joined: Fri May 22, 2015 3:31 pm
- Contact:
Re: stray trains
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.
Re: stray trains
:O how did I never think of this.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.
There are 10 types of people: those who get this joke and those who don't.
-
- Filter Inserter
- Posts: 947
- Joined: Wed Nov 25, 2015 11:44 am
- Contact:
Re: stray trains
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.Jap2.0 wrote::O how did I never think of this.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.
(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...)
- impetus maximus
- Smart Inserter
- Posts: 1299
- Joined: Sat Aug 20, 2016 10:07 pm
- Contact:
Re: stray trains
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'.
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'.
Re: stray trains
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.