In my Original Message from a few years ago (pre-pandemic), I described a scripting language and a program (RTC) that could control MTH engines on your layout.
During that last few pandemic years, I've spent time enhancing the language, fixing bugs, and writing new scripts that demonstrate how to control a layout.
By throwing the right switches, my layout models the Pittsburgh & Lake Erie point-to-point railroad between McKees Rocks and Youngstown. It passes through my hometown of Aliquippa, serving the former Jones and Laughlin Steel Corporation mill there. I model three sidings at J&L, at College and at Struthers. Of course, the real P&LE was much larger than this but there is only so much you can model in O-scale.
Then by throwing a balloon switch, I can magically connect McKees Rocks and Youngstown with a worm hole that turns the layout into a continuous running loop configuration with three sidings (I call that connection the Lionel-Ives block in honor of Frank Ellison who had such a connection on his Delta Lines layout).
(For larger image, click on the link)
http://www.silogic.com/trains/...20Single%20Track.jpg
My latest script "Engineer on Board". This video shows a screen capture of a run with 4 engines, 2 eastbound and 2 westbound. I'm running 5 scripts at once. The first "Layout4 APB Master" controls the signals. Each of the other 4 scripts control one engine. The 4 scripts are identical, each initialized with an engine number, its direction, and its starting block.
Westbound trains are superior and always take the main at each siding. Eastbound trains always take the siding. Westbound trains are allowed to make headway when possible. That is, they can follow close behind another westbound train. Eastbound trains are required to be able to reach the next passing siding otherwise they are held up until the necessary blocks clear.
The four trains can start in any four blocks that they could occupy during normal running. That is, you can't start them in a deadlock which can never be reached. If you watch this video, it shows messages and signal indications for the four trains.
This video shows the layout view of the 4 trains running around the layout under control of the 5 scripts running on the RTC program.