📜 ⬆️ ⬇️

Levels for Sokoban

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 ************************************* 

You can download all the levels at once .

Levels are compressed by something like Huffman - bit chains of variable length. Each level is encoded as follows:
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:

 level_01 db 16h, 0Bh, 0A2h, 0DFh, 38h, 32h, 1Fh, 38h, 2Ah, 3, 0E6h db 12h, 0C0h, 0A5h, 0F2h, 83h, 2, 81h, 3, 0E4h, 12h, 82h db 25h, 6, 0CDh, 64h, 22h, 51h, 0ACh, 11h, 0A1h, 0Ah, 5 db 0E5h, 11h, 0B1h, 14h, 82h, 29h, 82h, 31h, 0A0h, 0E1h db 2Ch, 18h, 0D1h, 0CFh, 80h, 0Ch, 8 level_02 db 0Eh, 0Ah, 0F6h, 58h, 0Ch, 68h, 0Dh, 94h, 0C6h, 80h db 85h, 2, 82h, 18h, 0D0h, 15h, 4Ch, 10h, 0C6h, 0C2h, 18h db 21h, 8Dh, 1, 6, 4, 39h, 10h, 0A0h, 81h, 80h, 85h, 2 db 8, 20h, 60h, 34h, 1Bh, 0Ch, 1Eh, 0CAh, 7, 4 level_03 db 11h, 0Ah, 0E3h, 9Fh, 0Eh, 7, 0C2h, 11h, 42h, 1Fh, 8 db 50h, 23h, 0E0h, 85h, 4, 0Ch, 1Eh, 84h, 8, 0A6h, 0B4h db 10h, 85h, 2, 82h, 59h, 0D4h, 28h, 14h, 90h, 0D6h, 83h db 0DFh, 7Ch, 0Eh, 1 
Etc.

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.

Project on GitHub'e - github.com/begoon/sokoban-maps , if anyone is interested.

Source: https://habr.com/ru/post/150882/


All Articles