How to keep the main line (trains) rolling?

OpenTTD is a fully open-sourced reimplementation of TTD, written in C++, boasting improved gameplay and many new features.

Moderator: OpenTTD Developers

Post Reply
MarkShot
Engineer
Engineer
Posts: 118
Joined: 27 Mar 2019 11:30

How to keep the main line (trains) rolling?

Post by MarkShot » 27 Apr 2019 15:30

Suppose I have a mainline either express or fast freight or slow freight (mutually exclusive).

The mainline connects to side stations, and the mainline itself is two tracks running up and down.

The problem is how to keep rail traffic on the mainline rolling?

I already know that junctions should not cross tracks, but should be over/under implementations.

I already know that if you don't disable breakdowns or use a mod that breakdowns pose a severe risk of stalling the mainline.

Suppose a station has N trains which visit via the mainline. I only see two absolute ways to guarantee that those N trains do not stall the main line.

Option #1: Make sure there are enough track and signals on the siding to the station to buffer N trains. Thus, the entire complement can come off the mainline if they must for any reason.

Option #2: The mainline is more than parallel tracks, but rather a race track pattern. When any of those N trains encounters a RED to exit for its station (programmable routing) sends the train past its exit for another lap around the race track. Thus, trains are like planes put into a holding pattern. All the trains behind the given train, can reach their assigned destinations. Hopefully, the "go around" train will be able to make its siding on the next pass. THE PRIMARY RULE IS DON'T STOP MOVING ON THE MAIN LINE.

BTW, I don't have the knowledge I need to implement Option #2, and Option #1, is cumbersome, but trivial to implement.

---

Comment, thoughts, expertise, help?

Thanks!


Transportman
Tycoon
Tycoon
Posts: 2687
Joined: 22 Feb 2011 18:34

Re: How to keep the main line (trains) rolling?

Post by Transportman » 27 Apr 2019 20:37

MarkShot wrote: Option #1: Make sure there are enough track and signals on the siding to the station to buffer N trains. Thus, the entire complement can come off the mainline if they must for any reason.
Or use an escape depot, then you have basically unlimited buffer capacity, although you might need to make some minor modifications if you really have high traffic at the station or have very long trains, as depots have a reduced entry/exit speed.
Coder of the Dutch Trackset | Development support for the Dutch Trainset | Coder of the 2cc TrainsInNML

Alberth
OpenTTD Developer
OpenTTD Developer
Posts: 4730
Joined: 09 Sep 2007 05:03
Location: home

Re: How to keep the main line (trains) rolling?

Post by Alberth » 28 Apr 2019 05:48

One solution is to use feeders. You have sideline trains and mainline trains, cargo gets transported through feeder stations onto and from the mainline.
That is: producer -> sideline train -> feeder station -> mainline train -> feeder station -> sideline train -> consumer.

Since there is a fixed number of trains on the mainline, (and they don't wait for full load,) main line will continue to roll.
I tried this while aiming to move all industrial cargo to/from all industries, and it's interesting :mrgreen:



I usually build a network of lines (I don't really have main lines and side lines, just a network of connected stations), and in my experience trains are pretty good at finding their way in the network. They avoid busy areas, unless you force everything to the same spot of course.
For example
tarnington_map.png
(45.38 KiB) Not downloaded yet
These networks are created organically, so they are always different.
Being a OpenTTD developer does not mean I know what I am doing.
Also, other OpenTTD developers may have different opinions.

MarkShot
Engineer
Engineer
Posts: 118
Joined: 27 Mar 2019 11:30

Re: How to keep the main line (trains) rolling?

Post by MarkShot » 28 Apr 2019 07:46

kamnet wrote:Check out https://wiki.openttdcoop.org/Main_Page for advanced concepts on building and managing train networks.
What an interesting and profound resource. I didn't even know that site existed.

I was only aware of:

https://wiki.openttd.org/Main_Page

I have been relying on YouTube videos.

I am a little confused as to the distinction between these three sites:

https://wiki.openttd.org/Main_Page

https://wiki.openttdcoop.org/Main_Page

https://github.com

Can someone clarify?

Thanks.

MarkShot
Engineer
Engineer
Posts: 118
Joined: 27 Mar 2019 11:30

Re: How to keep the main line (trains) rolling?

Post by MarkShot » 28 Apr 2019 07:52

If I wanted to try my approach of using a race track pattern with no waiting to pull off the mainline, but to go around ...

Where would I find material on programmable routes such that if a train encountering a Y with two options:

(a) Sideline
(b) Bypass

finds the Sideline blocked, it bypasses and begins a circuit?

Thanks.

User avatar
kamnet
Moderator
Moderator
Posts: 6711
Joined: 28 Sep 2009 17:15
Location: Eastern KY
Contact:

Re: How to keep the main line (trains) rolling?

Post by kamnet » 28 Apr 2019 08:28

MarkShot wrote:I am a little confused as to the distinction between these three sites:
1. https://wiki.openttd.org/Main_Page
2. https://wiki.openttdcoop.org/Main_Page
3. https://github.com
1. Is the official OpenTTD wiki, which is contributed to by anybody who wishes to contribute
2. Is the wiki for OpenTTD Co-op, a dedicated group of players (many of them devs) who work on advanced gaming techniques
3. Is the open source code repository where OpenTTD now stores its code.

Transportman
Tycoon
Tycoon
Posts: 2687
Joined: 22 Feb 2011 18:34

Re: How to keep the main line (trains) rolling?

Post by Transportman » 28 Apr 2019 09:00

MarkShot wrote:If I wanted to try my approach of using a race track pattern with no waiting to pull off the mainline, but to go around ...

Where would I find material on programmable routes such that if a train encountering a Y with two options:

(a) Sideline
(b) Bypass

finds the Sideline blocked, it bypasses and begins a circuit?

Thanks.
You might want to look at this page. It is a bit of complex material, but in your case, it would be reduced to the following:
  1. Set the setting yapf.rail_firstred_twoway_eol in your openttd.cfg to true
  2. Place a two-way signal on your sideline and have the next signal on the sideline be at least one train length ahead
  3. Place a one-way signal on your bypass and continue with the usual signal distance you use on your mainline
What this does, is when your sideline-entry is blocked by a train, all other trains do not consider the sideline because the two-way signal is red and because of the yapf.rail_firstred_twoway_eol-setting, it is considered the end of the line and has an infinite penalty for the pathfinder. Because your mainline has a one-way signal, it is not considered the end of the line, and has a lower penalty, and trains always take the path with the lowest penalty.
Coder of the Dutch Trackset | Development support for the Dutch Trainset | Coder of the 2cc TrainsInNML

rowdog
Engineer
Engineer
Posts: 49
Joined: 24 May 2017 12:51
Location: East Texas

Re: How to keep the main line (trains) rolling?

Post by rowdog » 28 Apr 2019 14:22

I believe that your "race track" is what is commonly referred to as a cyclotron.
https://wiki.openttd.org/Cyclotron

MarkShot
Engineer
Engineer
Posts: 118
Joined: 27 Mar 2019 11:30

Re: How to keep the main line (trains) rolling?

Post by MarkShot » 28 Apr 2019 14:41

Transportman wrote:
MarkShot wrote:If I wanted to try my approach of using a race track pattern with no waiting to pull off the mainline, but to go around ...

Where would I find material on programmable routes such that if a train encountering a Y with two options:

(a) Sideline
(b) Bypass

finds the Sideline blocked, it bypasses and begins a circuit?

Thanks.
You might want to look at this page. It is a bit of complex material, but in your case, it would be reduced to the following:
  1. Set the setting yapf.rail_firstred_twoway_eol in your openttd.cfg to true
  2. Place a two-way signal on your sideline and have the next signal on the sideline be at least one train length ahead
  3. Place a one-way signal on your bypass and continue with the usual signal distance you use on your mainline
What this does, is when your sideline-entry is blocked by a train, all other trains do not consider the sideline because the two-way signal is red and because of the yapf.rail_firstred_twoway_eol-setting, it is considered the end of the line and has an infinite penalty for the pathfinder. Because your mainline has a one-way signal, it is not considered the end of the line, and has a lower penalty, and trains always take the path with the lowest penalty.
Yes, I believe this is the key to doing what I had intended.

Thanks.

MarkShot
Engineer
Engineer
Posts: 118
Joined: 27 Mar 2019 11:30

Re: How to keep the main line (trains) rolling?

Post by MarkShot » 28 Apr 2019 14:44

Before I retired, I was in management and systems design.

Has anyone tried to reduce these problems to queuing theory and mathematical analysis?

Transportman
Tycoon
Tycoon
Posts: 2687
Joined: 22 Feb 2011 18:34

Re: How to keep the main line (trains) rolling?

Post by Transportman » 28 Apr 2019 19:11

rowdog wrote:I believe that your "race track" is what is commonly referred to as a cyclotron.
https://wiki.openttd.org/Cyclotron
What MarkShot wants is basically the inverted cyclotron. The idea behind the cyclotron is to only allow trains onto the mainline if there is a suitable gap and keep their speed while waiting to keep all trains running at full speed, but in this case, the mainline is the cyclotron and only if the sideline is free trains are allowed to leave.
Coder of the Dutch Trackset | Development support for the Dutch Trainset | Coder of the 2cc TrainsInNML

User avatar
acs121
Tycoon
Tycoon
Posts: 1933
Joined: 03 Nov 2017 18:57
Location: Courbevoie, near Paris, France

Re: How to keep the main line (trains) rolling?

Post by acs121 » 28 Apr 2019 20:03

By the way, you should have quadruple track and 1-tile signal density on your busy lines. If you don't have JGRPP, avoid tunnels and bridges at all costs. Also, your curves shouldn't slow down your trains. Make them the length of your trains (I use 5-tile trains generally so it turns out to be easy for me, but it may be difficult with longer trains).

MarkShot
Engineer
Engineer
Posts: 118
Joined: 27 Mar 2019 11:30

Re: How to keep the main line (trains) rolling?

Post by MarkShot » 29 Apr 2019 07:28

Yes, Transportman has got it.

It is the mainline which must NOT slow or backup. The sidelines are to be viewed as independent subsystems connected to the mainline. So, the mainline traffic should be architected to have traffic of a consistent speed.

I am running OTTD-JGR 0.30.3. So, my bridges and tunnels have signals.

My one concern about the changes proposed below. Will these have a broad impact on many other aspects of the game?
Transportman wrote: You might want to look at this page. It is a bit of complex material, but in your case, it would be reduced to the following:
  1. Set the setting yapf.rail_firstred_twoway_eol in your openttd.cfg to true
  2. Place a two-way signal on your sideline and have the next signal on the sideline be at least one train length ahead
  3. Place a one-way signal on your bypass and continue with the usual signal distance you use on your mainline
What this does, is when your sideline-entry is blocked by a train, all other trains do not consider the sideline because the two-way signal is red and because of the yapf.rail_firstred_twoway_eol-setting, it is considered the end of the line and has an infinite penalty for the pathfinder. Because your mainline has a one-way signal, it is not considered the end of the line, and has a lower penalty, and trains always take the path with the lowest penalty.

Transportman
Tycoon
Tycoon
Posts: 2687
Joined: 22 Feb 2011 18:34

Re: How to keep the main line (trains) rolling?

Post by Transportman » 29 Apr 2019 17:27

MarkShot wrote:Yes, Transportman has got it.

It is the mainline which must NOT slow or backup. The sidelines are to be viewed as independent subsystems connected to the mainline. So, the mainline traffic should be architected to have traffic of a consistent speed.

I am running OTTD-JGR 0.30.3. So, my bridges and tunnels have signals.

My one concern about the changes proposed below. Will these have a broad impact on many other aspects of the game?
Transportman wrote: You might want to look at this page. It is a bit of complex material, but in your case, it would be reduced to the following:
  1. Set the setting yapf.rail_firstred_twoway_eol in your openttd.cfg to true
  2. Place a two-way signal on your sideline and have the next signal on the sideline be at least one train length ahead
  3. Place a one-way signal on your bypass and continue with the usual signal distance you use on your mainline
What this does, is when your sideline-entry is blocked by a train, all other trains do not consider the sideline because the two-way signal is red and because of the yapf.rail_firstred_twoway_eol-setting, it is considered the end of the line and has an infinite penalty for the pathfinder. Because your mainline has a one-way signal, it is not considered the end of the line, and has a lower penalty, and trains always take the path with the lowest penalty.
It will not have a broad impact, unless you use two-way signals everywhere. But it is very unlikely that you have that as there are very few instances where two-way signals make sense (as they are all block signals, any train in the block will block the entire block) so the only impact on your games is that you need to change all signals where you want to say DON'T GO HERE IF IT IS RED to two-way.
Coder of the Dutch Trackset | Development support for the Dutch Trainset | Coder of the 2cc TrainsInNML

Eddi
Tycoon
Tycoon
Posts: 7410
Joined: 17 Jan 2007 00:14

Re: How to keep the main line (trains) rolling?

Post by Eddi » 29 Apr 2019 21:40

a less impactful approach would be to use exit signals instead of setting "firstred_twoway_eol", because there is a quite large "firstred_exit_penalty". you might have to do some adjustments to the crossings for this to work, as it is not an infinite penalty, but tweaking that value has a lower chance of destroying the flow elsewehere in your network.

the idea here is that the firstred_exit_penalty would get larger than the combined penalty of one roundtrip to get back to that signal, or through another overflow line, or whatever.
You might not exactly be interested in Ferion, but if you are, have fun :)

Post Reply

Return to “General OpenTTD”

Who is online

Users browsing this forum: No registered users and 4 guests