Optimized paths: a sliding search held to the grid, and how far to trust its answer

How the Solver's Automatically use optimized paths option works on boards of blocks, what its move counts prove, and why the normal full search takes so much longer

16 November 2026 · Sources: core/shapelogic/solve/sliding_search.cpp, decision records 0029, 0031, 0032 and 0033; solves of "Abe 1 to 6 Heart" and of a scaled Klotski with shapelogic_cli (release 1.8.4, MacBook Air M4, 32 GB)

Summary

  1. What the search counts
  2. The grid, and the stops it leaves
  3. How the search uses the grid
  4. How sure is the answer?
  5. How it differs from the normal Solve
  6. Which to use

1. What the search counts

In a sliding puzzle one move is one piece sliding anywhere it can reach while the others stay where they are. It may go any distance and turn any number of corners. With Allow Nested Slides, a piece may also carry the pieces nested inside its outline. The Solver looks for the fewest such moves from the start to the goal.

An arrangement is the position of every piece at once. The Solver searches level by level: every arrangement one move from the start, then every arrangement two moves away, and so on until the goal turns up. (The companion page describes that search and how it runs from both ends.) The work is the number of arrangements, so what matters is how many places each piece can come to rest. This page calls such a place a stop.

The boards are drawn on a grid of small cells, and a piece can rest at every cell position it fits. Many sliding puzzles are coarser than they are drawn. Figure 1 shows one: an 18 by 18 board of six blocks, each 6 cells high and 6 or 12 wide, with seven 4 by 4 pieces riding in the blocks' holes. Its solutions only ever move a block by a whole block's width. But as far as the search can tell, a block that slides into an empty space can also stop one, two, three, four or five cells of the way in, and each of those is a new arrangement with moves of its own.

The board of "Abe 1 to 6 Heart", Problem 3: start and goal 18 by 18 cells; the dashed lines are the 6-cell grid the solver finds Start Goal f a b d e g c a d e f b c g
Figure 1. Problem 3 of "Abe 1 to 6 Heart". Blocks are blue, small pieces orange; the letters show where each small piece has to go. The fewest moves found is 47.

2. The grid, and the stops it leaves

2.1 Finding the grid

The Solver works the grid out from the board. It takes the largest cell size, above one, for which all of these hold:

For Figure 1 that is a size of 6: a 3 by 3 grid. A board that fits no such grid has no optimized search; the option then does nothing and every stop is searched.

2.2 Where each piece may stop

A piece may rest only where its position within a cell of the grid, its offset, is one that the grid allows it:

The seven small pieces of Figure 1 start and end in holes at three different offsets, so each of them has three stops in every cell of the grid.

Where a piece may stop on the empty board Each dot is a stop, drawn where the piece's top left corner would be A 6 by 6 block 169 stops in a full search, 9 on the grid A 4 by 4 piece 225 stops in a full search, 27 on the grid
Figure 2. Every stop of one block and of one small piece on the empty board of Figure 1. The small dots are the stops a full search counts; the large dots are the ones the grid leaves. One position of each piece is drawn.
Pieces of Figure 1Stops each, full searchStops each, on the gridFewer by
Five 6 by 6 blocks169918.8×
One 12 by 6 block91615.2×
Seven 4 by 4 pieces225278.3×
All 13 pieces together2,51124010.5×

These totals are the ones the Solver shows in its question before a solve. They count stops on the empty board; the number of arrangements is roughly what you get by combining a stop for every piece, so a tenfold cut for each piece is a far larger cut for the board as a whole (section 5).

3. How the search uses the grid

The result says how it was found. The problems list shows 47 moves (optimized) or no solution (optimized), and the file keeps that label. When the option's box is off, Solve asks first whenever the board fits a grid: Use Optimized Paths for this solve, or Full Search.

4. How sure is the answer?

The question has two halves, and they have different answers.

4.1 Within the grid: certain

Optimized paths is not a shortcut inside the search. It is the same exhaustive level search as a normal solve, run on a smaller set of arrangements. Everything that search guarantees still holds for that set:

The search itself is checked heavily. Its results are compared in the tests with an older, independent search on thousands of generated boards; the search from both ends was compared with the search from one end on 5,669 boards; and every path returned is replayed move by move.

4.2 Against the true minimum: an upper limit

What the grid cannot rule out is a solution that parks a piece off the grid and is shorter for it. So the honest reading of 47 moves (optimized) is "47 moves is possible, and the fewest is 47 or less". How often is it less? That depends on the kind of board.

4.3 Boards of whole-cell pieces: exact

If every piece is made of whole cells of the grid, the floor is too, every piece starts and ends on the grid's lines, and nested slides are off, then the grid loses nothing. The argument is short.

Take any solution of the full puzzle. At every moment, pull each piece back to the nearest grid line on its left and the nearest one above it. In other words, round both of its coordinates down to a whole number of cells.

The start and the goal are on the grid, so rounding leaves them alone. The rounded solution is therefore a solution on the grid with no more moves than the one we started from. Applied to a shortest solution, it shows the grid has one just as short.

This can be tested. Klotski is a board of whole-cell pieces whose fewest moves, counted the way ShapeLogic counts them, is known to be 81. Drawn at its usual size it has no grid to find. Drawn with every cell doubled or tripled, a full search has two or three times as many places to stop along every slide, and the Solver finds a grid of 2 or 3:

ScaleBoardGrid foundStops, full → gridFull search: movesarrangementsOptimized: movesarrangements
1×4 by 5none8123,7918123,791
2×8 by 102 cells528 → 17181107,0218123,791
3×12 by 153 cells1,081 → 17181302,9098123,791

The full search finds 81 moves at every scale, while its work grows from 23,791 arrangements to 302,909. Optimized paths finds 81 as well, and at every scale it visits exactly the 23,791 arrangements of the small board: the grid has undone the scaling and nothing else. (At 1× no grid is found, so the optimized run is the full search.)

4.4 Boards with small pieces: not proved, and it can fail

The argument above needs whole cells. The Heart boards break that in two ways: the small pieces are smaller than a cell, and the blocks have holes. Rounding a small piece to the grid can push it out of the hole it sits in or into a wall. So nothing guarantees that a part-way stop never helps there, and there are two ways it could:

The first is easy to show on a small board. Figure 3 is taken from the engine's tests. Two unit pieces have to change places along a corridor one cell wide. The only way is for one of them to step up into a pocket while the other passes. The corner block gives the board a grid of 2, and the pocket is one cell up, at an offset no unit piece starts or ends at. A full search solves the board in four moves. On the grid it has no solution.

Animation: two units in a one-cell corridor change places in four moves of a full search, one of them waiting in a pocket one cell up; on the 2-cell grid the pocket is not a stop, so the units can never pass and the grid finds no solution
Figure 3. A board where optimized paths reports no solution and a full search finds four moves (about 35 seconds, then it starts again). This is why "no solution (optimized)" always comes with the offer of a full search.

4.5 What the Heart boards show so far

An earlier version of the "Abe 1 to 6 Heart" file had five shorter problems, short enough for the full search to finish. Optimized paths found the same number of moves on all five.

ProblemFewest moves, full searchMoves, optimizedArrangements, optimized
Mid 0 to Mid 1141482,456
Mid 1 to Mid 21414177,100
Mid to End1616215,063
Start to Mid 031313,115,279
Start to End40406,861,036

The file's three current problems come out at 50, 56 and 47 moves. No full search of them has finished, so those numbers are upper limits. The one-ended search of release 1.8.1 found the same 56 and 47 (it did not finish the 50). But both searches rest on the same grid, so their agreement checks the search and not the grid.

Putting it together:

Claim about an (optimized) resultStanding
The moves shown solve the puzzleCertain
No shorter solution rests only on the gridCertain
No shorter solution exists at all, on a board of whole-cell pieces without nested slidesCertain: proved above, confirmed on Klotski at two scales
No shorter solution exists at all, on a board with small pieces in holesNot proved. Held on 5 of 5 problems checked (14 to 40 moves); unchecked for 47, 50 and 56
"No solution" means there is noneNo. Figure 3 is a board where it is wrong

Five agreements out of five is encouraging, and all five are on the same board with the same pieces as the longer problems. It is still a small sample, and a longer solution has more moves in which a part-way stop could pay off. We do not think a number can honestly be put on it. The only way to turn an (optimized) count into a proved minimum is to run the full search, and the next section shows what that costs.

5. How it differs from the normal Solve

The normal Solve, which the question before a solve calls Full Search, and optimized paths are the same search. Both go level by level, on every core, from both ends where the puzzle allows, writing to disk what outgrows memory, and both can be paused and continued. The one difference is the set of places a piece may rest. Everything else follows from that.

Normal Solve (Full Search)Optimized paths
A piece may restAt every position it fitsOnly at its stops on the grid
Works onEvery sliding puzzleBoards that fit a grid of blocks, with starts placed
The moves foundThe fewest there are: provedThe fewest on the grid: an upper limit on the fewest there are
"No solution"ProvedProves nothing; a full search may find one
Stops, Figure 1 board2,511240
Key for one arrangement, Figure 1 board128 bits64 bits
Result shown as47 moves47 moves (optimized)

5.1 Why the normal Solve takes so much longer

Every part-way position is an arrangement. When a block slides into an empty cell of the grid in Figure 1, optimized paths records one new arrangement. The full search records six: the block one cell in, two cells in, and so on. Each of the six is expanded in turn, and from each of them every other piece gets to make its own moves, part-way ones included. Two blocks each half-way into a cell, with a small piece at any of fifteen positions along a row, are all different arrangements that the search has to visit, sort and store. Almost none of them is on a shortest solution.

The effect multiplies across the pieces. The table in section 2 shows about ten times fewer stops for each piece. An arrangement is a stop for every piece at once, so the cut in arrangements is far larger than ten. Figure 4 measures it on Problem 3, the same search run both ways from both ends. One move from the start the full search has 36 arrangements and optimized paths 6. After five moves it is 36,655 against 434. After fourteen it is 29.5 million against 142,316: 207 times as many, with the ratio still rising at every level.

The same problem, level by level: every stop against the grid's stops "Abe 1 to 6 Heart", Problem 3, the start end of a search from both ends; the scale is logarithmic 1 100 10 thousand 1 million 100 million 0 2 4 6 8 10 12 14 16 18 20 22 24 moves from the start arrangements in the level Full search (every stop): level 14 holds 29.5 million; the run was stopped here Optimized paths: level 23 holds 2.3 million and the search is over 207 times
Figure 4. The size of each level from the start end of Problem 3. The full search was stopped after 150 seconds, 14 moves deep from each end and 134 million arrangements in; optimized paths finished the whole problem in 18.4 million.

The levels also grow faster. At level 14 each level of the full search was 1.71 times the one before; for optimized paths the figure was 1.57, falling to 1.30 by the end. A higher growth rate compounds: it is why the ratio in Figure 4 keeps widening instead of settling.

Each arrangement costs more. The full search needs a 128-bit key for this board where the grid needs 64, so the same number of arrangements takes more memory and more disk. More arrangements at more bytes each means the search leaves memory sooner, and a search working from disk is slower again.

Large boards fall off the fast search. The level search can hold keys of up to 128 bits. A full search of a board the size of "Abe 1 to 8 Heart" needs about 170, so it drops to the original search: one core, memory only, about 11,000 arrangements a second where the level search does millions.

5.2 What it comes to

The one like-for-like pair measured to the end is the 40-move problem of the earlier file, before the search ran from both ends:

"Start to End", 40 movesTimeArrangements
Normal Solve (full search)8,852 s5.09 billion
Optimized paths2.3 s6.9 million
Ratio3,800×740×

For the 47-move Problem 3 there is no finished full search to compare with. The run in Figure 4 gives a rough idea of what one would take. It was 28 of the 47 moves deep after 134 million arrangements, with about ten more levels to build at each end. If its levels kept growing at 1.71 it would reach about 30 billion arrangements; if the growth eased the way the optimized search's did, about 5 billion. Either way that is hundreds to more than a thousand times the 18.4 million that optimized paths needed: hours of search and tens to hundreds of gigabytes of disk, against a few seconds. This is an estimate from the first 150 seconds, not a measurement.

6. Which to use

Sources

← Back to Research