I’ve become interested in railroad shunting, in particular the Inglenook Shunting game. Could we have something like that for Valkyrie Transport?
Here is a game that may tell you everything you need to know about this topic: Beaver Games - Inglenook Shunting.
In the standard “Inglenook” form, we have a small railroad shunting yard, with a lead track that can hold the locomotive and up to three cars. There are three shunts, one that can hold up to five cars, and two that can hold up to three cars.
There is a locomotive and eight cars, five numbered one through five and five blank. The game starts with a random ordering of the cars in the top two shunts.
The locomotive can push and pull the cars. Locomotive and cars couple up when they bump each other. There are three uncoupling points, one at the outer edge of each shunt. These can be used to “cut the line”, so as to pull some of the cars out of the shunt but not all of them.
Our mission is to sort the cars to produce a train consisting of the five numbered cars in increasing numeric order, starting at the loco, 1, 2, 3, 4, 5.
We might script a game that just displays a shunt game on a panel and you can play it.
We might build a real shunting yard using the Valkyrie Transport code.
We might allow people to operate the shunting yard via a HUD or big control panel of some kind.
We might want to automate some kind of ongoing train assembly disassembly activity, to entertain and warp the minds of visitors.
We might want to build some kind of product involving shunting.
As to doing it in Second Life, with our existing VT code, questions include:
How can we uncouple and couple cars in a different order? Should we do it such that when cars bump they couple and with an uncoupling station like in the on line game? Some kind of menu on the cars?
How will the details of car order be properly communicated among all the cars? A given car may follow the preceding one, or may be following the locomotive at a long distance, depending on which version of our code we’re running. (I almost regret allowing that to happen.) In either case, the following distance involves at least the length of the current car and the preceding car, or, in the case of long-distance following, all cars preceding the current.
When we uncouple car N, all the cars from N on back should no longer follow the locomotive. If they’re following each other, no problem. If they’re following the locomotive, they all have to be informed to stop that right now.
If we were just implementing a human-controlled system, it would suffice to provide robust uncoupling and recoupling. We already have forward and backward operation, and switches, or as they are called outside the US, “points”. I am pretty sure that decent coupling capability is all that would be needed.
However, I am quite interested in an automated player that can control the shunting in at least as complicated a situation as standard Inglenook. That complicates things, because that player needs global information about the state of all the cars and shunts. That information is quite abstract compared to the details of the coordinates and rotations of all the cars and loco, which is what a train actually knows now.
So, just now today, I am interested in what kind of data structures and operations would be useful for representing the state of the “game” and for specifying operations that need to take place.
I’ve played the online game a bunch, and I’m getting kind of good at it, but honestly I don’t yet fully understand my own strategy. Let me try to see what I do …
I kind of look for pairs that are out of order and there is a standard kind of shuttling move where if the order you have is 5, 4, you park the 4 on one shunt, the 5 on the other, then go get the 4 and attach it to the 5 in the right order.
You can only process batches of three or less, because if you move four cars onto the lead track, the fourth one overlaps the switch and you can’t change tracks. So if you need to work on the cars toward the end of the line, you need to more the nearer cars off to a shunt.
If the next move after that is to be useful, I think you must leave at least one open space on each of the shorter shunts. That’s necessary if you’re going to do a swap.
If, on the other hand, you’re trying to dispose of a blank obstacle car, you’d really like an empty shunt, so that you can push the empties to the rear.
But there are things I still just wonder about.
If the last car in the long shunt is blank, is it always OK to just leave it there, or are there times when you’ll have to clear it?
Note that there are “style points” for getting all the blanks onto the third siding before finally hooking up your whole winning train. Is it possible to win with all three blanks in the long siding instead of the third?
Today I’m mostly interested in how we might represent the Inglenook Siding game in an SLua script, and how we might devise a solver. Somewhere back in my history I actually studied heuristics and maybe I can remember how to put them together to try to solve something. Or invent something. Or find something on the Internet to copy.
We have a locomotive, five numbered cars and five blank cars.
There are four main track segments, a five-car shunt, two three-car shunts, and a “lead” track that has room for the loco and three cars.
The initial setup has five random cars in the top shunt and three random cars in the middle one, nothing in the third, and the loco down in the lead track.
Possibly we can ignore the locomotive by treating the lead track as being of length three. Probably not, because the locomotive does constrain what units can be moved and where they can be moved to.
There are the two switches, which amount to Y-connections with only one path open. They are long enough to hold the loco or car, actually a bit longer than a single unit length, at least in the game we’re looking at. A switch will not operate if any part of a car or loco is in it.
Will it suffice, for an internal model of the game, to treat all these locations as fixed elements, with each car or loco always in one and only one location? Can we ignore the overlapping situation and just consider what amounts to the center of each loco or car? My intuition says that we can, for modeling purposes.
This morning I only have questions and vague notions. My plan for the next phase is to draw some pictures that show what segments are connected and then imagine moves that can and cannot be made. I am vaguely thinking that a “move” consists of starting with one connection picture, picking up one or more cars, drawing them into the lead, then changing the connections and putting one or more of those cars somewhere else. I’m not sure how we’ll decide which moves are making progress and which are not. One needs a measure of desirability for an arrangement, some kind of metric of “value” or “goodness”.
If there was a measure like that and if we could compare any two adjacent configurations and decide which one was better, a simple hill-climbing algorithm would suffice. I am almost certain that no such thing exists, because if it did, there would be a writeup somewhere. Instead there are even recent contests with real money payouts for solutions to the problem.
I’m not in it for the money, but for the fun. So far so good.
Safe paths!