At the time of XTs and DOS, I had a variant of Sokoban, implemented in the form of a tiny binary, smaller than ten kilobytes. This miracle was called pusher.exe and it looked like this:
It was a simple level, but what about this? ')
Elementary starts via DOSEmu: DOSEmu -exit pusher.exe .
Who is too lazy to run, you can see the demo:
And I wondered how sixty levels fit into such a small binary. Having picked a bit of IDA, I wrote a program that tears out all levels from the `pusher.exe` binary and prints them in text form:
************************************* Maze: 1 File offset: 148C, DS:00FC, table offset: 0000 Size X: 22 Size Y: 11 End: 14BD Length: 50 XXXXX XX X* X XXX *XXX X * * X XXX X XXX X XXXXXX XX XXX XXXXXXX ..X X * * ..X XXXXX XXXX X@XXXX ..X X XXX XXXXXX XXXXXXXX *************************************
Levels are compressed by something like Huffman - bit chains of variable length. Each level is encoded as follows:
The size of the card is X (1 byte).
The size of the card is Y (1 byte).
X * Y bytes of the card itself, which is represented by a sequence of pairs [COUNTER] [SYMBOL CODE]. COUNTER is either one bit 0 if the character is only one or four bits "1 D3 D2 D1", and then the number of repetitions calculated by the formula "N = 2 + D3 * 4 + D2 * 2 + D1", that is, from 2 to 9 characters. The SYMBOL CODE has five different meanings: 00 is an empty space, 01 - wall, 10 - barrel, 110 - place for the barrel, 111 - barrel, already standing
The starting position of the player in X (1 byte).
The initial position of the player on Y (1 byte).
And so all 60 levels.
In the file pushermaps.c you can see the whole simple decompressor.
During the disassembly process, the levels were formed in a convenient textual, but still compressed form, for example:
So if you want to get your own simple and compact Sokoban somewhere, you can take a certain number of levels ready .
I know that the Internet is full of levels for Sokoban, and there are automatic solvers, but this does not at all cancel the fan-digging disassembler in the binary more than twenty years ago.