Is this level actually solvable? An interactive Sokoban BFS lab

In this interactive lab, you push a box yourself and watch BFS search layer by layer. Then you check the hints and the release data contract. The page uses the real levels.json from BoxCat, a Sokoban game made with Godot.

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:

  1. Play it yourself: Level l003 has a par of 5. After every move, the page recomputes "Best remaining".
  2. 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.
  3. Take one hint: A hint takes only the first step of an optimal route. After one hint, "Best remaining" falls by exactly one.
  4. 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".
  5. 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

  1. Move with the arrow keys, WASD, or the direction buttons below the board.
  2. To take back a move, select "Undo". To start the level again, select "Reset".
  3. If you are stuck, select "Take one hint".
  4. To watch the full solution, select "Play optimal route". Select "Stop" to end it.
  5. 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.

Related articles