Open Rails Perpetual Railroad / Activity Editor

Collapse
Only viewable if you're a logged in user
X
 
  • Time
  • Show
Clear All
new posts
  • Snowman
    Senior Member


    • Apr 2001
    • 211

    #1

    Open Rails Perpetual Railroad / Activity Editor

    Open Rails Perpetual Railroad and Activity Editor

    1.png

    The scope of this project is really two programs in one, so bear with me while I explain exactly what is being released here and why the first part was necessary to build the second. Part One: The Activity Editor

    2.png
    The first part is the Activity Editor.

    The obvious question is: Why build another activity editor?

    The answer is twofold. First, I wanted a modern replacement for the original MSTS Activity Editor that still behaves very much like the program we already know. Second, and more importantly, the Activity Editor became the foundation needed to build the Perpetual Railroad underneath it.

    The editor is basically a 1-to-1 recreation of the MSTS Activity Editor, but enhanced where needed with debugging tools, Open Rails features, and modern conveniences.

    It is not intended to completely reinvent activity creation. If you already understand the MSTS Activity Editor, most of this should feel familiar.

    Where it becomes considerably more powerful is troubleshooting. Optional AI Activity Debugging

    3.png

    The Activity Editor includes an optional AI-powered diagnostic system.

    The AI is read-only. It cannot modify your activity files, paths, services, consists, route files, track database, or anything else.

    Its job is simply to inspect what the editor and route are doing and help explain problems.

    It can troubleshoot things such as:
    • Path problems
    • Service problems
    • Missing or incorrect filenames
    • Activity file problems
    • Signal issues
    • Timing problems
    • Traffic problems
    • Consist problems
    • Event problems
    • Missing references
    • Track database problems
    • Junction and switch problems
    • Reverse points
    • Wait points
    • Deep-level track-node issues
    • Live editor state
    • Player and AI service relationships
    • Problems between ACT, SRV, PAT, CON and TDB files

    And quite a bit more.

    The purpose is to make activity creation and debugging as painless as possible.

    Instead of spending hours trying to figure out why an AI train refuses to move, why a path breaks at a particular switch, or why an activity behaves differently from what you expected, the debugger can inspect the underlying files and track topology and tell you what is actually happening.

    For people who do not want AI involved, the feature is completely optional.

    The Activity Editor itself does not depend on AI to create or edit activities. Open Rails Live Integration

    4.png

    The Open Rails API is also connected to the editor.

    This allows the Activity Editor to view the railroad while Open Rails is actually running, including things such as:
    • The live player train
    • AI trains
    • Signal states
    • Player paths
    • AI paths
    • Reverse points
    • Waiting points
    • Train positions
    • Other live simulation information

    One particularly useful possibility is diagnosing a troublesome activity while the activity is actually running in Open Rails.

    Instead of only examining the files before starting the simulator, the editor can compare what was supposed to happen with what Open Rails is actually doing. Open Rails-Specific Activity Features


    The editor also supports more advanced Open Rails functionality that goes beyond what the original MSTS Activity Editor was designed for.

    That includes features such as:
    • Join/Split
    • AI train horn blowing
    • Wait Until
    • Additional Open Rails activity options
    • Expanded activity diagnostics
    • Improved path and service inspection
    5.png

    Again, though, the Activity Editor was never the final goal.

    It was the groundwork for the second half of the project.

    Part Two: ORPR - Open Rails Perpetual Railroad NOTE: All of the following images are outdated and should only represent the idea of what were building not its current form.

    6.png


    ORPR, or Open Rails Perpetual Railroad, is exactly what the name implies.

    At the time of this post, it is an activity-driven perpetual railroad simulation.

    Rather than thinking of every Open Rails activity as a completely independent scenario, ORPR keeps track of the railroad between operating sessions.

    You finish one job, and the railroad continues from there.

    For example, suppose you run a local or turn job on Monday.

    You finish the activity, park the locomotive, leave cars at several industries, return empties to the yard, and shut Open Rails down.

    You do not play again until Wednesday.

    During that time, ORPR can simulate what happened to the railroad between Monday and Wednesday.

    It keeps track of things such as:
    • Freight cars
    • Locomotives
    • Consists
    • Loaded and unloaded states
    • Car locations
    • Engine locations
    • Industries
    • Industry production
    • Industry consumption
    • Scheduled trains
    • As-needed trains
    • Equipment servicing
    • Railroad operations

    When you come back Wednesday, the railroad has moved forward instead of magically resetting to Monday.

    Your next activity is generated from the railroad's new state.

    That is the basic idea behind the Perpetual Railroad.

    It sounds simple when described that way, but underneath it there is considerably more going on. ORPR Creates the Railroad Files for You

    7.png

    One important point I want to make clear is that ORPR is not simply keeping a database of what cars are where and then expecting the user to go into the Activity Editor and build everything manually.

    The program creates the necessary Open Rails/MSTS operating files itself.

    That means ORPR can generate:
    • Paths
    • Consists
    • Services
    • Traffic services
    • Traffic patterns
    • Player activities
    • AI train movements

    Those files are created from the current state of the railroad and the work that actually needs to be done.

    If an industry needs empties, ORPR can determine what equipment is available, where it is located, what train should move it, what path that train needs to use, what consist should be assembled, what service is required, what AI traffic needs to coexist with it, and then create the activity needed to actually run the job in Open Rails.

    The user does not have to manually create a path, then create a consist, then create a service, then create traffic, and finally put all of those pieces together into an activity every time the railroad needs another train.

    That entire chain is part of the Perpetual Railroad.

    In other words:

    The railroad decides what work needs to be done, and ORPR creates the Open Rails files necessary to make that work playable.

    Of course, all of those files can still be inspected in the Activity Editor, and that is another major reason the Activity Editor was built first.

    If ORPR generates a complicated switching job with several AI trains, reverse points, events, pickups, setouts and timing requirements, the same editor can be used to see exactly what was generated and diagnose it if something does not behave as expected. Industries Actually Generate Railroad Work


    Industries are not simply scenery or names attached to sidings.

    They can have operating characteristics.

    For example, a coal mine can produce a certain amount of coal over time.

    As coal production increases, loaded cars eventually need to be removed and empty cars need to be supplied.

    Those movements can either be scheduled or generated as needed.

    A power plant can consume coal.

    A factory can receive raw materials and produce outbound loads.

    A yard can classify and hold cars for later trains.

    An interchange can receive cars from another railroad.

    The idea is that the traffic exists because the railroad actually has a reason to move it.

    In very broad terms, think of it as something along the lines of:

    JMRI meets Activity Master on steroids.

    Except the railroad's state continues between activities. Scheduled and Unscheduled Operations


    Not everything on a real railroad runs exactly the same way.

    ORPR therefore allows trains to be both scheduled and demand-driven.

    You might have scheduled passenger trains and through freights that operate at defined times.

    At the same time, an industry might generate enough traffic that another local or extra movement becomes necessary.

    The railroad can therefore include things such as:
    • Passenger trains
    • Through freights
    • Locals
    • Yard jobs
    • Turn jobs
    • Industry jobs
    • Transfer jobs
    • Extras
    • Maintenance-of-Way trains
    • Special trains

    The program plans around all of them.

    And when one of those trains needs to exist, ORPR can generate the path, consist, service, traffic and activity structure required to actually run it. Locomotive Maintenance and Car Servicing


    The railroad also has to take care of its equipment.

    Locomotives can require things such as servicing, inspections, fuel, sand, or other maintenance.

    Freight cars can require inspections or repairs.

    Those requirements affect how equipment is assigned.

    A locomotive that needs servicing should not simply be treated as permanently available.

    A freight car requiring repair should not magically appear in the next train.

    This can create periods where equipment availability becomes tight and other periods where the railroad has plenty of capacity.

    In other words, the railroad can have busy periods and quiet periods instead of operating at exactly the same level all the time. Maintenance-of-Way Operations


    Maintenance-of-Way is also part of the operating model.

    For example, suppose an MOW train is going to be parked for the weekend.

    The program does not simply choose an empty track and forget about it.

    It can look ahead and determine whether that track is expected to be needed.

    If the track is going to be used Saturday morning to stage freight cars or assemble another train, the MOW consist should not be parked there Friday night.
  • Snowman
    Senior Member


    • Apr 2001
    • 211

    #2
    The same logic applies to equipment storage, staging tracks, industry tracks and yard tracks. Tracks Have Purposes, But They Do Not Have to Be Exclusive


    One of the more important concepts in ORPR is that tracks can have operating definitions.

    An industry can effectively "own" or prefer certain tracks, but that does not necessarily mean no other train can ever use them.

    For example, imagine a three-track section of railroad where the middle track is commonly used to sort cars coming from a mine.

    That track can be defined with things such as:
    • Preferred industry
    • Preferred direction
    • Preferred usage
    • Usage times
    • Capacity
    • Train restrictions
    • Temporary availability

    That does not necessarily make the track exclusively owned by the mine.

    At another time it might be used to hold cars for a later train.

    Those cars could be picked up by either an AI train or the player.

    It could also temporarily hold an MOW train, provided doing so does not interfere with future operations.

    The goal is to allow the railroad to use its infrastructure intelligently rather than treating every siding as nothing more than an arbitrary place to put cars. You Decide How Much Railroad to Simulate


    You also do not have to simulate an entire route.

    You can choose which tracks, yards and industries ORPR should care about.

    If you have a huge route but only want to operate one division, yard, branch or industrial area, the rest can simply be left out.

    Likewise, industries that you do not want involved in generated traffic do not have to participate.
    Railroad-Specific Operating Rules


    Another important part of ORPR is the ability to define rules specific to your railroad.

    These rules can be used when generating activities, paths, timetables, switching work, and train movements so that the railroad operates according to the practices you want rather than treating every track and location the same.

    At the moment, these rules still have to work within the capabilities of the Open Rails framework, so there are practical limits to what can be enforced. As Open Rails adds more functionality, additional types of rules can be added as well.

    For now, the system can handle many practical operating restrictions.

    For example, you might specify that:
    • Crew changes cannot take place within 300 feet of a certain grade crossing.
    • Cars being spotted on a particular siding must stop at least 50 feet before the end of the track.
    • A locomotive cannot be left beyond a specified point on a servicing track.
    • Certain tracks can only be used by trains below a defined length.
    • A siding may only be used during certain hours of the day.
    • A track may be available for switching during the day but reserved for through trains at night.
    • Certain locomotives, car types, or train types may be prohibited from specific tracks.
    • A train may be required to stop before a particular location rather than using the full available track length.
    • Specific tracks can have preferred directions of travel.
    • Cars can be required to remain a certain distance away from crossings, switches, structures, or other defined locations.
    • A track can have different restrictions depending on the time of day or the type of operation being performed.

    Distances, track locations, train lengths, time periods, and the type of restriction can all be defined by the user.

    These rules can also influence timetable and activity generation. If a train movement would violate one of the railroad's defined restrictions, ORPR can account for that while determining where trains stop, where equipment is stored, which tracks are used, and how the activity is constructed.

    The idea is to make these rules as specific to the individual railroad as practical.

    Every railroad has its own quirks, local instructions, preferred practices, and places where crews simply know, "Don't put the cars there."

    ORPR provides a way to teach the program those same rules.

    For now, this remains limited by what can realistically be represented and enforced inside Open Rails, but the rule system is designed so additional restrictions and operating practices can be added as those possibilities expand.


    The level of complexity is largely up to the user. Weather and Railroad Conditions


    ORPR can optionally connect to the internet for real-world weather information.

    The idea is not simply to change whether the sky is cloudy.

    Weather can affect railroad operations.

    The system can simulate conditions and events such as:
    • Washouts
    • Buckled track
    • Weather-related restrictions
    • Temporary slow orders
    • Track closures
    • Other operating restrictions

    Restricted zones can then be placed into the railroad automatically.

    The player does not have to manually invent every situation.

    You simply show up for work and deal with whatever condition the railroad has developed.

    The important part is that these events are random within rules based on reality, rather than simply being random nonsense. AI Horn Blowing


    If a route is a suitable candidate, ORPR can also account for AI horn blowing at crossings and other appropriate locations.

    The Activity Editor and route information provide the underlying infrastructure needed to identify where those actions should take place.

    The Goal Is Specificity


    The philosophy behind ORPR is to define the railroad as specifically as practical.

    You define:
    • Tracks
    • Track usage
    • Industries
    • Industry types
    • Track capacity
    • Operating preferences
    • Equipment
    • Services
    • Train types
    • Scheduling behavior
    • Restrictions
    • Railroad rules

    The program then uses that information to operate within the boundaries you established.

    And once those rules are established, ORPR builds the actual paths, consists, services, traffic and activities needed to carry out those operations.

    Will every decision be perfect?

    At this stage, no.

    There are simply too many variables involved in railroad operations to pretend otherwise.

    But that brings me to where the project is going next.

    Why the Activity Editor, AI Debugger and Open Rails API Were Built First


    A great deal of the Activity Editor work was done specifically because ORPR needed that foundation.

    Before attempting to dynamically operate a railroad, the program needed to understand how everything fits together.

    Activities connect to services.

    Services connect to paths and consists.

    Paths connect to the track database.

    Traffic interacts with paths, timing, signals and other trains.

    Events interact with other events.

    Industries interact with freight cars.

    Freight cars interact with trains.

    Trains interact with tracks.

    Tracks interact with everything.

    And because ORPR itself is creating the paths, consists, services, traffic and activities used by the railroad, it needs to understand those relationships deeply enough to create them correctly rather than simply throwing files together and hoping Open Rails accepts them.

    The AI debugging system helped provide another layer for understanding and diagnosing all of those relationships.

    The Open Rails API adds another important piece: live simulation awareness.

    The Perpetual Railroad can know what was planned, while the Open Rails connection can tell it what is actually happening.

    That opens the door to the next stage.

    The Future: A Live AI Dispatcher


    The eventual goal is for AI to act as a live dispatcher.

    Instead of every possible operating situation having to be explicitly programmed beforehand, the AI dispatcher will work within the railroad rules and boundaries defined by the user.

    It will be able to understand both the player trains and AI trains and react to what is happening in real time.

    A train is late.

    Another train is blocking a siding.

    An industry suddenly needs cars.

    A locomotive needs servicing.

    An MOW restriction changes how trains can move.

    A train needs to meet another train somewhere different from what was originally planned.

    Those are the types of situations where a dynamic dispatcher becomes useful.

    Trying to hard-code every possible combination of those circumstances while still making the railroad behave naturally becomes an enormous programming problem.

    AI gives the system the possibility of making those decisions dynamically while still operating inside explicitly defined railroad rules.

    What About People Who Do Not Want AI?


    This is something I want to make very clear.

    ORPR is being programmed to work traditionally as much as possible.

    The program does not need to simply hand everything to an AI model and hope for the best.

    The railroad simulation, industry system, equipment tracking, path generation, consist generation, service generation, activity generation, scheduling rules, maintenance logic and other core functions are being built as normal program logic.

    AI is an enhancement on top of that.

    Even the Activity Editor's AI debugger is optional.

    Could the Perpetual Railroad eventually lean very heavily on AI?

    Absolutely.

    It makes certain parts of the system dramatically easier to manage and allows the railroad to respond to situations that would otherwise require an unbelievable number of hard-coded rules.

    But the goal is still to make the underlying railroad system as functional as possible without requiring it.

    For people who have no interest in AI, that option remains there.

    I also do not really want this thread to become another general debate about whether AI is good, bad, evil, wonderful, or anything else.

    That is not the purpose of the post.

    The interesting part to me is what this particular technology allows us to do with Open Rails.

    Current Status


    At this point, the Activity Editor portion is essentially finished.

    The Perpetual Railroad portion is currently in testing.

    It has reached the point where I believe the railroad portion is useful enough to release on its own and continue improving it through updates as more systems are tested and expanded.

    AI integration will continue to enhance it over time, particularly once the live dispatcher portion begins taking shape.

    The ultimate goal is that, once everything is configured, you do not spend your time constantly building activities.

    You operate the railroad.

    You finish today's work and go home.

    While you are gone, the railroad keeps existing.

    When you return, locomotives are where they were left. Cars have moved or been loaded and unloaded. Industries have produced or consumed freight. Scheduled trains have operated. Equipment may need servicing. Maintenance may have occurred. Weather may have caused restrictions. New work may be waiting.

    ORPR looks at that railroad state, determines what needs to happen next, and then creates the paths, consists, services, traffic and complete Open Rails activity needed for you to perform that work.

    You load the generated activity and go to work.

    In other words, instead of starting another isolated scenario every time you open Open Rails, you come back to your railroad and ask:

    "What work do I have today?"

    And the railroad already knows.

    Future will include radio between other crews and the dispatcher including the player train and the AI trains also working defect detectors of all sorts.

    Comment

    • superheatedsteam
      Senior Member


      • Jun 2004
      • 757
      • Perth, WA, Australia.

      #3
      Wow. I don’t really drive trains but this is impressive. How does the interaction with AI work?

      Cheers,

      Marek.

      Comment

      • frliss
        Senior Member



        • Mar 2011
        • 894
        • MP44.2 Worcester, MA
        • General

        #4
        Is this program available for download, and if so, were?

        Fred

        Flashing Rear End Device

        Comment

        • gammaray84
          Member
          • Dec 2018
          • 176

          #5
          Sounds exactly what i need

          Comment

          • qballbandit
            5000 Post Veteran

            • Jan 2006
            • 6518
            • Elgin Il., USA.
            • MSOR

            #6
            Very, very cool! Thank you for your hard work on this. Looking forward to trying when available.
            Neil

            Chicago Railroading Fan

            Comment

            • SD40-2
              Senior Member


              • May 2010
              • 1009
              • Metairie, Louisiana
              • English, C++, HTML
              • General

              #7
              Very, very cool indeed. Definitely ideal for those craving a more Run8 style experience in Open Rails.

              Am I allowed to ask for a feature?
              Parker B. - A Misplaced Midwesterner.
              Also known as Mr. Two Bits and Mr. Squarewheels.

              Comment

              • UP6706
                Member
                • Jun 2026
                • 190
                • California, USA
                • English
                • General

                #8
                I downloaded your shape viewer and it's useful.

                Comment

                • Snowman
                  Senior Member


                  • Apr 2001
                  • 211

                  #9
                  Originally posted by SD40-2
                  Am I allowed to ask for a feature?
                  Of course.

                  I want to add as well that the program is two programs in one. It is an MSTS Activity Editor clone, but its a clone that makes the original editor more useful. For example you drop off 52 cars and now need to measure 52 cars from the next switch in order to place a reverse point. This can now be done with simply using the Players consist and displaying the two engines and the 52 cars. You simply click two points and it will give you the initial measurement. You then click and drag to adjust and now you have precise reverse points in seconds. You can also flip the consist and measure form the rear. You can as well use a standard measuring line that measures the track in a specific length specified, but this isn't helpful for mixed freights.

                  1.png
                  Also, if you misjudged your reverse point you can simply click it and drag it to move it.

                  2.png
                  3.png
                  That being said the activity editor will be released first as the perpetual railroad side is still a work in progress. Much closer to an activity editor being released than the perpetual railroad. The main problems are having the program work with complex moves as every industry can be different so what it does at that industry has to be known. Not only what tracks to use and what goes where, but what happens IRL not just a means to an end. I hope that makes sense. We have the ability to generate AI and player paths and to pickup, set off etc. We can reliably say what goes where and when. We can base needs off of schedule or demand. Its narrowing down industry specific moves and have the program make paths around that. Some of this is Open Rails limitations and honestly if you can create activities faster then that's the route for you anyway.

                  I am making the activity editor playback feature play activities in the 2D viewer and you can speed it up there and see if it works properly before saving. This will cut down on testing activities and for testing the perpetual railroad side of things.

                  This program will be a railroad in progress, but not my main focus at the moment, but I'm actively working on it. Any ideas are of course welcome and I welcome any "Yeah, but how will it do this?" as well.

                  Comment

                  • commec61
                    Member

                    • Dec 2004
                    • 165
                    • Davenport, FL
                    • English
                    • MSOR

                    #10
                    I think that your program looks very promising. Since it will be for ORTS will you also be able to have check boxes for AI horns at crossings with also the ability to choose US?
                    Steve
                    USAF Veteran

                    Comment

                    • SD40-2
                      Senior Member


                      • May 2010
                      • 1009
                      • Metairie, Louisiana
                      • English, C++, HTML
                      • General

                      #11
                      Originally posted by Snowman

                      Of course.

                      This program will be a railroad in progress, but not my main focus at the moment, but I'm actively working on it. Any ideas are of course welcome and I welcome any "Yeah, but how will it do this?" as well.
                      Could there be a sort of "Stasis" mode, where the railroad can be partially frozen between operating sessions, like how model railroads work? You have an operating session, and instead of the railroad continuing to operate, it's mostly frozen in time until you begin another session, with only the operations that require no equipment movement occurring, such as loading and unloading of cars.

                      Going further, could the entire railroad be completely frozen, have nothing happening between operating sessions?
                      Last edited by SD40-2; 09-28-2026, 12:00.
                      Parker B. - A Misplaced Midwesterner.
                      Also known as Mr. Two Bits and Mr. Squarewheels.

                      Comment

                      • eric
                        Owner/Admin



                        • Dec 2002
                        • 9471
                        • NS MP245.4 CNO&TP South District
                        • English, SQL
                        • General

                        #12
                        I like everything I see here.

                        Will this be open source code in GitHub by chance, and what language are you writing it in?

                        I think there's a lot of benefit in having a standalone activity editor, especially if you can reuse some of what's already in the ORTS codebase.
                        If you like what you see here at Trainsim.com, be it the discussions and knowledge in the forums, or items available in our library, I hope you'll consider a paid membership to help support keeping the site operating.... Thanks!

                        Comment

                        • pschlik
                          Senior Member



                          • Jun 2011
                          • 287
                          • Missouri
                          • MSOR

                          #13
                          Exciting stuff! I'm finding it interesting how creators are using external programs to take big complex ideas and distill them down to something even old versions of OR can understand. Scott's PolyVeg does all this computation to figure out where trees go, computation that OR doesn't (and arguably shouldn't) know how to do and doesn't need to know as the result is baked into a static shape, which is something OR understands quite well. A perpetual railroad session fits the exact same thought process, do all the things OR doesn't know (and maybe shouldn't need to know) somewhere else, then convert it to a form OR is set up to handle.

                          Not everything needs to be a feature that gets added then takes a year+ to come out in a stable version of OR and who knows how much longer than that to actually get noticed and added to some editor. Though I imagine there are some things where it would help to have OR know a little more, it is easier to justify adding that when there is already a prospective use case.

                          Contributing to ORTS since 2023
                          Find me on GitHub @SteelFill

                          Like what I do? Join my Patreon to help me do more!

                          Comment

                          • motormaster532
                            Senior Member
                            • Jan 2011
                            • 465
                            • New York

                            #14
                            This looks fantastic! I am tired of having to hand "tweak" my Activities for different days of the week,season,etc. One question: Will this "Perpetual Railroad" have the ability to run through different Routes. For example: Most of my Activities go in succession across several Routes,simulating a trip of hundreds or thousands of miles. Will this be able to be accomodated in the new "Perpetual Railroad",or would it just work for one Route only? Thank You VERY much for your hard work and brainpower for this,and for your generosity in providing it to us. Take Care.Brian

                            Comment

                            Working...