Sokoban: Map set loading

Previous page Next page

File menu map set loading

Reading an external map set

The program can read in map sets written in the format shown in the example below. The map set will be added to the list of internal maps (for the current session only) and will appear at the bottom of the cascading menu in the map set selection menu. Any number of map sets can be added and will simply be appended to the end of the list.

There are agreed symbols for all the possible states in a Sokoban map but there is quite a lot of variation in how lists of maps - i.e. map sets - are written. Map set files can be downloaded from various sites on the internet. At present Sourkoban uses the following strategy to try to read map sets: find a line with a "#" symbol; assume that is the start of the next map; find the next line with no "#" symbol; assume that is the first line after the map; look back from the first line until a non empty line is found; make that the map level name. If the map set you want to load does not conform to this let me know or find an alternative copy of the set that does.


Level 1
'NABOKOSMOS 01'
 #####
 #   ##
## * .##
# $$*  #
#  * . #
## @ ###
 #####

Level 2
'NABOKOSMOS 02'
  ####
###  ###
#   *$ #
# #  # #
#   ** #
###  #@#
  # ** #
  #  # #
  # *. #
  #  ###
  ####

Figure 1. An example of a map set (the start of Aymeric du Peloux's Nabokosmos set). In this case the program would use 'NABOKOSMOS 01' and 'NABOKOSMOS 02' as the level names.

Reading a map solution from a file

The symbols for storing the moves made when traversing a map are u, d, l, r, plus repeat counts. So, 3d means ddd and 4(ru) means rurururu. For Sourkoban, the file should contain nothing else. The file is assumed to be for the current map. When the file is read in the program will show an animation of the moves to solve the map. A typical file is shown below.

Figure 2. An example of a solution file.

llu5r4l5d3ruu3r4uldlldllul4duruuru3rdrdd
3l3d4lur5u4r4l6d3r3u3ruuldrdllrr4ul3drdl
3u5l5drrdru

Last updated: 2012-10-28    Sitemap