Can someone tell me why these trains are deadlocked?

Got a problem with OpenTTD? Find some help here.

Moderator: OpenTTD Developers

Post Reply
JayGuerette
Engineer
Engineer
Posts: 6
Joined: 30 May 2012 23:51

Can someone tell me why these trains are deadlocked?

Post by JayGuerette »

OpenTTD v1.2.0

I built this test layout to mock a real in-game issue I'm having, and was able to duplicate the problem. There train on the left is waiting at a path signal, when there is an obvious open path:

Image

EDIT: added OpenTTD version
EDIT: updated image with names & orders displayed
Last edited by JayGuerette on 31 May 2012 12:24, edited 1 time in total.
Arie-
Director
Director
Posts: 593
Joined: 20 Jan 2009 16:07

Re: Can someone tell me why these trains are deadlocked?

Post by Arie- »

Can you show us the order list and station names?
JayGuerette
Engineer
Engineer
Posts: 6
Joined: 30 May 2012 23:51

Re: Can someone tell me why these trains are deadlocked?

Post by JayGuerette »

It seems I didn't save that layout; so I had to re-create it. I replaced the image in situ, with all requested information.
User avatar
Pyoro
Tycoon
Tycoon
Posts: 2566
Joined: 17 Oct 2008 12:17
Location: Virgo Supercluster

Re: Can someone tell me why these trains are deadlocked?

Post by Pyoro »

Problem seems to be that the train on the lowest platform tries to reach its destination (obviously blocked) "reserving" the crossing for some reason (try turning it around, the train on the left will properly go to platform 4). Can be solved by turning those signals to right around, as entering that station will then take priority over exiting it.
...doesn't seem to be a very desirable situation either way, though ;)
Arie-
Director
Director
Posts: 593
Joined: 20 Jan 2009 16:07

Re: Can someone tell me why these trains are deadlocked?

Post by Arie- »

Strange one, I can't reproduce it. The back of a signal doesn't count as a signal when reserving a track, the path passes straight through it. As such I expected some strange station layout or weird orders pointing at a specific depot. I don't see what is wrong, such a set up works for me. Could you turn on track reservations? (advanced settings -> interface -> display options -> track reservations)

@Pyoro, how can you see the bottom train already reserved a path in that screenshot?

edit: Perhaps there's a path penalty messing around: the shorter (lower path) is more cheaper although it crosses more tracks than the longer path taking the first exit. I'm gonna mess around with path lenghts.

edit2: Added a screenshot, the bottom setup keeps running, the top one stops.
Plonningley Transport, 29th Apr 2000.png
Plonningley Transport, 29th Apr 2000.png (43.46 KiB) Viewed 2758 times
edit3: @Pyoro below me, I turned on path reservations, but, as you can see it's not that there is a train which reserved a path. It just won't pick the available one, possibly because of path penalties.
Last edited by Arie- on 31 May 2012 13:04, edited 2 times in total.
User avatar
Pyoro
Tycoon
Tycoon
Posts: 2566
Joined: 17 Oct 2008 12:17
Location: Virgo Supercluster

Re: Can someone tell me why these trains are deadlocked?

Post by Pyoro »

I can't, which is why I went and reproduced it ;)
Turning on visible track reservations won't help here, but it seems rather obvious:
Attachments
Staufertransporte, 31. Jul 1932.png
Staufertransporte, 31. Jul 1932.png (19.01 KiB) Viewed 2760 times
Staufertransporte, 1. Aug 1932.png
Staufertransporte, 1. Aug 1932.png (20.49 KiB) Viewed 2760 times
JayGuerette
Engineer
Engineer
Posts: 6
Joined: 30 May 2012 23:51

Re: Can someone tell me why these trains are deadlocked?

Post by JayGuerette »

It happened in a game, and I've made 2 discrete test layouts. It's reliably reproducable for me.

Turning on track reservations didn't add any information. I turned #12 around, and after a bit of shuffling, they all came to rest in the same situation.The reservations were all as expected. At rest, as in the screenshot, they all show a reservation for the tile under them, in front of the path signal, and that's it; no train has reserved track sections in the intersection that would cause #12 to wait.
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: Can someone tell me why these trains are deadlocked?

Post by planetmaker »

I'm again amazed... discussing game mechanics, train behaviour. And again: why has no-one posted a savegame so that one easily play around with the read-made setup. And see oneself...
Pathfinding has so many parameters, most of them only accessible in the savegame itself, nowhere found in the user-visible adv. settings.
JayGuerette
Engineer
Engineer
Posts: 6
Joined: 30 May 2012 23:51

Re: Can someone tell me why these trains are deadlocked?

Post by JayGuerette »

Here you go; save game of deadlock setup: http://images.guerette.net/OpenTTD_deadlock.sav
Eddi
Tycoon
Tycoon
Posts: 8289
Joined: 17 Jan 2007 00:14

Re: Can someone tell me why these trains are deadlocked?

Post by Eddi »

i didn't look at the savegame, but from the picture i would suggest this problem:
  • the train has 4 choices for paths, the pathfinder will calculate a "penalty" for each one, to find out which one is the best.
  • "best" is usually the shortest, but some exceptions apply when signals are red or tracks are occupied. so some detours may be acceptable.
  • by default, each straight tile counts as a penalty of 100, an occupied track as 300 (= 3 tiles detour), two consecutive diagonal tiles as 140 (=0.4 tiles detour) and a curve as 100 (= 1 tile detour) [plus a few others not interesting here]
  • the track straight ahead is 11 straight tiles, 1 occupied tile = 11*100+300 = 1400
  • the track to the last platform is 6 diagonal tiles, 8 straight tiles, and 2 curves = 3*140 (or 6*70) + 8*100 + 2*100 = 1420.
  • thus, the game gets to the opinion that it should rather wait for the straight track to clear, than use the detour to the free platform.
  • Arie's lower version however does not show this effect, because there the waiting trains are still on the platform, so the penalty there is higher (800 per platform tile. always the whole platform is reserved, not only the tiles the train is standing on)
  • to solve this issue, make your trains longer, move the signals to the platform, or increase the pathfinder penalty yapf.rail_pbs_cross_penalty
JayGuerette
Engineer
Engineer
Posts: 6
Joined: 30 May 2012 23:51

Re: Can someone tell me why these trains are deadlocked?

Post by JayGuerette »

Eddi wrote:... the game gets to the opinion that it should rather wait for the straight track to clear, than use the detour to the free platform.
Thanks. I think you've nailed it there.

I don't understand the logic of "wait" when there is a free path, no matter what the cost. A deadlock is vastly more expensive than taking the long way. Outside of this silly little test setup, I ran into this in a real game, and couldn't figure out why everything ground to a standstill. The paths were more complicated, and the trains were a servicable length, but I'm guessing the math came out the same. I ended up ripping everything out and re-doing it just to get the traffic flowing; and in doing so I must have just tipped the scales.

I personally don't think "wait" should be an option; or at least not the default.
Rubidium
OpenTTD Developer
OpenTTD Developer
Posts: 3815
Joined: 09 Feb 2006 19:15

Re: Can someone tell me why these trains are deadlocked?

Post by Rubidium »

JayGuerette wrote:I personally don't think "wait" should be an option; or at least not the default.
So in the following situation train 4 should pass through Kunrburk Valley, and possibly drive around the map infinitely because the station is accidentally full? I'd prefer the train to wait than to having go around. Especially in my networks trains then have to go through other stations or make gigantic detours before the vehicle reaches the original destination again.
Kunrburk Transport, 1999-05-10.png
Kunrburk Transport, 1999-05-10.png (42.45 KiB) Viewed 2679 times
So maybe in your deadlock situation it makes sense, but if you can create a deadlock then it isn't a safe waiting point and thus shouldn't you be placing signals there.

It is also not possible to make the pathfinder do the right thing in all situations, because as soon as you change a penalty to fix one situation, your creating another. In the end each player prefers his/her own penalty settings.
Transportman
Tycoon
Tycoon
Posts: 2792
Joined: 22 Feb 2011 18:34

Re: Can someone tell me why these trains are deadlocked?

Post by Transportman »

Rubidium wrote:So in the following situation train 4 should pass through Kunrburk Valley, and possibly drive around the map infinitely because the station is accidentally full? I'd prefer the train to wait than to having go around. Especially in my networks trains then have to go through other stations or make gigantic detours before the vehicle reaches the original destination again.
I think as long as there is a free path to the destination that the train should take it, so that would mean that the train should wait until there is a free path, but in the original case from the TS the train should go. to the station. Of course to a certain limit, so maybe allow a certain pathfinder margin like 10-20% if the vehicle should stop otherwise (so if the path has a penalty of 1000 also accept paths of 1100-1200 if the 1000 is not free but the 1100-1200 is free)?
Coder of the Dutch Trackset | Development support for the Dutch Trainset | Coder of the 2cc TrainsInNML
Eddi
Tycoon
Tycoon
Posts: 8289
Joined: 17 Jan 2007 00:14

Re: Can someone tell me why these trains are deadlocked?

Post by Eddi »

that is what happens already, that's what the penalties are for. the point is, once the numbers are added up, they are all that counts. the game cannot know whether a path is "blocked" at that point. you can influence the "margin" by yourself, by going to the ingame console ([?]-Menu) and changing one of the settings listed by "list_settings pf.yapf.rail", like the one i mentioned above, but that's all you can do. once the numbers are crunched, the lowest one wins. there is no alternative to that.
Transportman
Tycoon
Tycoon
Posts: 2792
Joined: 22 Feb 2011 18:34

Re: Can someone tell me why these trains are deadlocked?

Post by Transportman »

Maybe something like:
-Calculate penalties
-Take lowest penalty
-Is route free?
-Yes: Follow route
-No: Check next route
-Take route with second lowest penalty
-Is penalty<lowest penalty+20%?
-No: Stop
-Yes: Is route free?
-Yes: Follow route
-No: Check next route
And so on until it either finds a free route or the penalty exceeds the minimum+20%.

I'm not sure about the impact this would have on the speed of OpenTTD, especially on bit maps with a lot of vehicles and big stations this can becomes a lot of work.
Coder of the Dutch Trackset | Development support for the Dutch Trainset | Coder of the 2cc TrainsInNML
JayGuerette
Engineer
Engineer
Posts: 6
Joined: 30 May 2012 23:51

Re: Can someone tell me why these trains are deadlocked?

Post by JayGuerette »

Rubidium wrote:... train 4 should pass through Kunrburk Valley, and possibly drive around the map infinitely because the station is accidentally full
That's not a valid comparison; in your example there are 2 paths available. In the event where #12 in my example has only one path, and has it's back to a dead end, I don't think it should wait. Inexperienced users are more likely to create isolated dead-end runs; where more experienced users would create networks. If the default was to favor doing the right thing for the former, they're more likely to become the latter. Experienced folks are more likely to tweak a behavior to their liking, anyway.
Post Reply

Return to “OpenTTD Problems”

Who is online

Users browsing this forum: Google [Bot] and 3 guests