logoalt Hacker News

collabs • yesterday at 11:52 AM • 2 replies • view on HN

The way I think of it, divide the tracks into segments. Before you put a train on a segment, you must ask a question - is there a train on it. There are only two answers possible, No, and something else. If it is something else, stop. Don't let the train on that segment.

There are optimizations possible like make segments smaller etc but the original algorithm is trivial. If we can't figure things out, we make segments longer and we slow down the trains until we can. I am positive for a sufficiently large track segment and a sufficiently slow train, we can always answer the question with a no.


Replies

jdmichal • yesterday at 6:29 PM

You've "invented" interlocking railway semaphores, after which the computer science concept was named.

https://en.wikipedia.org/wiki/Railway_semaphore_signal

https://en.wikipedia.org/wiki/Interlocking

1718627440 • yesterday at 11:58 AM

Congratulation you are reinventing 1890 state of the art.

➕ show 1 reply