
Playing with model trains and calling it graph theory - zdw
https://11011110.github.io/blog/2019/05/02/playing-model-trains.html
======
dekhn
The book Hackers has an entire chapter on the TMRC
[https://en.wikipedia.org/wiki/Tech_Model_Railroad_Club](https://en.wikipedia.org/wiki/Tech_Model_Railroad_Club)
engineers (students) build early track switching systems using relays and
mainframes (later I think it was transistors and later microcomputers). This
let them experiment with all sorts of train routing algorithms and those
students often went on to influential positions in the telecom and computing
industries.

~~~
jpmattia
While we're on the subject of ancient history, Prof Jim Roberge's course on
feedback systems (6.302) famously included a final lecture incorporating his
love of model trains.

The goal of the lecture was that the train should have a constant speed
despite hills introduced into the track. In order to measure the speed of the
train, he noticed that there was a small glitch that would occur as the
motor's armature switched polarity, and so a time measurement of the glitches
was proportional to the speed of the engine.

[I took the course in 85 and still remember it, so he left something of an
impression. A couple of generations learned analog feedback from this course.
RIP Prof Roberge.]

Edit: By some lesser miracle, his lectures are on youtube. The train lecture
was last.

[https://www.youtube.com/playlist?list=PLUl4u3cNGP62in17jH_Di...](https://www.youtube.com/playlist?list=PLUl4u3cNGP62in17jH_DiJMkCGNM6Xni-)

~~~
dekhn
Thanks, that's pretty cool. When I was a kid I could never get my model train
to go very fast. It wasn't until about 30 years later that I learned enough EE
to understand the problem. Eventually I learned enough to build a self-
balancing robot using PID control but I'm always amazed at college students
who can do this stuff easily.

------
vibrio
Thanks for this, I've been obsessing about track layouts while playing trains
with my kid, how to avoid getting stuck in permanent loops, having bi-
drectional routes on all parts of the track etc. As I'm not a math person,
I've not had a logical framework with which to think about it. my kid doesn't
care but laying out tracks been a surprisingly fun mind game for me.

~~~
grimjack00
You may want to search for "shunting puzzles", such as those here:
[https://www.transum.org/Software/Shunting/Puzzles.asp](https://www.transum.org/Software/Shunting/Puzzles.asp)

Every time my model train interest rises, I consider setting up a small layout
for puzzles like these.

~~~
m463
I've wanted to make timesaver for quite some time now.

------
mpettitt
It is surprisingly difficult to build train tracks given a set of parts, even
without taking junctions into account - there is a challenge about it on Stack
Overflow's Programming Puzzle site
([https://codegolf.stackexchange.com/q/116607/66060](https://codegolf.stackexchange.com/q/116607/66060))
and there is only one answer in the two years it's been there. In some ways,
real life engineers have it easier - they don't have to plan routes based on
the parts in the box!

~~~
Someone
Having only one answer in two years doesn’t imply the problem is hard.

I would think all ‘large enough’ puzzles of this kind are easy. You build a
rectangle (needs four corners. If you don’t have those, no closed curve is
possible), and use pairs of left-over curves to add detours to the straight
ends, possibly compensating for an odd number of straight edges. I would guess
there is an analog to Euler’s formula
([https://en.wikipedia.org/wiki/Euler%27s_formula](https://en.wikipedia.org/wiki/Euler%27s_formula))
that describes what number of small corners, large corners, and straight ends
can form a large closed curve.

I also suspect ‘large enough’ isn’t that large, probably everything over 16
pieces or so (Smaller problems may be non-standard because they require effort
to avoid overlap)

------
sand500
Reminds me of the lab I TA'ed college where we had to implement a track with 2
trains on it as a state machine and make it impossible for the two trains to
collide. We had to eventually implement this state machine in vhdl which was
then run on a fpga where we could simulate and control the trains:

[http://engineering.armstrong.edu/tom/engr2031/engr2031traina...](http://engineering.armstrong.edu/tom/engr2031/engr2031trainassignment.pdf)

------
inciampati
Train track graphs have applications in genomics, where they are used to build
pangenomic models in which the graph has two strands (like DNA). It's great to
see work on them is ongoing!

------
Sniffnoy
Oh man, so I'd actually been thinking about the question of what happens when
you actually play the game of Snake on an arbitrary graph:
[https://hjaltman.github.io/snake.html](https://hjaltman.github.io/snake.html)

Very interesting to see these results about the more basic model, where we
leave out the game part and just focus on movement! I may have to contact the
authors about this...

------
elsurudo
At UW (University of Waterloo), our Real-time OS class projects used physical
trains. Walking the halls of the Math & CS building, you could see kids
"playing with trains" all through the night quite routinely.

It had the reputation of being one of the hardest CS classes in the undergrad
curriculum.

------
elygre
I seem to remember an Alistair MacLean book where the secret messages (spy
business) were coded in a model train setup. It was then disguised in a set of
time tables that, when run, would end up with the train cars in a particular
order, and where the cars were encoded letters.

~~~
KineticLensman
I think you are thinking of The Enemy by Desmond Bagley. It’s on a book shelf
at home and I’m away so I can’t check. I recall that the murdered
industrialist actually uses a train set to encode an algorithm rather than a
code. Will have to check when I get back

------
dblohm7
This brings up fond memories of Waterloo's CS 452: Real-time Programming.

"Here, we've got this model train set hooked up to a PC with nothing on it.
Here are some specs. Write an RTOS and control program to make the trains do
something interesting."

------
martinlofgren
I thought a lot about this a few years ago when my son was very much into
building train tracks. I had just taken a first course in linear algebra and
started to work out a mathematical solution to this very problem. It is still
one of those projects I wish to complete... someday when there is more time.
Guess it will be when I have grandchildren.

------
new4thaccount
Wow ...I was building tracks with my toddler yesterday and wondering how to
not run into so many problems with not being able to complete an
interconnection. I had a feeling it was an open math problem.

------
dllthomas
I call it group theory when I play with my Rubik's cube.

------
mkagenius
Offtopic: I read it as model trains and calling it machine learning.. meh!

