A new AI solver for the classic 1980s puzzle game Sokoban has been developed and released. The solver, implemented in plain JavaScript, is a port of a C++ optimal solver and is designed to find the provably fewest-moves solution for Sokoban boards. The game requires a player to push every box onto a goal, with the keeper also needing to finish on a goal.
The AI solver operates using an A* search algorithm, optimized to handle the complexity of Sokoban. Key optimizations include a move-optimal macro-push A* where each search edge represents a complete box push, calculated by the keeper's shortest walk to the push spot plus one. This approach allows the search to skip individual walking steps, focusing on significant moves.
To manage memory and improve performance, the solver uses compact bitmask states. Boxes are packed into a 32-bit integer, and the keeper's position into another number, resulting in a state key of approximately 8 bytes. This compact representation allows millions of states to fit within tens of megabytes of memory. The A* frontier is managed with a dial bucket queue, and visited states are stored in an allocation-free, cache-friendly typed-array hash.
The solver incorporates deadlock pruning to discard unsolvable positions early. This is achieved through a static dead-square table, which uses reverse-reachability from goals, and a freeze check. A wall-aware push-distance lower bound ensures that the A* algorithm remains admissible, guaranteeing optimal solutions.
The solver demonstrates its efficiency by solving boards 1 through 14 to their proven optimum in milliseconds. The optimal move counts displayed for these boards are precisely what the solver returns. Board 15, an 8-box maze, is noted as an exception, requiring the exploration of approximately 49 million states for an optimal search.
✨ This summary was generated by AI from the outlets' reporting listed below. It is not independently verified and may contain errors — check the original sources. How BrevFeed works →
One email each morning: the day's tech stories, clustered across outlets and summarized. No account needed.
One email a day. Unsubscribe in one click, any time.
Spend a few minutes, get the whole day. Every topic's top stories in one hands-free rundown — listen, watch, or read the transcript.
▶ Play today's briefNew every morning, and the back catalogue is archived by date.
A new JavaScript-based AI solver for the puzzle game Sokoban has been released, capable of finding provably optimal solutions for many boards. This solver utilizes an A* search algorithm with several optimizations to efficiently determine the fewest possible moves.