What this page is
Sokoban rules are simple. The player can push a box but cannot pull it. Every box must end on a goal square. The hard part is proving that a level has a solution and finding the fewest moves. That fewest number of moves is called par.
BFS (breadth-first search) looks outward one layer at a time. First it checks every board you can reach in one move. Then it checks every board two moves away, and so on. The first layer that contains a solved board gives the shortest move count.
A board state is more than the player's square. It combines the player position with the positions of all boxes. If a box moves, the same player square belongs to a different state.
The five chapters
As you scroll, the board changes to match each chapter:
- Play it yourself: Level l003 has a par of 5. After every move, the page recomputes "Best remaining".
- Watch BFS expand: Level l002 has a par of 4. You can play the search one layer at a time and see how many states each layer adds.
- Take one hint: A hint takes only the first step of an optimal route. After one hint, "Best remaining" falls by exactly one.
- Dead end: A box sits in a corner that is not a goal, and it can never leave. The search checks every reachable state and then reports "No path".
- Data contract: Before publication, CI checked 100 release levels with 30 automated tests and 491 assertions. All passed. Par ranges from 1 to 28 moves.
How to play
- Move with the arrow keys, WASD, or the direction buttons below the board.
- To take back a move, select "Undo". To start the level again, select "Reset".
- If you are stuck, select "Take one hint".
- To watch the full solution, select "Play optimal route". Select "Stop" to end it.
- In chapter 2, select "Play search", or use the slider and arrow buttons to step through layers.
Above the board, five values appear: the level ID, par, your moves, the best remaining moves, and the number of states the solver checked.
Limits and notes
- The page has only the built-in boards for each chapter. You cannot load your own level.
- The step count is player moves, not box pushes.
- Each solve checks at most 400,000 states. If it reaches that limit, the page also shows "No path".
- The board marks only one kind of dead end: a box stuck in a corner. The search finds other dead ends, but the board does not mark them.
- The figures in chapter 5 (100 levels, 30 tests, 491 assertions) come from one run before publication.
- These checks prove that each level is solvable and that par is correct. They cannot prove that a level is fun. A person still makes that call.