This is for everyone that would like to leverage the Routing Restrictions
patch (you can find it in JGR's Patch Pack
), but isn't doing so due to lack of documentation or examples.
We will build an overtake lane, i.e. a simple track layout that allows faster trains to overtake slower trains. The idea of this guide is to present an easy solution to a common problem (trains overtaking), and at the same time get players started with Routing Restrictions. As such, there may be better ways to do this, with or without the patch.
Let's start with the overall situation.
And the basic layout. 6 tiles signal spacing is used here, but any value should work.
Red tracks will be the overtake lanes, blue tracks will be the lanes used by the slower trains. This is slightly counterintuive (overtaking on the inside rather than the outside), but it keeps fast trains on the main line and makes the signal programming more understandable.
We first implement the overtaking aspect of the system. This means forcing trains slower than a threshold (112 km/h in our case) to the outer lanes. We do this by restricting the inner lane route: the two signals marked in red Deny
the overtaking lane to all trains whose max speed < 112 km/h
(ignore the Long reserve
for now); this forces slower trains to take the only other available lane. Note the inversion of control: the inner lane signals control what trains go the the outer lane, and vice-versa.
What happens though if the slower train is only slightly slower than the faster one, or if the latter is too much behind than the former when they both reach the overtaking area? For example, the slow train (in red) will reenter the main line before the faster train (in blue) had any chance to overtake it.
We solve this by reserving a path through the whole overtaking lane for the faster train to use. Reserving the track up until the first signal not in the layout (reserving in grey) means that any train in the outer lane (in red) will have to stop at the last signal and wait for any trains within the overtaking lane to pass.
We do this with the Long reserve
command: this tells YAPF that the path should be reserved up to the following signal, instead of stopping at the current one. Chaining the signals within the overtake lane implements exactly the behaviour we wanted.
Now another problem arises: if two fast trains are closely following each other, the one behind will take the slow lane because YAPF sees that lane as free.
We avoid this by denying entry to the overtake lane to all trains faster than the threshold speed.
This layout scales well, and works wonderfully with most other features (like the improved breakdowns
patch). You can also have overtaking lanes on your overtaking lanes, with different speed tiers. Also keep in mind this example was done with a speed acting as the deciding threshold, but you can use any property provided by the patch: e.g. give priority to full trains over half empty ones, passengers over freight, express over local, and so on.