Signals and pathing

The "spiritual sequel" to Transport Tycoon Deluxe: Chris Sawyer's Locomotion is the latest game from him - general discussion about it here please!

Moderator: Locomotion Moderators

Post Reply
User avatar
bsones
Engineer
Engineer
Posts: 1
Joined: 29 Sep 2019 18:04

Signals and pathing

Post by bsones » 30 Sep 2019 11:49

I've been relearning Locomotion after discovering the existence of OpenLoco--specifically trying to figure out how signals work. People complain about the lack of different signal types. And they are right--Locomotion has exactly two types of signals--basic two-way block signals, and basic one-way block signals. No chain/entry-exit signals, no path signals. In theory, this should cause problems with certain track configurations. If you limit yourself to only making RO-RO stations, then you can get by with nothing but simple block signals. But if you use terminus stations with junctions, where trains enter the station and then reverse direction and go out the same way they came in (ideally on the other side of a set of parallel track), then the deficiencies of basic block signals very quickly become obvious.

To illustrate, I threw together a "perfect storm" for terminus station traffic jams in OpenTTD. I have two stations, connected by a set of one-way parallel track (trains drive on the right). The track stretching between the two stations is just a single block in each direction, just to make this setup extra jam-prone. Just before each station is a crossover junction, broken into its own block using only the simple two-way and one-way signals. If you try to run four trains on this route, you will pretty much immediately get an unresolvable traffic jam, as illustrated below...

Image

What has happened is that you have a train on each of the center blocks--one going to the northwest station, and one going to the southeast station. You also have a train trying to leave each station, but they can't because the center blocks are already occupied. So both trains trying to leave have pulled into their respective junctions and are waiting for the center sections to clear. But the center sections will never clear, because now trains are blocking both of the junctions leading out of the center sections.

In OpenTTD, the solution to this mess is to use either path signals or entry-exit signals. I prefer entry/exit signals, as they tend to be a more bullet-proof solution to this sort of traffic jam, but YMMV.

So I tried setting up the same scenario in Locomotion, and... no traffic jam. In Locomotion, this route runs perfectly fine with four trains. But how?

I spent some time observing, and noticed a few things. For one, signals in Locomotion seem to be red by default, until a train approaches. This is not how basic block signals work in OpenTTD (they are always green if the block ahead is clear), but it IS how path signals work. Path signals in OpenTTD are normally red, and only turn green (briefly) when a a train reaches the signal and checks ahead to see if it has a clear path. So could it be that Locomotion's basic block signals are actually path signals in disguise?

They aren't. I tested this, and two trains will never enter the same block, even if both trains have a non-conflicting route through the block. But while tinkering, I noticed something else. When a train on this route enters a block, the next signal in their path of travel turns green. I think what happens in this game is that trains always try to "reserve" blocks ahead in their path of travel, and this decreases the likelihood of traffic jams. For example, below we have the exact same scenario that caused the traffic jam in OpenTTD. Two trains are occupying the center blocks (one travelling in each direction) and two trains are also trying to leave each of the respective stations. But the trains trying to leave the stations don't pull into the junctions, because the trains travelling through the center blocks have already "reserved" them. It's a little hard to see with these semaphore signals, but if you look closely, you can see that the signals ahead of each of the trains in the middle blocks--the signals entering the station junctions--are green. And as a result, the trains exiting the stations consider the junctions blocked, and won't move into them.

Image

And it’s a little more complicated than that, even. For one, signals actually have three positions. In the screenshot below, the train exiting the Breakers Bridge station has caused the next two signals in front of it to turn green, with the semaphore pointing straight up, and has also caused a third signal (the one entering the left-hand platform at the Beachtown Mines station) to turn yellow, with the semaphore pointing at a 45-degree angle.

Image

WTF does a yellow signal mean? It seems to be a caution signal, which tells the train approaching that while the block ahead is technically clear, it should slow down. Signals entering station platforms are always yellow, and signals out in the wild will be yellow only if the next signal along the route is red--i.e. because another train is in the next block. Thus they seem to be telling a following train "You can enter this block, but slow down because there's a train or station just ahead of you." By slowing trains down in advance, the game is actively working to keep them spaced out, and prevent them from bunching up.

In addition to that, trains try to reserve blocks all the way to their next destination, if they can. You can see the green/open signals rippling forward along the train's route of travel, with the last open signal always yellow (so the train will always have a yellow signal immediately preceding a red). If their path intersects another train's projected path, right-of-way calculations (which seem to work on a simple "first come, first served" basis) happen to see which of the two trains crosses first.

And sometimes traffic is so dense that trains can't reserve ahead at all. That's when you are getting close to having a traffic jam. The neat thing is that you can see when your network is getting too crowded just by watching your trains run. If trains are following real close behind other trains (like in the block directly behind them) on a regular basis, then that's a red flag telling you that you have too many trains running on that route, and you either need to redesign the route, or get rid of a train or two.

Anyway, I ran the Locomotion version of that route in fast-forward for ten years with four trains running on it, and it never generated a traffic jam. Then I decided to see if I could arrange things to force a traffic jam, by getting each of the four trains to leave each of the four platforms simultaneously. And yep, that caused a traffic jam. But only that very specific start condition will do it, and so in actual operation, that effectively never happens.

Then I checked to see if traffic jams are more likely with a more complex route, and the answer is "possibly." For example, this configuration jams pretty quickly even with just three trains running on it...

Image

That said, I think the problem here is not the train logic, but rather poor design on my part. This network has too many junctions in close proximity. Jams only happen near Breakers Bridge and Boulder Bay, and I think it's just because I have a T-junction that empties directly into another junction, and that inevitably causes pathing problems. Additionally, while there is a technically a block between the T-junction and the Boulder Bay station junction, it's not long enough to accommodate a train. So a train waiting in that block is also blocking the station junction (or the T-junction, depending on direction of travel). The trains never jam up by Beachtown Mines, where there is a full, train-sized block between the T-junction and the station junction.

So I tried a design adjustment. After adding more breathing room around all the junctions (in the form of blocks large enough to accommodate full trains), the traffic jams stopped, even after going back to running four trains on the network.

Image

TL;DR: Locomotion's signaling/pathing logic is actually fairly sophisticated, and is good at avoiding jams if you don't overload a route with trains, and also design it well.

Post Reply

Return to “General Locomotion”

Who is online

Users browsing this forum: No registered users and 2 guests