When building minecart tracks for distributing goods, one might sometimes want to route several lines across a common rail track. The problem then is separating the carts again so they go to their designated targets. There are of course several options, e.g. enabling the needed switches directly before giving the depart order, or using carts of measurably different weights, but since i found that minecarts follow exact build order rules to devolve their movements, i was sure carts' ages could be used as switch argument.
It wasn't easy, but i succeeded: one cart of four can be sent over a track into the switching array, and it'll be sent to the correct one of four destination bays, all through the magic of synchronised collisions.
track only
with constructions.
Not very transparent, i'm afraid.
How does it actually work?
First of all, we need a proper collision: two carts must try to move in a way that conflicts with the other's movement, _in the same game step_. In each such collision, the older cart will take its move first. If two carts are immediately adjacent and basically try to move into each other's location, this means that the older cart will push the younger cart. The enter movement pulse of the older cart will pass to the younger. The younger cart moves away from the collision, the older cart comes to rest in the location it reached before the collision.
Paths only to the left, relevant buildings for the collision to the right.
The "traffic" cart that's to be switched enters from the right. It's coming in very quickly in the given system, somewhere around 80.000 speed, gets stopped and turned around by a highest-speed roller, setting speed in the switch itself to 50.000. When it passes over the pressure plate next to the roller, the plate activates the (also highest-speed) roller to the left, where the resident switch-"operator" cart sits and opens the door right to the south of it. This accelerates the operator cart to highest-roller speed and lets it out onto the collision track, facing the traffic cart.
The collision is fully synchronous and thus the older cart will come to rest in the middle of the collision track, while the younger cart moves off. In the switches i built, the traffic cart has reached its destination when it stops, if it's "too young" yet, it gets pushed off to the east, around the corner and to the next switch cell. It gets accelerated quite a lot on those impulse ramps, because that helps with ensuring a regular speed from the next roller.
Obviously, the resting cart also needs to be moved out of the way; it wouldn't be much of an automatic switch if every switching operation would require a dwarven vehicle hauling job for cleanup. How to do this? Why, with two more rollers, of course:
In the middle of the collision track, over the two possible stop locations, there are two single-tile rollers, the one to the left pushes the operator cart west, the one to the right pushes the traffic cart to its destination path south. The cart that gets sent out from the collision will always move over a pressure plate actually switching these rollers on. They're off otherwise (they must be off so the carts can actually cross them to collide). The plate crossed by the operator cart _also_ toggles the gear connecting its "home" roller: it gets engaged by the traffic cart and would stay on for 100 steps otherwise, sending the operator cart around repeatedly. One hundred steps later, when the traffic cart's plate resets, the roller turns on again, but at the same time the door closes, so the cart can't move anyway.
For the scheme to work with four routes/carts, three cells are needed and the seven carts must be built in the order
T1
O1
T2
O2
T3
O3
T4
Cart weights should not affect the ability of the switches to tell carts apart, but the output speeds of the collision can vary a lot when different-weight carts collide. To avoid misdirected traffic and derailings, the operator carts should be much heavier than the traffic carts (more than twice as heavy), which means pushed operator carts will move extremely slowly, if at all. I built it all with absolutely same-weight carts (all made from bayberry wood) which completely removed that concern, but that's obviously not an option for material transport routes.
I had to put three medium-friction track stops into the third switch cell and needed to build a corner into the second cell's destination route (seen in the pictures) because for some unfathomable reason the N->S roller gave the (presumably) resting cart a minimally diagonal push (but only in this cell, not in the others). This was likely all caused by letting carts run into working rollers full-throttle, resulting in weird distance offsets.
Actually getting the construction right with such a "just passing through" cart is quite tricky, because carts still calculate distances normally when moving over rollers; a wrong setup can give you impractically slow carts (much slower than the roller set speed) or errors caused by incompatible distance off-sets on the collision rail, where one cart invariably ends up a full step ahead of the other, so the collision's no longer synchronous. For an easier approach, the traffic cart should be fully stopped before being sent onto the collision rail, e.g. by temporarily switching off the incoming roller and letting the cart run into a wall behind it. That fully zeroes speed and apparently normalises position to the middle of the tile.