Level format

From Sokoban Wiki

(Difference between revisions)
Jump to: navigation, search
m (Level collection)
Line 1: Line 1:
 +
= Level =
 +
The most commonly used format for representing a level of Sokoban is:
The most commonly used format for representing a level of Sokoban is:
Line 27: Line 29:
It's important that the whole level is surrounded by walls (<code>#</code>)
It's important that the whole level is surrounded by walls (<code>#</code>)
-
There are various different level formats. Many of them also offer the possibility to store save games or solutions in a level file.
 
-
A solution is represented by the movements of the player. The player can move up, down, left or right. Hence, the letters for these directions are: u, d, l, r.  &rArr; [[Solution format]]
+
= Solution =
 +
A solution of a level is represented by the moves of the player. The player can move up, down, left or right. Hence, the letters for these directions are: u, d, l, r.  &rArr; [[Solution format]]
A possible solution string may look like this:  
A possible solution string may look like this:  
Line 35: Line 37:
The capitals in this solution show that a box is pushed as the player moves. Usually this information is stored in a solution, too, although the solution is still correct if all letters are lowercase.
The capitals in this solution show that a box is pushed as the player moves. Usually this information is stored in a solution, too, although the solution is still correct if all letters are lowercase.
 +
Note: Although it's common to use the letters (N)orth, (S)outh, E(ast) and W(est) in other games the letters u,d,l and r have been become a standard for Sokoban directions. It's therefore uncommon to use the letters: n, s, e and w for represting the moves of the player.
 +
= Snapshot =
 +
It's also possible to save moves of the player even if they don't constitute a solution for the level. In this case these moves are called "snapshot". The only differences between a solution and a snapshot is the fact that the moves of a snapshot don't result in a solved state of the level.
-
 
+
= Level collection =
-
== Level collection ==
+
Many authors publish several levels as a collection of levels. This collection is named, for instance "Sokoban Perfect". Usually all levels contained in this collection are then referred to as "the Sokoban Perfect levels".<br>
Many authors publish several levels as a collection of levels. This collection is named, for instance "Sokoban Perfect". Usually all levels contained in this collection are then referred to as "the Sokoban Perfect levels".<br>
A specific level of this level collection is specified by adding the number of the level in that collection after the collection name. For instance to refer to the 10th level of the collection "Sokoban Perfect" one can write: "Sokoban Perfect #1" or simply "Sokoban Perfect 1".<br>
A specific level of this level collection is specified by adding the number of the level in that collection after the collection name. For instance to refer to the 10th level of the collection "Sokoban Perfect" one can write: "Sokoban Perfect #1" or simply "Sokoban Perfect 1".<br>
In the case the levels don't have own titles they are just numbered (1, 2, 3, ...) However, some authors also named their levels.
In the case the levels don't have own titles they are just numbered (1, 2, 3, ...) However, some authors also named their levels.
-
== Level file format ==
+
= Level file format =
There exist various file formats for storing the data of a level / level collection.
There exist various file formats for storing the data of a level / level collection.
-
== Exchange of Sokoban levels in Emails ==
 
-
Many e-mail servers strip empty spaces and multiple spaces, too. To ensure the levels can be imported to the email recipients properly here are some suggestions:
 
-
Replace all spaces by hyphens "-" or underscores "_" (preferred).
+
= Run length encoding =
-
(the recipients of your mail have to replace them back to spaces in order to import the levels to their Sokoban programs. However, some of the Sokoban games do have already an automatic replacement build in and can read the levels)
+
-
 
+
-
== Run length encoding ==
+
The XSB format with RLE (run-length-encoding), is more compact, and efficient in mobile devices (as Palm, PocketPC, Smart Phones), besides being smaller to send for SMS.
The XSB format with RLE (run-length-encoding), is more compact, and efficient in mobile devices (as Palm, PocketPC, Smart Phones), besides being smaller to send for SMS.
Line 95: Line 94:
Should be RLE this way:
Should be RLE this way:
  <span style="color:#FF3030;">'''3#'''</span>|#.3#|#*$-#|#--@#|5#
  <span style="color:#FF3030;">'''3#'''</span>|#.3#|#*$-#|#--@#|5#
 +
 +
= Exchange of Sokoban levels in Emails =
 +
 +
Many e-mail servers strip empty spaces and multiple spaces, too. To ensure the levels can be imported to the email recipients properly here are some suggestions:
 +
 +
Replace all spaces by hyphens "-" or underscores "_" (preferred).
 +
(the recipients of your mail have to replace them back to spaces in order to import the levels to their Sokoban programs. However, some of the Sokoban games do have already an automatic replacement build in and can read the levels)

Revision as of 17:47, 28 July 2010

Contents

Level

The most commonly used format for representing a level of Sokoban is:

Level element Character ASCII Code
Wall # 0x23
Player @ 0x40
Player on goal square + 0x2b
Box $ 0x24
Box on goal square * 0x2a
Goal square . 0x2e
Floor (Space) 0x20

The simplest solvable level looks like this:

#####
#@$.#
#####

It's important that the whole level is surrounded by walls (#)

Solution

A solution of a level is represented by the moves of the player. The player can move up, down, left or right. Hence, the letters for these directions are: u, d, l, r. ⇒ Solution format

A possible solution string may look like this: DDrdrruLruLLDllU

The capitals in this solution show that a box is pushed as the player moves. Usually this information is stored in a solution, too, although the solution is still correct if all letters are lowercase. Note: Although it's common to use the letters (N)orth, (S)outh, E(ast) and W(est) in other games the letters u,d,l and r have been become a standard for Sokoban directions. It's therefore uncommon to use the letters: n, s, e and w for represting the moves of the player.

Snapshot

It's also possible to save moves of the player even if they don't constitute a solution for the level. In this case these moves are called "snapshot". The only differences between a solution and a snapshot is the fact that the moves of a snapshot don't result in a solved state of the level.

Level collection

Many authors publish several levels as a collection of levels. This collection is named, for instance "Sokoban Perfect". Usually all levels contained in this collection are then referred to as "the Sokoban Perfect levels".
A specific level of this level collection is specified by adding the number of the level in that collection after the collection name. For instance to refer to the 10th level of the collection "Sokoban Perfect" one can write: "Sokoban Perfect #1" or simply "Sokoban Perfect 1".
In the case the levels don't have own titles they are just numbered (1, 2, 3, ...) However, some authors also named their levels.

Level file format

There exist various file formats for storing the data of a level / level collection.


Run length encoding

The XSB format with RLE (run-length-encoding), is more compact, and efficient in mobile devices (as Palm, PocketPC, Smart Phones), besides being smaller to send for SMS. It can be used for both: levels and solutions.

In this format a digit shows how many elements of the same type are following.

#### becomes 4#

This level ("Claire", by Lee J Haywood):

#######
#.@ # #
#$* $ #
#   $ #
# ..  #
#  *  #
#######

runlength encoded looks like this:

7#|#.@-#-#|#$*-$-#|#3-$-#|#-..--#|#--*--#|7#

The rows of the level are separated by "|"s. There has been a discussion in the Yahoo Group about what character should represent an empty square in May 2006. Finally the hyphen has been elected to be the standard character for an empty square. Nevertheless, programs are encouraged to support both, hyphens and underscores.

If only two level elements are grouped together they may be run length encoded, but needn't to. Example:

$$ may keep $$ or be encoded as 2$

It's recommended to write run-length encoded boards in a single line because currently some programs may not be able to handle RLE-boards spanning multiple lines. Most of the editor programs (for instance "notepad" in Windows) have a automatic wrapping of lines so there is no need for manually creating new lines. However, when a RLE board spans multiple lines, the trailing "|" on each line may be omitted.

In the RLE format empty squares at the end of a row should be ommited.
For example, this level:

###__  <- two empty squares / spaces at the end of the row
#.###
#*$ #
# @ #
#####

Should be RLE this way:

3#|#.3#|#*$-#|#--@#|5#

Exchange of Sokoban levels in Emails

Many e-mail servers strip empty spaces and multiple spaces, too. To ensure the levels can be imported to the email recipients properly here are some suggestions:

Replace all spaces by hyphens "-" or underscores "_" (preferred). (the recipients of your mail have to replace them back to spaces in order to import the levels to their Sokoban programs. However, some of the Sokoban games do have already an automatic replacement build in and can read the levels)

Personal tools