AI Puzzle Framework Sokoban Protocol Document Josh Wilkerson June 7, 2005
Sokoban Protocol Document Page 2 of 5 Table of Contents Table of Contents...2 Introduction...3 Puzzle Description... 3 Rules... 3 Board State...3 Flags... 3 Representation... 3 Sample Board Layout File... 4 Module Requirements...4 Puzzle Number... 4 Puzzle Module... 5 Board Module... 5 Player Module... 5
Sokoban Protocol Document Page 3 of 5 Introduction Puzzle Description Sokoban is a logic puzzle game that originated in Japan. The point of the game is to push a set of objects into a designated area. The objects typically are crates, or some similar object, that need to be grouped in a certain area (Sokoban in Japanese means warehouse keeper). You can only push the blocks (no pulling) and the number of moves it takes to move all of the pieces into place is tracked, the fewer the better. Rules 1. Every maze configuration will have a starting position, where the player is initially located, the crates scattered across the board, and the goal area designated. 2. The player may not, at any time, step on or push a crate into a space marked by a wall or barrier. 3. The player may not, at any time, push a crate into a space occupied by another crate. 4. The player can only push one crate at a time, e.g. the player cannot push a line of crates all at once. 5. The number of crates on the board must equal the number of goal spaces. 6. A move consists of a transition of the player from the currently occupied space to an immediately adjacent space. 7. Moves may only be made to horizontally or vertically adjacent spaces; no diagonal moves are allowed. 8. A solution to a layout is defined as a board state in which all of the crates have been pushed into the goal area. 9. At any point that a solution is found, the game is over and the player wins. 10. The overall goal for the player is to find the optimal solution (the solution that takes the fewest moves) for the given layout. Board State Flags The following flags are used by the Sokoban puzzle when configuring the board state: Flag USE_TIME USE_MOVES LIMIT_NONE Purpose Count time for the puzzle Count moves for the puzzle Do not limit the puzzle based on time or moves
Sokoban Protocol Document Page 4 of 5 Representation The Sokoban board state is represented internally and in.puz layout files as follows (which corresponding ASCII values in base 10): Character ASCII Value Meaning # 35 Wall piece c 99 Crate (not in goal space) Space 32 Open space g 103 Goal space (without a crate on it) G 71 Goal space (with a crate on it) p 112 Player piece (not on a goal space) P 80 Player piece (on a goal space) Sample Board Layout File Following the standards for board layout files (.puz files) defined in the Module Developer Guide, the following is a sample board layout file for the Sokoban puzzle 6 8 10 ########## # #gg# # c #gg# # cc c g# # # # c# #p # ########## Module Requirements Puzzle Number The Sokoban puzzle has a puzzle identification number (puzid) of 6 (six), which must be set in the LibraryInfo for each of the modules, and for the board layout files intended for use with the Sokoban puzzle. Use of any other number will cause the given module or layout file to not work correctly with the given puzzle, and may also conflict with other, previously defined puzzle ID numbers.
Sokoban Protocol Document Page 5 of 5 Puzzle Module For the Sokoban puzzle, the puzzle module will not contain an initial state, but rather it will be loaded from a.puz board layout file. When the state is loaded from the layout file and passed to the checkboardstate function in the puzzle module, which will verify the layout s validity before passing it to the other modules. Board Module The board module should maintain the visual layout of the board as the player moves the crates around. The module should also support keyboard inputs for moves as well as mouse clicks. Player Module No special treatment is needed by the player module. It should be noted, however, that there are losing states in the puzzle (e.g. crates pushed into a corner or against a wall) so it is not possible to return to a safe board state after a move is made which creates a losing state.