How to Play Sokoban: seven techniques, and how to spot a deadlock
Sokoban is a game about irreversibility. You can only push, so a box in the wrong place can never come back, and the puzzle is over before it looks over. These levels are pre-built and verified solvable by a solver that shares no code with the builder, so every loss is a deadlock you can learn to see.
-
A box in a corner is dead
Pushed into a corner, a box can never move again. Unless that corner is a goal, the level is over the instant it arrives. This is the deadlock everybody hits first and the easiest to check before pushing.
-
A box against a wall can only slide along it
Once a box sits flat against a wall, it can only travel in one line. If there is no goal on that wall, it is dead — the same as a corner, just delayed.
-
Four boxes in a square are all dead
A 2×2 block of boxes can never be broken up, because every push needs an empty square behind. The same is true of two boxes side by side against a wall.
-
Decide which side you need before you arrive
Pushing means standing opposite. Walking to a box and then discovering the square you need is behind another box is the most common wasted trip. Trace the push direction first, then plan the walk.
-
Plan the goal order backwards
Goals in a corridor or corner must be filled from the far end, because a box on the near goal blocks the way to the far one. Work out the order before you move the first box.
-
Fill the goals that constrain the most first
A goal in a tight pocket has only one approach and should be served early, while the board is still open. Goals in the open can wait — they will still be reachable later.
-
Our warning is a hint, not a verdict
When we spot a box that can no longer reach any goal, we say so. That check is deliberately partial: it catches the common corner and wall cases, not everything. No warning does not mean no deadlock.
Every level here has been solved before it shipped, and we also know the minimum number of pushes. So a level that feels impossible is a deadlock you have already created — undo to before the push that made it.