I feel like you are intentionally trying to turn this into a spherical cow situation by insisting on solutions that work in an information vacuum. All of this sort of problem in the real world is solved by sensor fusion from multiple data sources.
Trains are captive to a particular track - they can only change tracks at specific pre-determined junctions. With a pretty minimal sensor feed from each junction we can statically determine which track segment a given train is on. With GPS we can shrink that segment length down to a few kilometres. By sharing data persistently every single train can validate that central command-and-control is not about to run it into another train from behind...
There cases which are genuinely challenging engineering problems (i.e. derailments that impinge on adjacent tracks), but this trivial case of bumper cars is not one of them.
By enumerating the tracks?
I feel like you are intentionally trying to turn this into a spherical cow situation by insisting on solutions that work in an information vacuum. All of this sort of problem in the real world is solved by sensor fusion from multiple data sources.
Trains are captive to a particular track - they can only change tracks at specific pre-determined junctions. With a pretty minimal sensor feed from each junction we can statically determine which track segment a given train is on. With GPS we can shrink that segment length down to a few kilometres. By sharing data persistently every single train can validate that central command-and-control is not about to run it into another train from behind...
There cases which are genuinely challenging engineering problems (i.e. derailments that impinge on adjacent tracks), but this trivial case of bumper cars is not one of them.