The Trainz AI is a very powerful, very flexible system. However, this complexity and power can lead to perceived unreliability and recurring problems. Without a clear understanding of what it is doing and why, these problems can prove to be frustrating and difficult to solve.
All AI orders that cause the AI to do some driving operate in much the same way. A route is calculated for the AI to follow, in the form of a list of actions (mostly of the form "take junction X in direction Y"). Then the AI is asked to complete that list of instructions. This will run until it either completes the list, or gets completely stuck and gives up. If it gets completely stuck, the order will try to re-calculate the route from its current location, and it will try again.
Making the list of instructions is done with a breadth-first search, to find the shortest path to the destination. Note that the shortest path will generally use the inside route on multiple track curves, and will change direction and go backwards if it thinks it can get there via a shorter path that way. If your route is more at the 'model railway' end of the scale and has a looped track, you may even find the AI decides to drive backwards around the circuit rather than forwards.
The AI Direction marker
The AI direction marker tells the AI which way traffic is expected to flow on a specific track. It should be considered as a "No Entry" sign. It applies at the junction that the pointy end of the marker points towards. It tells the AI not to plan a route which crosses that junction and enters into the one-way track in the "wrong" direction.
Note that it doesn't affect an AI that already started on a specific track, e.g. at the start of a session.
Also, it does not convey additional priority information. If there are three tracks between A and B, an 'up' line with a track direction marker preventing trains from B from entering the line, a 'down' line with a track direction marker preventing trains from A from entering the line, and a reversible line with no markers; an AI at 'A' will not prefer the 'up' line to the reversible one. It will pick the shorter route, whichever this happens to be. You might want to consider using a track priority marker instead to help with this case.
The Track priority marker
Trainz allows track to be tagged with a 'priority' level – 1, 2, or 3. Both track and trains default to 'priority 2'. AI trains can also be allocated a priority, and AIs will prefer to use tracks of their own priority.
If you were to set high speed lines to have priority 1, normal lines to be priority 2, and freight yards and loops to have priority 3, a train with a priority of 1 will try to use the high-speed lines wherever possible, and a train with a priority of 2 will try to stick to the standard lines (avoiding both the high speed lines and the yards and loops). A train with priority of 3 will try to avoid using the mainline (in this example, this might be a good idea for a yard shunter, which will then prefer not to block the mainline if at all possible).
Note that the priority setting has nothing at all to do with which AI gets to go first at a junction when there is a conflict – it only affects the routing of trains along different tracks. If you want to control which AI gets to go first over a junction, you'll need to do that by issuing a sequence of AI orders that will achieve that result, e.g. by making one train wait for the other to pass before continuing.
'Drive ...' and 'Navigate ...' orders
The difference between the 'drive' and 'navigate' commands is how they calculate the route ahead when they see other traincars on the track.
'Navigate ...' will attempt to route around other traincars. 'Navigate ...' orders can get an AI to pick its way through a full yard, working around all the other traincars. However, because AI orders calculate paths when they first start running, if the other traincars have moved by the time the AI gets to that location, it will still take the loop, and things can look rather odd.
'Drive' doesn't attempt to route around other trains at all. It expects to queue up behind the train in front, and will continue on when it moves. This solves the problem where 'Navigate' will appear to take loops at random, and in a busy mainline situation 'Drive' can produce reliable, predictable pathing which 'Navigate' orders will not. However, trying to use 'Drive' in a yard, where the other traincars won't move out of the way will result in a stuck AI waiting for a stationary consist to be moved out of its way for it.
You will need to use 'Navigate' wherever stationary traincars will be encountered - all yard movements, switching operations, and so on. 'Drive' is best in a multiple track mainline situation where tracks are operated in one direction only. Where you have a reversible mainline (e.g. single track with passing loops), you'll need to experiment, and decide which one is best at each point in the schedule.
These orders also come in '... via trackmark' versions. The 'via' versions complete early, when the '... to trackmark' version would have started braking. This allows them to hand off at speed to the next order rather than forcing the train to slow down.
All AI orders that cause the AI to do some driving operate in much the same way. A route is calculated for the AI to follow, in the form of a list of actions (mostly of the form "take junction X in direction Y"). Then the AI is asked to complete that list of instructions. This will run until it either completes the list, or gets completely stuck and gives up. If it gets completely stuck, the order will try to re-calculate the route from its current location, and it will try again.
Making the list of instructions is done with a breadth-first search, to find the shortest path to the destination. Note that the shortest path will generally use the inside route on multiple track curves, and will change direction and go backwards if it thinks it can get there via a shorter path that way. If your route is more at the 'model railway' end of the scale and has a looped track, you may even find the AI decides to drive backwards around the circuit rather than forwards.
The AI Direction marker
The AI direction marker tells the AI which way traffic is expected to flow on a specific track. It should be considered as a "No Entry" sign. It applies at the junction that the pointy end of the marker points towards. It tells the AI not to plan a route which crosses that junction and enters into the one-way track in the "wrong" direction.
Note that it doesn't affect an AI that already started on a specific track, e.g. at the start of a session.
Also, it does not convey additional priority information. If there are three tracks between A and B, an 'up' line with a track direction marker preventing trains from B from entering the line, a 'down' line with a track direction marker preventing trains from A from entering the line, and a reversible line with no markers; an AI at 'A' will not prefer the 'up' line to the reversible one. It will pick the shorter route, whichever this happens to be. You might want to consider using a track priority marker instead to help with this case.
The Track priority marker
Trainz allows track to be tagged with a 'priority' level – 1, 2, or 3. Both track and trains default to 'priority 2'. AI trains can also be allocated a priority, and AIs will prefer to use tracks of their own priority.
If you were to set high speed lines to have priority 1, normal lines to be priority 2, and freight yards and loops to have priority 3, a train with a priority of 1 will try to use the high-speed lines wherever possible, and a train with a priority of 2 will try to stick to the standard lines (avoiding both the high speed lines and the yards and loops). A train with priority of 3 will try to avoid using the mainline (in this example, this might be a good idea for a yard shunter, which will then prefer not to block the mainline if at all possible).
Note that the priority setting has nothing at all to do with which AI gets to go first at a junction when there is a conflict – it only affects the routing of trains along different tracks. If you want to control which AI gets to go first over a junction, you'll need to do that by issuing a sequence of AI orders that will achieve that result, e.g. by making one train wait for the other to pass before continuing.
'Drive ...' and 'Navigate ...' orders
The difference between the 'drive' and 'navigate' commands is how they calculate the route ahead when they see other traincars on the track.
'Navigate ...' will attempt to route around other traincars. 'Navigate ...' orders can get an AI to pick its way through a full yard, working around all the other traincars. However, because AI orders calculate paths when they first start running, if the other traincars have moved by the time the AI gets to that location, it will still take the loop, and things can look rather odd.
'Drive' doesn't attempt to route around other trains at all. It expects to queue up behind the train in front, and will continue on when it moves. This solves the problem where 'Navigate' will appear to take loops at random, and in a busy mainline situation 'Drive' can produce reliable, predictable pathing which 'Navigate' orders will not. However, trying to use 'Drive' in a yard, where the other traincars won't move out of the way will result in a stuck AI waiting for a stationary consist to be moved out of its way for it.
You will need to use 'Navigate' wherever stationary traincars will be encountered - all yard movements, switching operations, and so on. 'Drive' is best in a multiple track mainline situation where tracks are operated in one direction only. Where you have a reversible mainline (e.g. single track with passing loops), you'll need to experiment, and decide which one is best at each point in the schedule.
These orders also come in '... via trackmark' versions. The 'via' versions complete early, when the '... to trackmark' version would have started braking. This allows them to hand off at speed to the next order rather than forcing the train to slow down.