Train deadlock on a single-track line
Moderator: OpenTTD Developers
Train deadlock on a single-track line
Hello. I have a problem with trains on a single-track line. I'm uploading a screenshot and a savegame to demonstrate.
I have the following track setup. There is a line with terminal stations A and B. On this line, there are stations C and D. Each of the stations C and D has two platforms which allow one-way movement (each platform has its own direction), and a passing track, which allows two-way movement. Because there is only one track on the line which connects station A to station B via stations C and D, passing tracks on stations C and D can be used by a train to wait while another train passes from the opposite direction.
And here comes the problem.
Imagine there are two trains, train 1 and train 2. They are standing on stations A and B respectively. Train 1 needs to get to station B, and train 2 needs to get to station A. Both trains pass C and D without stopping (there may be other trains which stop there). When started, the trains will move forward until they reach stations C and D. They will then get stuck on passing tracks of C and D, waiting for each other forever. Each of the trains will try to reach the other station's passing track but will fail to do so because there is another train standing there. They will completely ignore the fact that there are free tracks with platforms on C and D which will allow them to pass.
Note that if I remove one of the track pieces marked with a red circle (on the screenshot), the corresponding train will recognize the platform and pass through it. After removal of the track piece, there are evidently no more ways to get to the other station except through the platform, so the train will go through it.
I know that this is somehow related to the way the pathfinder works. The question is: can this be fixed without changing the track layout? Maybe there is some configuration setting which will allow trains to pass through free platforms when there are no more free ways to pass?
I hope I was clear in describing the issue. Thank you.
I have the following track setup. There is a line with terminal stations A and B. On this line, there are stations C and D. Each of the stations C and D has two platforms which allow one-way movement (each platform has its own direction), and a passing track, which allows two-way movement. Because there is only one track on the line which connects station A to station B via stations C and D, passing tracks on stations C and D can be used by a train to wait while another train passes from the opposite direction.
And here comes the problem.
Imagine there are two trains, train 1 and train 2. They are standing on stations A and B respectively. Train 1 needs to get to station B, and train 2 needs to get to station A. Both trains pass C and D without stopping (there may be other trains which stop there). When started, the trains will move forward until they reach stations C and D. They will then get stuck on passing tracks of C and D, waiting for each other forever. Each of the trains will try to reach the other station's passing track but will fail to do so because there is another train standing there. They will completely ignore the fact that there are free tracks with platforms on C and D which will allow them to pass.
Note that if I remove one of the track pieces marked with a red circle (on the screenshot), the corresponding train will recognize the platform and pass through it. After removal of the track piece, there are evidently no more ways to get to the other station except through the platform, so the train will go through it.
I know that this is somehow related to the way the pathfinder works. The question is: can this be fixed without changing the track layout? Maybe there is some configuration setting which will allow trains to pass through free platforms when there are no more free ways to pass?
I hope I was clear in describing the issue. Thank you.
- Attachments
-
- Safingley Market Transport, 29-е ноя 1950 г..png
- (516.83 KiB) Downloaded 6 times
-
- TrainDeadlock.sav
- (102.66 KiB) Downloaded 126 times
Re: Train deadlock on a single-track line
I was able to duplicate your problem. I was able to resolve it by going into the console and lowering yapf.rail_station_penalty to 499.
Do you like drones, quadcopters & flying toys? Check out Drone Strike Force!

Base Music Sets: OpenMSX | Scott Joplin Anthology | Traditional Winter Holiday Music | Modern Motion Music
Other Projects: 2CC Trams | Modern Waypoints | Sprite Sandbox & NewGRF Releases | Ideabox | Town Names | Isle of Sodor Scenario | Random Sprite Repository
Misc Topics: My Screenshots | Forgotten NewGRFs | Unfinished Graphics Sets | Stats Shack | GarryG's Auz Sets

Base Music Sets: OpenMSX | Scott Joplin Anthology | Traditional Winter Holiday Music | Modern Motion Music
Other Projects: 2CC Trams | Modern Waypoints | Sprite Sandbox & NewGRF Releases | Ideabox | Town Names | Isle of Sodor Scenario | Random Sprite Repository
Misc Topics: My Screenshots | Forgotten NewGRFs | Unfinished Graphics Sets | Stats Shack | GarryG's Auz Sets
Re: Train deadlock on a single-track line
IMHO it's better to have the station spanning over the passing track as well.
With the default penalty of passing through backward PBS, the trains won't abuse your passing track unless the network itself is overcrowded.
With the default penalty of passing through backward PBS, the trains won't abuse your passing track unless the network itself is overcrowded.
Re: Train deadlock on a single-track line
Thanks for the replies. Unfortunately, I wasn't able to solve the problem by lowering yapf.rail_station_penalty (I double checked that the pathfinder being used for trains is actually YAPF). I also don't recall changing pathfinder settings, at least in the past year. I'll post all the lines from my config file which start with yapf for reference.
Real world stations - I'm talking about stations with extended track layouts, not about those which are called "halts" or "flag stops" - usually don't have platforms on every track. Additional tracks can be used for passing, overtaking, performing cargo operations (besides simple loading / unloading - e.g. storing, sorting, etc.) and so on. In OpenTTD these tracks can only be used for passing, and sometimes overtaking (if a train stops at the station but the one behind doesn't); unfortunately, there's (perhaps only for the time being?) no way to do things such as storing series of cars on tracks, or coupling / uncoupling trains dynamically (not in a depot).
Code: Select all
yapf.disable_node_optimization = false
yapf.max_search_nodes = 10000
yapf.rail_firstred_twoway_eol = false
yapf.rail_firstred_penalty = 1000
yapf.rail_firstred_exit_penalty = 10000
yapf.rail_lastred_penalty = 1000
yapf.rail_lastred_exit_penalty = 10000
yapf.rail_station_penalty = 499
yapf.rail_slope_penalty = 200
yapf.rail_curve45_penalty = 100
yapf.rail_curve90_penalty = 600
yapf.rail_depot_reverse_penalty = 5000
yapf.rail_crossing_penalty = 300
yapf.rail_look_ahead_max_signals = 10
yapf.rail_look_ahead_signal_p0 = 500
yapf.rail_look_ahead_signal_p1 = -100
yapf.rail_look_ahead_signal_p2 = 5
yapf.rail_pbs_cross_penalty = 300
yapf.rail_pbs_station_penalty = 800
yapf.rail_pbs_signal_back_penalty = 1500
yapf.rail_doubleslip_penalty = 100
yapf.rail_longer_platform_penalty = 800
yapf.rail_longer_platform_per_tile_penalty = 0
yapf.rail_shorter_platform_penalty = 4000
yapf.rail_shorter_platform_per_tile_penalty = 0
yapf.road_slope_penalty = 200
yapf.road_curve_penalty = 100
yapf.road_crossing_penalty = 300
yapf.road_stop_penalty = 800
yapf.road_stop_occupied_penalty = 800
yapf.road_stop_bay_occupied_penalty = 1500
yapf.maximum_go_to_depot_penalty = 2000
Well, let's say, I'm trying to get a balance between realism and efficiency in my game.siu238X wrote:IMHO it's better to have the station spanning over the passing track as well.
With the default penalty of passing through backward PBS, the trains won't abuse your passing track unless the network itself is overcrowded.
Real world stations - I'm talking about stations with extended track layouts, not about those which are called "halts" or "flag stops" - usually don't have platforms on every track. Additional tracks can be used for passing, overtaking, performing cargo operations (besides simple loading / unloading - e.g. storing, sorting, etc.) and so on. In OpenTTD these tracks can only be used for passing, and sometimes overtaking (if a train stops at the station but the one behind doesn't); unfortunately, there's (perhaps only for the time being?) no way to do things such as storing series of cars on tracks, or coupling / uncoupling trains dynamically (not in a depot).
Re: Train deadlock on a single-track line
changing the value in the config file does not affect your savegame. you must change it from the ingame console instead.
Re: Train deadlock on a single-track line
First I changed it in console and it seemed to have no effect. After that I changed it in config file and started a new game. Still no effect though.
Re: Train deadlock on a single-track line
On the same line as Eddi but i suggest that instead of lowering a pf penalty you increase the penalty of the backwards PBS.
set yapf.rail_pbs_signal_back_penalty 5000
Seems to do the trick. Tried 2x result was "realistic"
In other words either edit in the config file of openttd. start game and start new map to apply setting, or ingame load save press the ~ key next to the 1 above the tab and type yapf.rail_pbs_signal_back_penalty 5000. Return key and close with ~ key.
edit very important: the command is
set yapf.rail_pbs_signal_back_penalty 5000
set yapf.rail_pbs_signal_back_penalty 5000
Seems to do the trick. Tried 2x result was "realistic"
In other words either edit in the config file of openttd. start game and start new map to apply setting, or ingame load save press the ~ key next to the 1 above the tab and type yapf.rail_pbs_signal_back_penalty 5000. Return key and close with ~ key.
edit very important: the command is
set yapf.rail_pbs_signal_back_penalty 5000
Last edited by Vinnie_nl on 23 Jul 2013 07:04, edited 1 time in total.
Re: Train deadlock on a single-track line
Ah, but "realism" would give you a signal box operator who would decide which train goes first and which route it takes!Player701 wrote: Well, let's say, I'm trying to get a balance between realism and efficiency in my game.
.

Re: Train deadlock on a single-track line
I fully understand what you want to simulate when I posted the previous reply.Player701 wrote:Well, let's say, I'm trying to get a balance between realism and efficiency in my game.siu238X wrote:IMHO it's better to have the station spanning over the passing track as well.
With the default penalty of passing through backward PBS, the trains won't abuse your passing track unless the network itself is overcrowded.
Real world stations - I'm talking about stations with extended track layouts, not about those which are called "halts" or "flag stops" - usually don't have platforms on every track. Additional tracks can be used for passing, overtaking, performing cargo operations (besides simple loading / unloading - e.g. storing, sorting, etc.) and so on. In OpenTTD these tracks can only be used for passing, and sometimes overtaking (if a train stops at the station but the one behind doesn't); unfortunately, there's (perhaps only for the time being?) no way to do things such as storing series of cars on tracks, or coupling / uncoupling trains dynamically (not in a depot).
I only suggested putting the tracks under the same roof such that trains don't make stupid mistakes.
The unrealistic-ism, if exists, concerns the train's path-finding rather than any of the "track / station / signal layout" suggested in this post. I don't find it "unrealistic" putting passing tracks under the same roof (many stations in Britain have platforms facing passing tracks, as far as I know)
Dynamic train coupling is probably yearned by most of us. I personally think that brings constructive challenge to the game play, and makes one plan networks better.Player701 wrote: In OpenTTD these tracks can only be used for passing, and sometimes overtaking (if a train stops at the station but the one behind doesn't); unfortunately, there's (perhaps only for the time being?) no way to do things such as storing series of cars on tracks, or coupling / uncoupling trains dynamically (not in a depot).
I had heard about a shunting patch lately, but I am not quite able to find it out.
Re: Train deadlock on a single-track line
Hey, it worked! Thank you very much!Vinnie_nl wrote:set yapf.rail_pbs_signal_back_penalty 5000

I hope it won't cause any other problem somewhere else... I have to test it.
A signal box operator would definitely prevent such deadlocks from happeningccomley wrote:Ah, but "realism" would give you a signal box operator who would decide which train goes first and which route it takes!

I didn't quite get you at first try, but now I do understand what you mean.siu238X wrote:I only suggested putting the tracks under the same roof such that trains don't make stupid mistakes.
Who is online
Users browsing this forum: No registered users and 5 guests