JanetRossini.github.io

Lua, LSL, Blender, Python in Second Life


Project maintained by JanetRossini

Shunting Design?

May 5, 2025 • [designshunting]


Let’s think about the design a bit. I’m envisioning six separate segments where cars or locomotive can be located:

L L L L P1 S1 S1 S1 S1 S1
           P2 S2 S2 S2
              S3 S3 S3

THe game starts with cars filling S1 and S2, in some random order, and the loco somewhere in L.

It is legal to have things on the points but if there is anything on a point it cannot be switched, so we will generally be able to ignore that state and the solver should never create such a state.

When I’m playing the game, what am I thinking about? One common task is to swap some two adjacent cars that are in the wrong order in S1. If they are close enough to the front of the train and there is at least one cell available in each of S2 and S3, I can do it, like this:

  1. Couple up to S1, cutting after the second of the two;
  2. Drive down past the switches, set to connect to S2;
  3. Push cars into S2, cutting off the furthest one;
  4. Back away, set to connect to S3;
  5. Push remaining car into S3 and cut;
  6. Back away, set to S2;
  7. Go get the car that’s there;
  8. Back away, set to S3;
  9. Go get the car that’s there.

Now those two cars are in the correct order.

Let’s call the loco zero and the cars 1-5 and x x x. Empty spaces will be underbar. Suppose we have this:

LI: _ _ 0 _
S1: 2 1 3 4 5
S2: _ x x
S3: _ _ x

We might show the transformations something like this:

LI S1 S2 S3 action
___0 21345 _xx __x  
_021 345__ _xx __x Get 2,1 and pull back
___0 345__ 2xx __x Push 2 into S2
___0 345__ 2xx 1_x Push 1 into S3
__01 345__ 2xx __x Pull 1 out of S2
_012 345__ _xx __x Pull 2 out of S3
____ 12345 _xx _.x Push 1,2 up to 3,4,5

Train complete!

Digression: What am I up to?

The above was written on Monday. It is now Tuesday. Here’s what’s on my mind just now.

Based on the fact that I’ve been unable to find any usable code or algorithms for shunting, I’m pretty sure that the problem does not succumb to some algorithm the way that, say, Towers of Hanoi does, even though some of my moves in shunting do remind me of those moves in Towers, where you put the disc you’re thinking about on a post where you don’t want it, to clear the post for something you need to move first, and then you move the disc back. But Towers is just counting in binary, so the resemblance is pretty thin.

But as I play the game, I sense certain patterns, such as:

What I’m trying to come to with all this thinking is a sort of “language” of shunting. I’d like to have a way of expressing the situation that is easy to write, easy to read, and easy (enough) to process. I’d like to have a small set of “phrases” that are useful for expressing reasonable-sized steps toward a solution. Phrases like “stack #3 in shunt 2”, or “pick up #3”, perhaps.

In trying to think about this “language”, I think about how I’d like to tell someone else the moves to solve the game. “OK, let’s pick up the 5 and stash it in shunt 3”. As we played that way, I suspect we would make up new language, as we learned large patterns. “Let’s do a swap of the 3 and 2”. We’d probably come up with ways of expressing goals.

Take a look at this sample starting position:

game with 53x21 in the 5-cell and xx4 in the 3-cell

What might we say if we were planning how to attack this puzzle?

Now I’m going to try it and write down what I think and do:

progress

progress

progress

progress

progress

progress

progress

progress

We’re getting closer to a language. I don’t think we’re there yet: I don’t know how to write a script that understands plain English. But there are some common notions that might be showing up.

Summary — For Now

Maybe you begin to see what I’m trying to do. I’m trying to devise a way of expressing changes to the layout that make sense in terms of shunting, but that are simple enough that we can imagine implementing them as reasonably simple operations. We might even be able to express some commands as sequences of others. Kind of like macros or something.

Or just functions calling other functions, methods calling other methods.

If I can come up with a reasonable set of phrases and a reasonable way to represent the current state of the layout, it might, just might, be possible to make a little progress.

Caveat emptor, though. In view of the very limited amount of information about solutions, and in view of my very limited brain, I’m not optimistic about a full solution to even the simple Ingelnook case. But we might make some progress, and we will almost certainly at least come up with some convenient commands to provide to people who want to build a switch yard of their own.

We’ll see. So far, just learning.

Safe paths!