Thứ Hai, 1 tháng 6, 2015

How to play Sokoban

*Source from http://www.sokobano.de/
This article explains how to play Sokoban. There are also simple strategies explained.
First let's have a look at the rules of the game:
The object of Sokoban is to take some objects (usually boxes) to designated locations by pushing them.
To do this the user moves a man who we call Sokoban. Sokoban can move up, down, left and right. He can't pass through walls or boxes. He can push only one box at a time (never pull). At any time a square can only be occupied by one of a wall, box or man.
A level contains these elements:
Walls:                    #
Boxes:                    $
Goals:                    .
Free squares:            ' '
The Sokoban / the player: @
Boxes and the Sokoban can also be located on a goal.
Boxes on goals:           *
The Sokoban on a goal:    +
In the following the Sokoban is called "the player" to indicate that this is the object the user can move.

Movements: Nearly all Sokoban games can be played using the arrow keys. Nowadays many programs also support playing with the mouse. All moves of the Sokoban need only to be done for pushing a box.
Level 1
#########
#@  $  .#
#########
Using the arrow keys one has to press the "right arrow" 5 times. Using the mouse you have to mark the box for pushing (by clicking on it) and then clicking at the position the box is to be pushed to.
Level 2
########
#    ###
#@$  ###
#### ###
##   ###
##    ##
#  ##. #
#      #
#####  #
########
Here the difference between playing with keyboard and playing with mouse is demonstrated. Using the mouse is as simple as in Level 1. Using the arrow keys needs a lot of key presses for pushing the box to the goal. Hence, it's always recommended to use the mouse for playing. The advantages compared to keyboard playing are:
  1. With two clicks a box can be pushed to every possible square
  2. Most programs automatically calculates the best moves for the player. Hence the user doesn't have to think about how to move the player by keys.
  3. Some programs even show the squares a box can be pushed to. In this way it's easy to see if a box can be pushed to the selected position.
  4. The user can concentrate on pushes only instead of moves and pushes

Levels containing only one box are very simple to solve using the mouse: One just has to mark the box for pushing and then to choose the goal square as target.
Usually Sokoban levels are a lot more complicated.
Let's increase the difficulty step by step:
Level 3
########
#      #
#  $  .#
#@ $  .#
#  $  .#
#      #
########
Here the level contains 3 boxes. Nevertheless the level can easily be solved. Although every box can be pushed to each goal it doesn't matter which box is pushed to which goal. The boxes can just be pushed one after the other to any goal.
Level 4
########
#  #.  #
# $#   #
#  # @##
#  # $##
#    .##
########
This level is more complicated. The box under the player is close to a goal. Nevertheless it can't be pushed to the goal - this would result in a deadlock. This level shows some problems one has to solve before it's possible to finish the level:
  1. Not every box can be pushed to every goal
  2. Boxes can't just be pushed to the nearest goal in every case
  3. Box pushes can create a deadlock

Level 5
#########
##  #   #
#.$.  $ #
# #  ## #
# @$.$. #
#########
To solve this level the boxes have to be pushed to their goals in a specific order. Moreover one box has to be pushed away from its goal before it can be pushed to it.

Level 6
#########
#  #   .#
#@$ $   #
# $ ##..#
#   #####
#########
This level is another example of the need to push a box away from its goal before the level can be solved. Additionally one box has to be "parked" until some other boxes have reached their goals. A situation where a box must be pushed but can't be pushed immediately to its goal occurs very often in Sokoban levels. Some of them are "parking" situations. "Parking" means:
  1. a box must be pushed away from its goal
  2. after the box is pushed to its parking position another box has to be pushed
  3. parking the box at a specific position is required to solve the level

Chủ Nhật, 31 tháng 5, 2015

Sokoban from Wikipedia

Sokoban (倉庫番 sōkoban?, warehouse keeper) is a type of transport puzzle, in which the player pushes boxes or cratesaround in a warehouse, trying to get them to storage locations. The puzzle is usually implemented as a video game.
Sokoban was created in 1981 by Hiroyuki Imabayashi, and published in 1982 by Thinking Rabbit, a software house based inTakarazukaJapan.

Rules


The game is played on a board of squares, where each square is a floor or a wall. Some floor squares contain boxes, and some floor squares are marked as storage locations.

The player is confined to the board, and may move horizontally or vertically onto empty squares (never through walls or boxes). The player can also move into a box, which pushes it into the square beyond. Boxes may not be pushed into other boxes or walls, and they cannot be pulled. The puzzle is solved when all boxes are at storage locations.

Scientific research on Sokoban


Sokoban can be studied using the theory of computational complexity. The problem of solving Sokoban puzzles was proven to be NP-hard.[3] Further work showed that it was significantly more difficult than NP problems; it is PSPACE-complete.[4] This is also interesting for artificial intelligence researchers, because solving Sokoban can be compared to the automated planning that needs to be done by a robot that moves boxes in a warehouse.

Sokoban is difficult not only due to its branching factor (which is comparable to chess), but also its enormous search tree depth; some levels can be extended indefinitely, with each iteration requiring an exponentially growing number of moves and pushes.[5] Skilled human players rely mostly on heuristics; they are usually able to quickly discard futile or redundant lines of play, and recognize patterns and subgoals, drastically cutting down on the amount of search.
Some Sokoban puzzles can be solved automatically by using a single-agent search algorithm, such as IDA*, enhanced by several techniques which make use of domain-specific knowledge.[6] This is the method used by Rolling Stone,[7] a Sokoban solver developed by the University of Alberta GAMES Group. The more complex Sokoban levels are, however, out of reach even for the best automated solvers.[8]

Sokoban variants


Several puzzles can be considered variants of the original Sokoban game, in the sense that they all make use of a controllable character who pushes boxes around a maze.

Alternative tilings: In the standard game, the mazes are laid out on a square grid. Several variants apply the rules of Sokoban to mazes laid out on other tilings. Hexoban usesregular hexagons and Trioban uses equilateral triangles.
Alternative pushers: In the variants Multiban and Interlock the player can control multiple characters. In some games the pusher is a small bulldozer.
Alternative goals: Several variants adjust the requirements for completing a level. For example, in Block-o-Mania the boxes have different colours, and the goal is to push them onto squares with matching colours. Sokomind Plus implements a similar idea, with boxes and target squares uniquely numbered. In Interlock and Sokolor, the boxes also have different colours, but the goal is to move them so that similarly coloured boxes are adjacent. In CyberBox, each level has a designated exit square, and the goal is to reach that exit. In a variant called Beanstalk, the elements of the level must be pushed onto the goal in a fixed sequence.
Additional game elementsSokonexXsokCyberbox and Block-o-Mania all add new elements to the basic puzzle. Examples include holes, teleports, moving blocks and one-way passages.
Character actions: In Pukoban, the character can pull boxes in addition to pushing them.
Reverse mode: The player solves the puzzle backwards, from the end to the initial position by pulling instead of pushing boxes. Standard Sokoban puzzles can be played in reverse mode, and the reverse-mode solutions can be converted to solutions for the standard-mode puzzle. Therefore, reverse mode can also be considered a tool for solving standard Sokoban puzzles. Reverse mode is available in Sokoban YASC and Sokofan.