Score File
The scores and solutions are saved in XML files in the Scores sub-folder of
the game. There is one score file for each level file, the name is the same
as the level file but with the extension .ssc (Sokoban Score Collection).
The format of the file is defined in an XSD file that can be found
here.
The solution is stored as the content of the Score tag.
Each move is encoded in two bits to save space. The coding is shown
in the table below. No distinction is made between moves and pushes since this
is given by the level itself, a move left will be a push left if there is a
ball to the left of the man.
| Move |
Bits |
Up |
00 |
Right |
01 |
Down |
10 |
Left |
11 |
The solution is stored as a byte array with a 4 byte length holding the number
of moves in the solution, byte nr 0 holds the most significant byte and byte nr
3 the least significant byte of the length. The actual moves are stored beginning
with byte nr 4. Each byte holds four moves, beginning in the two most significant
bits of the byte. The pattern 00112233 in byte 4 means move 0, move 1 and so on.
Previously there was a format with a 2 byte length. The new format has the attribute
Version="2" in the root element. When the game finds a file with version 1 (default), it
is automatically converted to Version 2.
The result of this is bytes with any value (0 - 255). In order to store this binary data
as text in the file, the whole array is Base64 encoded. Base64 is a standard encoding
specified in RFC 1421.
| Byte |
Description |
0 |
Length (msb) |
1 |
Length |
2 |
Length |
3 |
Length (lsb) |
4 |
00112233 |
5 |
44556677 |
6 |
88... |
... |
... |