Skip to content

Sliding puzzles

Pieces are flat shapes in a tray. Mark where each piece starts and where it must end, and the solver finds the fewest moves that slide them from start to goal, one piece at a time. Pieces can carry others nested inside them when that is allowed.

Sliding puzzle by GiiKER Super Slide, a Sliding puzzle.

Sliding puzzle by GiiKER Super Slide.

You can try one now: download slide_klotski.xmpuzzle, a Klotski-style puzzle of ten pieces that the solver finishes in 81 moves.

A sliding puzzle has two kinds of shape:

  • Pieces are shapes, usually one layer thick. They are the things that slide.
  • A Start/Goal shape, or tray, is a shape that describes the board, usually one layer. Its fixed cells are floor, its variable cells are corridors (pieces can cross them but not stop on them) and its empty cells are walls.

Each piece gets a start and a goal position, stamped onto a tray: the whole piece at a time. A piece the puzzle has several copies of gets a start and a goal for each copy. Trays are also called boards. They always stay at the top of the shapes list and are labeled B1, B2 and so on, while the pieces below them are S1, S2 and so on. When you delete or move a board, the boards after it are numbered again, so there is never a gap.

A board without a name shows Board 1. When you rename it, the field starts with that text, which you can change or delete. Boards are never pieces: the Puzzle tab’s All pieces list leaves them out. A board has no problem of its own: on the Puzzle tab you make the problems and choose a board for each, as you choose the result of a Brick puzzle.

The Shapes workspace for a sliding puzzle: a board drawn with the usual tools.

  1. Draw each piece on its own shape, one layer thick unless it needs more. + New Piece makes a piece the size of the last piece, or of the Sliding new shape size if there isn’t one yet.
  2. Press + New Board in the Boards list, above the shapes, to add a board. It takes the size of the last board, or the Sliding new shape size (6 by 6 by 1 unless you change it) if there isn’t one. Its color follows the theme (the Sliding board color settings); see Grid editor settings. The list’s Delete removes a board. Problems that used it stay, without a board, until you choose another.
  3. Draw the board with the usual tools, as any other shape: Fixed is floor, Variable is corridor and Erase is wall. A board that problems already use can still be changed: in every problem, the starts and goals stay where they are, and a start or goal that loses one of its cells (erased, or cut off by a smaller board) is removed whole, and ShapeLogic tells you which pieces lost one.

Sliding puzzles are edited in the XY plane, one layer at a time. Paint the pieces and the board with constraint colors to limit where a piece may start; a piece with a start mark must also fit the colors there. See Color Restrictions.

A piece or a board can also show a picture, as on a printed tile puzzle: the image button in the color area applies a PNG, JPEG, WebP or GIF file, cropped or stretched to the shape. A board’s picture lies on its floor, under the pieces. Pictures are only for looks: the solver ignores them. See Pictures on sliding pieces and boards.

Pieces and trays can have more than one layer: add layers with the Z size stepper. A piece’s start or goal covers every cell of the piece in every layer. To place one, choose a layer beside the Start or Goal grid: the outline under the mouse is the piece’s slice on that layer, and the piece sits as low as it can while still fitting.

By default every piece stays in its layer: it slides across the tray but never up or down, even where the layer above is open. Turn on Allow Vertical Moves in the Solver’s search options to let pieces move up and down too. A piece can then be lifted out of a box over the others and put down somewhere else, as long as the tray has floor cells above for it to pass through. This counts as one move. Pieces never turn, so a goal that needs a piece turned around cannot be reached.

A piece keeps the orientation it is drawn in: it is placed on the board that way and never turns as it slides. A piece with a start or a goal sits on its stamp as drawn, even where a turned copy would cover the same cells, such as two upright dominoes stamped side by side as a square. A piece with neither is placed as drawn too, unless you turn on Allow any orientation for unplaced pieces in the Solver’s search options. Each of its quarter turns is then a different start. Include mirrored orientations adds its mirror images, as if the piece were turned over.

The Puzzle workspace for a sliding puzzle: the pieces in the puzzle on the left, the START and GOAL trays at the top of the 3D view with the pieces under them, and the Start and goal grids on the right.

On the Puzzle workspace the board is the problem’s result.

  1. Press + New in the problems list to make a problem, then Change… beside its result and pick a board. Change… lists only the boards. You can make, copy and delete problems as on other puzzles, and several problems can use the same board. Each problem has its own starts and goals on it, and its own pieces and counts, so one board can hold a whole set of challenges. A copy of a problem begins with the same starts and goals, and you can then change it without touching the first.
  2. Add the pieces to In this puzzle, with as many copies of each as the puzzle has. Three blue blocks of the same shape are one piece with three copies.
  3. The right card, Start and goal, shows the board twice: Start at the top and Goal below. Above each grid is every piece of the puzzle with how many of its copies are placed there, for example S2 1/3. Focus 2D editor, at the top right of the card, puts Start and Goal side by side and gives their grids all the room it can (Esc goes back). A large board shrinks to fit its grid.
  4. Select a piece, in In this puzzle or above a grid, then click the grid where it goes. It follows the mouse: green where it fits, red where it does not, orange on a copy that is already there. A piece with one copy moves to where you click. A piece with several copies gets one more copy at each click, until all of them are placed. Click a copy, or right-click it, to take it off.
  5. The 3D view shows two trays side by side, START and GOAL, at the top, and the problem’s pieces under them, as on a Brick puzzle; click a piece there to select it. A bar at the bottom of the view reads green (Valid Start/Goal positions…) or red (Invalid Start/Goal positions - …, with the reason).

At least one piece needs every copy at a start and at a goal. Any other piece may have starts and goals for none, some or all of its copies:

  • A copy without a start can start anywhere. The solver tries every place it fits.
  • A copy without a goal can end anywhere.
  • Copies of one piece are alike, so any copy may end on any of its goals, and swapping two copies’ starts does not make a new puzzle.

A piece keeps at least as many copies as are placed at its starts or its goals: take a copy off first to lower the count.

The Solver after finding the 81-move solution of a Klotski puzzle.

For a sliding puzzle, Find Solutions is selected by default. It keeps a start layout only when each marked piece can slide from its start cell to its goal cell. Press Solve: the solver searches breadth first and reports the fewest moves. The Solutions list shows the number of moves, and the player replays them, each piece following its route around corners.

The search options include nested slides and partially nested slides, which let a piece carry another inside it. Solve stays off while the start and goal are invalid, with the reason in the button’s tooltip.

A sliding puzzle has a Play tab to the right of Solver. Pick a problem and drag its pieces over the board: moves are counted as the Solver counts them, the board says Solved! at the Goal, and your moves can be undone, played back, exported for someone else and imported again. The position on the board can also be saved as the problem’s Start or Goal. See Play Tab.