[posila]Train pathfinding fails when there is a station

This subforum contains all the issues which we already resolved.
ToasterGod
Manual Inserter
Manual Inserter
Posts: 4
Joined: Fri Aug 11, 2017 9:33 pm
Contact:

[posila]Train pathfinding fails when there is a station

Post by ToasterGod »

What did you do?
Send a train down a two way track with a fork. One side of the fork is blocked. The other side has a trainstop in the opposite direction the train is traveling.
What happened?
The train fails to go into the empty block with the trainstop.
What did you expect to happen instead? It might be obvious to you, but do it anyway!
I expected the train to enter the empty block.
Gif of bad train pathing.
Gif of bad train pathing.
output.gif (20.59 MiB) Viewed 7212 times
The expected behavior only is achieved when the train stop is removed.
posila
Factorio Staff
Factorio Staff
Posts: 5358
Joined: Thu Jun 11, 2015 1:35 pm
Contact:

Re: Train pathfinding fails when there is a station

Post by posila »

Stations on path have pretty big penalty. The junction is not signaled properly for how you want it to work. You need to put chain signal also before the left turn.
If you provide the save or at least blueprint string of your setup, somebody will point out why exactly it doesn't work.
ToasterGod
Manual Inserter
Manual Inserter
Posts: 4
Joined: Fri Aug 11, 2017 9:33 pm
Contact:

Re: Train pathfinding fails when there is a station

Post by ToasterGod »

Thanks for looking at this so quick!

There are chain signals farther left than shown in the gif. I added a chain signal directly in front of the junction and the behavior didn't change.

Blueprint of surrounding area: https://pastebin.com/Z99vBmDr
Picture with chain signals added
Picture with chain signals added
Screen Shot 2018-02-07 at 5.07.41 PM.png (1.17 MiB) Viewed 7150 times
Ribbon.zip
Save file of map.
(1.28 MiB) Downloaded 162 times
Loewchen
Global Moderator
Global Moderator
Posts: 9253
Joined: Wed Jan 07, 2015 5:53 pm
Contact:

Re: Train pathfinding fails when there is a station

Post by Loewchen »

I say this is doing exactly what it should. You have two paths to the trains destination, if you place an unscheduled stop in the path you prefer it is not going to take that path but the other one.
ToasterGod
Manual Inserter
Manual Inserter
Posts: 4
Joined: Fri Aug 11, 2017 9:33 pm
Contact:

Re: Train pathfinding fails when there is a station

Post by ToasterGod »

I disagree, this behavior shouldn't happen.

This is non ideal behavior because there is an unblocked, properly signaled path for the train to take, yet it will never take it. I agree that it makes sense the train deprioritizes the path with the station on it, but train stations shouldn't block paths permanently.
Rseding91
Factorio Staff
Factorio Staff
Posts: 14318
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Train pathfinding fails when there is a station

Post by Rseding91 »

ToasterGod wrote:... but train stations shouldn't block paths permanently.
They don't. If there's 1 station on path A and 2 on path B it will preference A - it's not blocked - just heavily penalized.
If you want to get ahold of me I'm almost always on Discord.
orzelek
Smart Inserter
Smart Inserter
Posts: 3924
Joined: Fri Apr 03, 2015 10:20 am
Contact:

Re: Train pathfinding fails when there is a station

Post by orzelek »

Rseding91 wrote:
ToasterGod wrote:... but train stations shouldn't block paths permanently.
They don't. If there's 1 station on path A and 2 on path B it will preference A - it's not blocked - just heavily penalized.
It's still very unintuitive. And leads to a pictured situation that looks like a bug - train will chose the path through different train instead of empty free path to it's destination.
It would seem that penalty for stopped train being unable to move is lower then station one? Maybe this could be tweaked?
Loewchen
Global Moderator
Global Moderator
Posts: 9253
Joined: Wed Jan 07, 2015 5:53 pm
Contact:

Re: Train pathfinding fails when there is a station

Post by Loewchen »

orzelek wrote:It's still very unintuitive. And leads to a pictured situation that looks like a bug - train will chose the path through different train instead of empty free path to it's destination.
It would seem that penalty for stopped train being unable to move is lower then station one? Maybe this could be tweaked?
The station penalty has to be higher, if you reduce the penalty to be closer to the another-train-is-in-front-of-me case, you reintroduce the queue jumping behaviour at stations again. Right now one can be sure, that unless you screw up the setup, a train is not going to path through a unscheduled station, and if you really want it to do it after all you can always force it to path through it or equalise the penalty.
posila
Factorio Staff
Factorio Staff
Posts: 5358
Joined: Thu Jun 11, 2015 1:35 pm
Contact:

Re: Train pathfinding fails when there is a station

Post by posila »

I think it might be bug after all. I loaded the save and the junction seems to be signalled properly now. What seems to be problem is that everytime train waiting at signal repaths it resets its ticksWaitingAtSignal counter, so the penalty for path with train waiting on signal will never be large enough to beat train stop penalty. But even if the counter wasn't reset, with the current values it would take over 5 minutes of this deadblock for the train to choose a path with train stop on it. So, either the penatlies need to be tweaked, deablock detection added, or just say we don't care about this kind of setup.
Kovarex was doing some penalty changes the last, so I'll assign this to him to decide how it should be handled.
mrvn
Smart Inserter
Smart Inserter
Posts: 5878
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: [kovarex]Train pathfinding fails when there is a station

Post by mrvn »

Aside from any bug or cost tweaks stations and repathing should have I think this is simply broken by design.

You have a 2 way track that splits into 2 2 way tracks and they have full signals.

So even if everything works as you intend what happens when 2 trains come from the right while a train is coming from the left? Both right trains will drive until they are stopped at the full signals. The can't go further because the train from the left blocks the path. And the train from the left is blocked with no way out too.

I believe you need chain signals all around there and then the deadlock wouldn't happen even with the bad path choice.
kovarex
Factorio Staff
Factorio Staff
Posts: 8207
Joined: Wed Feb 06, 2013 12:00 am
Contact:

Re: Train pathfinding fails when there is a station

Post by kovarex »

Loewchen wrote:
orzelek wrote:It's still very unintuitive. And leads to a pictured situation that looks like a bug - train will chose the path through different train instead of empty free path to it's destination.
It would seem that penalty for stopped train being unable to move is lower then station one? Maybe this could be tweaked?
The station penalty has to be higher, if you reduce the penalty to be closer to the another-train-is-in-front-of-me case, you reintroduce the queue jumping behaviour at stations again. Right now one can be sure, that unless you screw up the setup, a train is not going to path through a unscheduled station, and if you really want it to do it after all you can always force it to path through it or equalise the penalty.
Yes, this is order of magnitude more important than the setup presented in this report.

The fact that train waiting at signal penalty resets is a bug that can be fixed.
orzelek
Smart Inserter
Smart Inserter
Posts: 3924
Joined: Fri Apr 03, 2015 10:20 am
Contact:

Re: Train pathfinding fails when there is a station

Post by orzelek »

kovarex wrote:
Loewchen wrote:
orzelek wrote:It's still very unintuitive. And leads to a pictured situation that looks like a bug - train will chose the path through different train instead of empty free path to it's destination.
It would seem that penalty for stopped train being unable to move is lower then station one? Maybe this could be tweaked?
The station penalty has to be higher, if you reduce the penalty to be closer to the another-train-is-in-front-of-me case, you reintroduce the queue jumping behaviour at stations again. Right now one can be sure, that unless you screw up the setup, a train is not going to path through a unscheduled station, and if you really want it to do it after all you can always force it to path through it or equalise the penalty.
Yes, this is order of magnitude more important than the setup presented in this report.

The fact that train waiting at signal penalty resets is a bug that can be fixed.
I don't think I understand the queue jumping behavior - I might not use big enough train setups to notice it.

If there is no feasible way to fix it then OP might need to use some circuitry contraption to artificially boost up the cost of top track to overcome the station penalty. Or add a fake station there which would work I guess?
mrvn
Smart Inserter
Smart Inserter
Posts: 5878
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: Train pathfinding fails when there is a station

Post by mrvn »

orzelek wrote:
kovarex wrote:
Loewchen wrote:
orzelek wrote:It's still very unintuitive. And leads to a pictured situation that looks like a bug - train will chose the path through different train instead of empty free path to it's destination.
It would seem that penalty for stopped train being unable to move is lower then station one? Maybe this could be tweaked?
The station penalty has to be higher, if you reduce the penalty to be closer to the another-train-is-in-front-of-me case, you reintroduce the queue jumping behaviour at stations again. Right now one can be sure, that unless you screw up the setup, a train is not going to path through a unscheduled station, and if you really want it to do it after all you can always force it to path through it or equalise the penalty.
Yes, this is order of magnitude more important than the setup presented in this report.

The fact that train waiting at signal penalty resets is a bug that can be fixed.
I don't think I understand the queue jumping behavior - I might not use big enough train setups to notice it.

If there is no feasible way to fix it then OP might need to use some circuitry contraption to artificially boost up the cost of top track to overcome the station penalty. Or add a fake station there which would work I guess?
But if you add a station to the top then both top and bottom path are equal cost and trains would path through the real station instead of prefering to go through the fake station (unless you make that cheaper again and then you have a tug of war).


By the way, does a station have a higher cost if a train is headed there? As in if you have 2 paths with a station, one of which has a train comming, will the path finding prefer the other station to path through?
posila
Factorio Staff
Factorio Staff
Posts: 5358
Joined: Thu Jun 11, 2015 1:35 pm
Contact:

Re: [posila]Train pathfinding fails when there is a station

Post by posila »

Thanks for the report.
For 0.16.24 we fixed the penalty of train waiting on signal being reset whenever that train recalculates its path. So this deadlock will resolve itself after some time. But other people are right that you can end up in situation where no train can move in their desired direction.
quyxkh
Smart Inserter
Smart Inserter
Posts: 1031
Joined: Sun May 08, 2016 9:01 am
Contact:

Re: [posila]Train pathfinding fails when there is a station

Post by quyxkh »

Seems to me that allowing a train to plan a path through that block, a normal-signaled block with a station facing the other way is just pushing the deadlock back one step.

As your layout is now, you have a coal train at ~ {9494,1}, scheduled with the stop you're wanting to route through ( at ~{ 4243,1} )..

If your jammed train was allowed to path through the coal station block, the incoming coal train would eventually be in exactly the wrong place and block your jammed train's exit from the station block.

You could avoid _that_ deadlock by chain-signalling the reverse path past the stop, that would allow your jammed train to reserve the path to the next free chain-block exit. If there's a downside to allowing trains to chain-path through a block with an opposite-facing station, I can't see it yet.
Post Reply

Return to “Resolved Problems and Bugs”