The scheduling gets interesting when two or more trains need to take the same tracks to get to their destination. The trains shall not have to wait too long nor take unnecessary detours.
A train can have one of the following four statuses:
A parking train just sits around and has nothing to do. It can be moved if the section it occupies is needed by another train.
A halting train will start moving again after a period of time (maybe to let passengers get in and out).
A waiting train has a destination that it can not yet reach as the section it needs to use is occupied / blocked.
A moving train is on the way to its destination.
A section is a set of tracks between tow points that can only have multiple trains using it if they all drive in the same direction. Otherwise only one train at a time is allowed to be an a section. Tracks with points on them are a section by them self.
A section can take on of four possible statuses:
- Not blocked
- Blocked only in forward direction
- Blocked only in backward direction
If a section is not blocked the scheduling is trivial as a train can use the section without any problems.
If a section is blocked in one direction a second track is allowed to drive behind the train blocking the section while keeping a safe distance to the train in front.
If a section is blocked a not moving train occupies the section.
A train can only have a train station as destination, but it can specify a favored platform. If the scheduler can not send the train easily (will be defined later) to the favored platform it will try to reroute it to a different platform.
There are three train stations:
If a train has to be re-routed because it favored station can not be reached it shall get a platform that is as close as possible.