The International Simutrans Forum

Simutrans Extended => Simutrans Extended Development => Topic started by: Freahk on July 08, 2020, 08:30:27 AM

Title: Deadlocks caused by drive by sight
Post by: Freahk on July 08, 2020, 08:30:27 AM
Hey there.
There seems to be a design issue with drive by sight.
A simple junction can deadlock if there is any diagonal involved. Only cardinal 90° junctions are safe from deadlocking.

Would it be possible to reservate all adjacent junctions along a route as one in drive by sight?

Special consideration might be required in case the whole set of junctions cannot be sighted before actually entering the first junction tile.
We might
a) simply ignore sighting distance in that special case or
b) try to reservate the whole junction as soon as it is completely in sight; Reservate the parts that are in sight if the whole junction cannot be seen from one tile before that junction.

It would be very nice to also include stations into this atomic drive by sight "block", to allow safe reversal at dead-end station in drive by sight, which is common practice in real-world tram networks.
That means, when a platform starts immediately adjacent to a junction, ensure that trains will only enter that junction if the platform behind it is clear either.
Title: Re: Deadlocks caused by drive by sight
Post by: freddyhayward on July 08, 2020, 08:46:28 AM
This seems quite simple and useful!
Title: Re: Deadlocks caused by drive by sight
Post by: jamespetts on July 21, 2020, 11:20:53 PM
Can you clarify what you mean by "adjacent junctions" here? I am not sure that I entirely understand this in the context of a linear reservation.
Title: Re: Deadlocks caused by drive by sight
Post by: Freahk on July 21, 2020, 11:51:34 PM
When you have one junction and there is another one on a neighboring tile, that means (x,y) being a junction and (x+1,y) being a junction, those are adjacent to each other.

So, if (0,0), (0,1) and (0,2) are junctions and a train travels along (0,0)->(0,1)->(1,1), it will reserve (0,0) and (0,1) as a block.
That means, if it cannot reserve both, it won't reserve any of these, i.e. it will stop in front of the junction.

As pointed out above, considerations need to be taken in cases where the whole junction block is not in sight. We could either ignore sighting distance in that case, or create such reservations only up to the point we can see.

That behavior would solve the most troublesome deadlocking in drive by sight, where a very simple junction tat nobody would expect to ever cause a deadlock can deadlock (and in practice does)
Deadlocking issues related to terminus stations will persist.