This is where i will show the logic behind moving the train on each track.
Before a train can move it must check a certain number of things:
First:
The direction of the train. (Clockwise or Counter-Clockwise)
Second:
That specific trains current location (the track it is on, and what point on that track)
Third:
Is there a train on my current location or my next location
Once these two things are determined, the constant track point checks are underway, seeing if the train has crashed or gone off the rails or can move on unimpeded.
(if it is going clockwise)
if the train is on the start of that track, go to the middle of that same track.
if the train is on the middle of that track, go to the end point
if the train is on the end of the track, (check if it is a switch rail and it has been changed on you before: ) look to the supposed 'next' track
The only difference for the counterclockwise logic is that the end and start reactions are swapped (in other words, if you are at the start, look for the next)
This is a picture showing the logic of the grid and the points on each part of the grid are the midpoints.
Below that are each of the types of tracks and where each point 'end' or 'start' is with respect to the middle.
First:
The direction of the train. (Clockwise or Counter-Clockwise)
Second:
That specific trains current location (the track it is on, and what point on that track)
Third:
Is there a train on my current location or my next location
Once these two things are determined, the constant track point checks are underway, seeing if the train has crashed or gone off the rails or can move on unimpeded.
(if it is going clockwise)
if the train is on the start of that track, go to the middle of that same track.
if the train is on the middle of that track, go to the end point
if the train is on the end of the track, (check if it is a switch rail and it has been changed on you before: ) look to the supposed 'next' track
The only difference for the counterclockwise logic is that the end and start reactions are swapped (in other words, if you are at the start, look for the next)
This is a picture showing the logic of the grid and the points on each part of the grid are the midpoints.
Below that are each of the types of tracks and where each point 'end' or 'start' is with respect to the middle.