Marc A. Lehmann > Games-Sokoban-1.01 > Games::Sokoban



Annotate this POD

View/Report Bugs
Module Version: 1.01   Source  


Games::Sokoban - load/transform/save sokoban levels in various formats


 use Games::Sokoban;


I needed something like this quickly - if you need better docs, you have to ask.

Supports xsb (text), rle, sokevo and a small "binpack" format for input and output and can normalise levels as well as calculate unique IDs.

$level = new Games::Sokoban [format => "text|rle|binpack"], [data => "###..."]
$level = new_from_file Games::Sokoban $path[, $format]
$level->data ([$new_data, [$new_data_format]])

Sets the level from the given data.

$text = $level->as_text
$binary = $level->as_binpack

Binpack is a very compact binary format (usually 17% of the size of an xsb file), that is still reasonably easy to encode/decode.

It only tries to store simplified levels with full fidelity - other levels can be slightly changed outside the playable area.

@lines = $level->as_lines
$line = $level->as_rle

($x, $y) = $level->start

Returns (0-based) starting coordinate.


Mirror horizontally.


Mirror vertically.


Transpose level (mirror at top-left/bottom-right diagonal).


Rotate by 90 degrees clockwise.


Rotate by 180 degrees clockwise.

$id = $level->simplify

Detect playable area, crop to smallest size.

$id = $level->normalise

Simplifies the level map and calculates/returns its identity code. ., assume uppercase and hex.

$levels = Games::Sokoban::load_sokevo $path

Loads a sokevo snapshot/history file and returns all contained levels as Games::Sokoban objects in an arrayref.


 Marc Lehmann <>
syntax highlighting: