Posted 26 November 2013 - 11:19 AM
Here is how I would set up the "Dispatch" (AI Dispatcher) system. The way most railroads establish train superiority is by right, class, and direction. Even in CTC systems, the Dispatcher will try to adhere to that hierarchy. In OR, it could work like this:
I would establish train superiority using a point system--the train with more points being superior to one with less. The default points assigned by the Activity Editor would be as follows, but could be altered by the activity developer. Let's start with direction. Superiority of train by direction is usually established by Rule or by Employee Timetable. In my "ABC Railroad" Employee Timetable, timetable westbound trains are superior to timetable eastbound trains of the same class. (In this lexicon, there are no northbound or southbound trains, they are either eastbound or westbound no matter their compass direction.) So, an eastbound train would get 0 points for direction superiority and westbound trains would get 10 points. Next would be class. There could be numerous classes of trains, but, for my example, there would be four--Passenger train, fast freight, slow freight, and local freight. The lowest class, the local, would get 0 points, the slow freight 100 points, the fast freight 200 points, and the passenger train 300 points. Finally, there would be right superiority--for example, a train with rights over all other trains would be given 1,000 points. At each passing point, the AI would evaluate the points of the AI trains and the player train and give superiority to the train with the most points at that moment.
So, for an example, let's say the player train is a westbound slow freight. It would get 110 points. There are 4 AI trains, an eastbound passenger train (300 points), a westbound local freight (10 points), an eastbound fast freight (200 points), and a westbound officer's special with rights over all trains (1,010 points). So, during the activity, the slow freight player train would have to clear for the EB fast freight and the eastbound passenger train, and the westbound local freight would have to clear for the player train if the system determined that the player train would overtake it based on average speed of both. Similarly, the player train would have to clear for the officer's special when the special would overtake it. Since the system would be dynamic, with the AI evaluating the points and average speed of trains at each passing point, meets could be scheduled according to the progress of the various trains. For example, two westbound freights with equal priority could proceed across the line in sequence, but, if the first train was moving at a slower average rate than the second, the second train could overtake the first at a passing point.
As for manual switching, taking the switches to manual operation would place the player train at 0 points until the automatic switches were restored, meaning that the player train would have to stay out of the way of all other movements until it finished its switching and the switches set back to automatic.
Changing priorities during an activity could be done through what basically would be equivalent to a train order or track warrant system. For example an eastbound train could be given superiority over other traffic to a certain passing point, where its points could be changed to a lower number, or even dropped to zero until a triggered event occurred--for example the arrival of an opposing AI train. This would be equivalent to a "not effective until the arrival of" train order or track warrant.
The entire system could be based on a mathematical hierarchy, combined, when necessary, with some "if/then/else" statements that could be invoked at certain points. I don't think that it would be that complex to program, but I freely admit to not being an expert in that area.