Realistic Path Based Signalling

From OpenTTD
Jump to: navigation, search


Historic content
This page or section contains content that is no longer relevant for the current version of OpenTTD. Please keep it intact because it shows some of the history of this wiki as documentation.
This page describes a possible implementation of path based signalling. It was originally written in June 2007, before YAPP PBS signals existed. Therefore, this article is partially outdated.



This page describes an alternative to the old path based signalling (PBS) system of OpenTTD. This proposed new PBS system is based on realistic signal behavior. The primary intent of this new system is to allow bi-directional double track and bi-directional stations, which are not supported by the current OpenTTD signalling system (at least not without frequent deadlocks). This new signalling system was first proposed in detail by the forum user "Tekky" in his post in March 2007. Currently, forum user "Tekky" is trying to implement this new PBS system himself, but only very little code has been written to date.

However, a partial implementation of these proposals has been implemented by forum user "Michi_cc", which has become known as YAPP (Yet Another PBS Patch). This implementation does not support bi-directional double track due to lack of support of "weak" reservations. However, it does support many other PBS features, including bi-directional pass-through-stations.

Bi-directional double track in reality

In reality, bi-directional double track is used to allow faster (passenger) trains to overtake slower (generally freight) trains and also to allow one track to be closed for maintenance working while still allowing traffic to flow in both directions on the other track. In Germany, for example, all newly built double track is bi-directional and also existing double track is now being upgraded to become bi-directional. (Note that, unless stated otherwise, all the signals depicted in this article are not one-way block signals, that means train can pass through all the single signals from behind as if there is no signal regulating passage of that direction.)

Bi-directional double track has the following layout in reality (assuming right-hand traffic):

Figure 1.1

If one considers only the placement of realistic signals important, and not the placement of realistic switches, the above layout can be simplified to the following:

Figure 1.2

Bi-directional double track in OpenTTD/miniIN

The previously described realistic signal placement will currently not work in OpenTTD, for the following 3 reasons:

  1. OpenTTD consideres track with single signals as one-way track.
  2. The above signals are all pre-signals. OpenTTD also requires the placement of corresponding exit-signals, which do not exist in reality.
  3. OpenTTD by default doesn't allow more than one train to be in an intersection area at a time. This means a train would be obstructed by traffic coming the other way, even if their paths do not cross.

The closest solution available in OpenTTD to these 3 problems would be the following track layout, which uses the old path based signalling (PBS), which is available in the miniIN version of OpenTTD:


Please note that the new YAPP path signals behaves very differently to the old miniIN PBS system, which this article is referring to. This article was written at a time before YAPP existed.

Figure 2.1

This track layout works, in principle. However, there is the danger of a deadlock, using the current miniIN PBS implementation:

Figure 2.2

This deadlock occurs if two trains try to enter the same block from two sides, at the same time. This problem could be fixed in the current miniIN PBS implementation by making a train also reserve the block behind the intersection, so that two trains won't attempt to enter the same block from two sides. However, this solution would not prevent the following deadlock from occuring:

Figure 2.3

Bi-directional double track in the proposed new PBS system

In order for OpenTTD to implement bi-directional double track without the danger of a deadlock, the following semi-realistic track layout was proposed, which would require a new PBS system in OpenTTD:

Figure 3.1

Assuming right-hand traffic, trains should normally use the right track and only use the left track when the right track is being blocked by another train travelling in the same direction. Since many OpenTTD players also create rail networks with left-hand traffic, this article will use the terms "regular track" and "opposite track" instead of "right track" and "left track", respectively.

In the above picture, the signals are placed in such a way so that trains will always encounter regular signals when travelling on the regular track and orange signals when travelling on the opposite track. These different signal types tell the pathfinder to use the regular track and not the opposite track, if possible. This could be accomplished by adding an additional "weight" for orange signals to the pathfinder.

Of course, the above track layout would only work if OpenTTD were reprogrammed to not consider track with single signals as one-way track. This can be changed easily. Also, all of the signals in the above picture are pre-signals. OpenTTD (more specifically, the PBS-system) would have to be modified to act as if implicit exit-signals were behind the switches. It is important not to have real signals which can show red/green as exit signals, because trains should not be allowed to wait in front of exit signals, since they would be blocking the intersection. Instead, they should reserve the route up to the next non-exit-signal.

As a rule of thumb, trains should try to wait in front of signals on the regular track (=regular signals). As long as there are only trains waiting on the regular track, there is no danger of a deadlock. Trains should only be allowed to wait in front of signals on the opposite track (=orange signals) if they can be absolutely sure to soon be able to swap back to the regular track. Otherwise, there is a danger of a deadlock:

Figure 3.2

This picture may not look like a deadlock, but if there is a full station immediately to the left, then the waiting train on the opposite track will have caused a deadlock:

Figure 3.3

In order to prevent such deadlocks, trains should only be allowed to wait in front of signals on the opposite track (=orange signals) if they can be absolutely sure to be able to swap back to the regular track without a deadlock occuring beforehand. Therefore, a train whose pathfinder decides to wait in front of an orange signal will also have to have reserved a route to the next regular signal. This reservation of the path to the next regular signal, however, does not mean the path to the next regular signal must be completely free. Such a requirement would make all orange signals redundant, since they would always show green and never red. Instead, it is enough to reserve a route to the next regular signal that is safe from a deadlock (a "weak reservation"), such as in the following picture:

Figure 3.4

In the above picture, it was safe for train 1 to use the opposite track, because it can be sure to soon be able to move to the signal next to train 2. Train 1 can be sure of this because train 2 is already moving and has already reserved a route past the signal.

When there are two trains travelling next to each other in the same direction on different tracks, the path reservations will look like the following:

Figure 3.5

In this picture, the red path is the "strong" reservation and the yellow path is the "weak" reservation.

Since the train on the opposite track is unable to switch back to the regular track without interfering with the other train, the train on the opposite track will shift its weak reservation to the next junction, as soon as the pathfinder detects a path conflict, so that both trains can continue unhindered:

Figure 3.6

This would of course only work if there is no traffic coming the other way. If it is not possible to reserve the path to next junction due to traffic coming the other way, then there are two possible solutions:

1. The path reservations in figure 3.5 are left unchanged. This means that the train on the opposite track switches back to the regular track and the train already on the regular track must stop.

2. The path reservations are changed to that displayed in the picture below. In this case, the train on the opposite track stops and waits for the train on the regular track to clear the area of the weak reservation. The train on the regular track must make a strong reservation out of the area of the other train's weak reservation(i.e. to the next signal), otherwise it would risk deadlocking the other train, thus violating the other train's weak reservation.

Figure 3.7

Whenever there is a path conflict, OpenTTD should determine which solution is best, depending on how much time every train would lose and possibly also taking train priority into account. In order to detect path conflicts in time to take all of these considerations into account, it will be necessary that trains on the regular track have some kind of additional "lookahead", which could be technically implemented as an additional type of reservation, even if lookaheads aren't "real" reservations.

Conclusion: It is always safe for a train to wait in front of a signal on the regular track (=regular signal). It is also always safe for a train to use the opposite track, as long as it has a "weak" reservation of a path to a regular signal. A "weak" reservation of a path means the path is guaranteed to soon be cleared. This is the case, for example, if all trains currently blocking the path have an exclusive ("strong") reservation of a path leading to a point outside the area of the weak reservation and no further trains are allowed into the area of the "weak" reservation.

Bi-directional pass-through stations in the proposed new PBS system

Using the signalling system described in the previous section, a pass-through station would look like this:

Figure 4.1

Please note that you now only need one pre-signal for the station, all the exit-signals of that pre-signal before each platform are now implicit after every switch, as they are in reality (although in reality most stations are bi-directional). You only need additional signals for the trains leaving the station.

However, the main advantage of the proposed new PBS system would be that bi-directional pass-through stations would also be supported, such as the following layout:

Figure 4.2

A bi-directional station layout will currently not work in OpenTTD (even when using pre- and exit-signals), because there would be a deadlock if two trains try to enter the same platform at the same time from two different sides. With the new PBS system, however, all trains will have to reserve a route into the station platform (thereby reserving the entire platform) before they leave their waiting signal. For this reason, only one train will attempt to enter a platform at once and there is no danger of a deadlock.

Required changes to OpenTTD

For the features described in the previous sections to work, the following modifications would have to be made to OpenTTD:

First, OpenTTD should not automatically consider track with single signals as one-way track. It must be permitted to put single signals also on bi-directional track. One-way track must be marked in a different way.

Furthermore, all signals in OpenTTD are to be PBS signals. With a proper PBS implementation, exit-signals can be considered implicit after every switch, making them obsolete. They don't exist in reality, either, because in reality, signals are only placed in places where trains are supposed to wait.

Also, all signals should show red by default, as in reality. Only after a train reserves a route through a signal, should a signal show green (until the train passes by). This is also how modern signals behave in reality.

A train's pathfinder must always reserve a route to the next signal. This reservation must be "strong", i.e. the path to the next signal must be completely clear. In the case of the next signal being an orange signal instead of a regular signal (which means the signal is an unsafe waiting location), the train must also make a "weak" reservation from the orange signal to the next regular signal, in order to not risk getting stuck in front of an orange signal (which could cause a deadlock). The difference between these two types of path reservations are explained in the section titled "Bi-directional double track in the proposed new PBS system". If these path reservations are not possible or conflict with another train with a higher priority, the train does not proceed and waits in front of its current signal (which shows red). The basics of such a system have already been implemented with the current miniIN PBS sytem, although this current system only supports strong reservations and not weak ones and also does not support train priorities.

As long as regular signals are only placed in safe waiting locations for trains and all unsafe waiting locations are marked with orange signals, there will never be a danger of a deadlock.

Personal tools