TL;DR - Described a system which allows to select destination station in runtime using combinators.
Also, I'm assuming you are familiar with combinators, trains and at least once you tried to switch off a train stop.
To understand the further system you have to keep in mind these facts:
- A parked train ignore all changes in its route until it leaves the station.
- A parked train will wait until all leaving conditions are met even if its station is disabled.
- If the destination station is disabled during the trip the train switches to the next available station in its route.
- During this "switching" train may lose all its speed if the new destination station is:
a) unreachable (no path)
b) new path differs from the previous path
- Red rail signal placed in front of the station stop prevents train from any movement.
Let's start. First of all, ALL trains (except static trains in case of a mixed system) in the proposed system have exactly the same route and it looks like this (obviously it is not limited with 6 stations, this just an example):
1 2 3 4 ... - different stations in system.
1' 2' 3' 4' ... - "shadows" of the real stations.
The core operation of this system is a "shifting" operation: all real and shadow stations sequentially changes their state to opposite in the next pattern: N-th shadow station, N-th station, (N-1)-th shadow station, (N-1)-th station, (N-2)-th shadow station, (N-2)-th station, ... , 1-th shadow station, 1-th station.
All trains that went to K-th station before shifting will be sent to K-th shadow station after shifting.
- When any train is ready to leave its station it initiates a shifting operation.
- First shifting operation (station -> shadow station). During shifting each station will "release" its train (if it is ready to leave) if the destination station is the next station for a parked train.
- Applying inverted shifting (shadow station -> station). Inverted shifting can only descend train (for example: "2" to "3"/"4"/"5").
When direct shifting and inverted shifting used together we may redirect each train from any station to any other station.
And what happens to the other trains during shifting?
- Nothing, because
a) their destination station is always enabled (either shadow station or real station),
b) their path is always identical (because shadow station is placed right next to the real station).
As a result they won't notice any shifting or changing in their path
Although it is quite complex to entirely understand this system, but it is surprisingly easy to build it.
The entire system consist of 5 combinators per station + 7 combinators for shared logic.
Station consists of:
- memory cell (to store what station is enabled shadow or real, 2x combinator)
- circuit to identify what shifting is required (direct or inverted, 3x combinator)
- also, station should have some circuits for
a) setting destination (this may be a simple constant or something more advanced)
b) leave condition
For a testing purpose I've built a small system:
6 different station + 4 dynamic trains.
1, 2, 3 stations change their destination in a "splitter" way (first train is send to the left station, second train - to the right).
4, 5, 6 redirects all trains to 2, 1, 3 respectively.