The Inglenook puzzle is a basic train shunting puzzle. The real world problem is to build a train of boxcars, in the best order for delivery of goods along the train's rout. In the puzzle available boxcars are on three sidings. A google web search will reveal several websites and videos describing the puzzle, variation and other's implementations. 


My approach is to write a computer control program to solve the puzzle and control a model railroad executing the solution. Working on my other 'control process' project, Train Thing, I stumbled onto the Inglenook puzzle. I was/am having trouble with the Train Thing, controlling four trains to follow randomly assigned overlapping/intersecting paths in a non-deterministic manner, along with graphics. The Inglenook puzzle looks like a simpler process to work on while developing the needed skills to then apply to Train Thing.


Basic puzzle graphic


This screen shot illustrates part of my solution to the Inglenook puzzle. The color coded boxcars are shown in a random starting order. The colored numbers show a random order for the boxcars to solve the puzzle. At the top, sidings 1 and 2 can each hold at most three boxcars. Siding 3 can hold at most five boxcars. On the right is the head shunt, which can hold at most three cars along with the switcher/locomotive. The two red 'track' switches, or turnouts, are used to connect the head shunt with a siding so cars can be moved between them. At the end of a move, when the switcher is back on the head shunt, rolling stock cannot be sitting on a turnout. 


My plan is to use this software as a stand alone simulator and secondly as a driver/controller of a model railroad implementing the Inglenook puzzle.


I plan on 4 modes of operation for my inglenook application; 2 automatic modes where the computer solves the puzzle, and 2 manual modes where the user can enter moves, one at a time, to solve the puzzle. In one pair, an automatic and a manual mode, you can enter the starting order of the boxcars. In this case the solution is to place the cars in natural (1,2,3...) order. The other two modes start with the boxcars in the saved order from the previous run. The solution order is randomly selected by the computer and saved as the starting order for the next run.


User move input screen


In this example of a user entered move, two boxcars will be moved from siding three to the head shunt. "Move from siding 3, 2 boxcars."


Another way to look at the four modes of operation is:


  • Mode 0: You can enter the starting order of the boxcars. (It is assumed that when starting the Inglenook puzzle, the HOG {Hand Of God} has placed the boxcars on the track in some order, unknown to the computer.) If the starting order of the boxcars is not given, the saved order from the last run is assumed. When started the computer determines the moves to place the boxcars into 1,2,3... order solving the puzzle. As each move is determined the laptop graphics are updated executing the move, and commands are sent to the model RR layout executing the move. The order for the solution is saved.
  • Mode 1: The saved solution from the last run is assumed to be the starting order for the boxcars in this run. A random order for the boxcars is selected to solve the puzzle. This order is saved to be used as the starting order for the next run. The computer determines the moves and executes the moves in the graphics and model layout to solve the puzzle.
  • Mode 2: As in mode 0, enter the starting order of the boxcars, or not. The user uses the screen area shown above to enter each move to get the boxcars into 1,2,3... order solving the puzzle. The solution is saved.
  • Mode 3: As in mode 1, the saved solution from the last run is assumed to be the starting order (so the HOG does not need to get involved). The computer randomly selects an order for the eight boxcars to solve the puzzle. The user enters the required moved to solve the puzzle.


The Bulletin Board on the main TrainThing Menu includes an Inglenook Puzzle forum where you can enter comments and ask questions.