Mr. Matt: Digging Out My Childhood Caves Again
When I was a kid, I had ADI. The educational software with the little green alien who explained fractions to you. Except that on the ADI 4 CD-ROM, between two grammar drills, there were games. And among those games, there was Mr. Matt.
I sank far too many hours into it. Really far too many. (so the educational software did its job: I learned perseverance, if not fractions)
Today it's right there in your browser: mrmatt.jeux.philr.fr.
The game
Mr. Matt is a puzzle game by J. Andrzej Wrotniak, written in 1996 for Windows, after he retired his Atari ST and couldn't find a decent version of Stone Age. Distributed as shareware, it was downloaded fifty thousand times in its first year.
The principle fits in one sentence, and the original help file puts it better than I could: "No shooting, no killing, just thinking ahead and hours of endless frustration."
You dig through the earth, you eat the apples, you avoid the stones. Eating the last apple ends the level. Stones fall the moment the square beneath them clears, roll off piles, and kill you if they end up above your head. You can push one stone, exactly one, horizontally. There are also boxes, which swallow three stones before disappearing, and bombs, added in 2001, which destroy whatever they hit.
That's all of it. And it's a nightmare.
Because pushing a stone is irreversible. An apple walled in behind a rockfall is a lost apple, and a lost level, except you won't find out until forty moves later. The game is a Sokoban cousin dressed up as Boulder Dash. (except Boulder Dash lets you run, whereas Mr. Matt lets you sit and contemplate your mistake)
The port
I rebuilt the game in Godot 4.7, from the 1.59 shareware distribution and the 3.16 release of 2001.
The rule I set myself: fidelity. No "modern reinterpretation", no visual overhaul, no adventure mode with achievements. Same rules, same levels, same tiles, same sounds, all extracted straight from MRMATT.EXE. The forty 16-pixel bitmaps sit inside a Delphi resource in the 1997 executable; the sounds are the original MM_*.WAV files, 8-bit mono PCM at 22,050 Hz, two of them with a corrupted header that had to be rewritten.
Even the translations come from there. The game speaks six languages, English, French, German, Italian, Spanish and Swedish, and those are the six .MMI files shipped in 1997, eighty-nine strings each. Typos included: the original French says « Qu'as-tu fais à Mr.Matt? », and it still says it.
How you check that a port is faithful
This is the part I hadn't seen coming, and by far the most interesting.
The 1997 help file describes the rules. Badly. It says a stone rolls, without saying which way. It says a bomb won't explode "when landing on the bottom of the screen", without saying whether the bottom of the screen holds things up or swallows them. It says nothing about the exact moment an object starts falling, which is precisely the whole difference between surviving and dying.
Except that the 2001 distribution ships a mrmatt.sol file containing 2,278 solutions found by players, across 437 level packs. Those people played on the real program. So each of their move sequences, replayed in my engine, has to end in a win.
That's an oracle. Far harsher than reading the documentation, and above all measurable: I wrote the engine a second time in C, put every doubtful rule behind a #define, and watched the success rate move.
| Variant tested | Success | Verdict |
|---|---|---|
| (rules finally kept) | 99.8% | |
| Boxes don't roll | 89.6% | refuted |
| You roll off anything | 48.1% | refuted |
| Falling doesn't wait for the next step | 41.4% | refuted |
| You must fall before you roll | 8.2% | refuted |
Three rules the help file never mentions came out of that.
An object in mid-air doesn't fall on its own. The real game doesn't apply gravity to the whole board: an object only falls if the square beneath it has changed. And 851 levels in the corpus start with a stone sitting in empty space. It stays there, suspended, until something comes along to disturb it.
Roll direction follows the player. When a stone lands on another one and both sides are free, it goes towards the side Mr. Matt just moved. Forcing a fixed direction fixed 42 solutions and broke 36; this rule fixes 66 and breaks none.
A box swallows anything that reaches it, whether it fell in, was pushed in, or rolled in.
Disassembly confirmed all three. It also gave the exact definition of death, at address 0x4653c4: Mr. Matt dies when an object comes to occupy the square directly above him, and only while apples remain. Once the last one is eaten, the level is won and nothing can touch him.
Final tally: 2,273 solutions out of 2,278, and all 35 from the seven original games. Five still don't replay, all of them very late, between move 305 and move 1102.
The levels, and a cipher to break
The shareware only gives you 48 levels. The registered version gave you four thousand, and the author suspended registrations long ago.
But 437 community packs from the era were still circulating. Except that the ones distributed after 2001 are scrambled: the eighteen board rows become unreadable, the rest doesn't.
+>$> ->!<*!#O* &!H! <<<<*=>+%!> <- enciphered
H#+#+#+++*************+++#+#+#+ <- the same in clear
One file, abba_dabba_dooo.mat, existed in both formats. That yields 2,232 squares of known plaintext, and something to compare. It's a shift substitution over a sixteen-character alphabet, where the key depends only on position and repeats every 256 characters. So it isn't a stream cipher: two levels in the same file encipher the same square the same way, which was enough to give the method away.
Check on a file with no known plaintext, 2b_or_not_2b.mat: out come five levels each drawing a question mark, for a game named "2b Or Not 2b" whose levels are called "Question 1" through "Question 5". That settled it.
Result: 443 games and 2,322 levels shipped with the port, in a 303 KB resource that loads in 11 milliseconds.
One mystery remains. Every level carries a checksum I still can't compute. It's neither a simple sum nor any common CRC-16. Until it's cracked, the levels you create will be read back by my game, but probably rejected by the 1997 one. (a shame, it was the only missing bridge)
What's in it
One screen, as in the original: the File / Game / Options / Help menu bar, the board, and the blue strip at the bottom with the level numbers, yellow for the current one, green for the finished ones, red for the next.
And then: fourteen graphic themes, including Beer, Margaritas and Matt-Ilda; a level editor with dot, line, circle and fill tools, and sixty-four steps of undo; the original's snapshot and playback, keys C and R; the solution display for any of the 443 games, since all 2,278 human solutions are bundled in. (a win obtained by watching the solution isn't recorded, just like in 1997: the game knows you)
It also plays by thumb. A translucent D-pad sits in the bottom left corner, an undo button in the bottom right, and the whole thing locks to landscape and fullscreen on the first tap. Firefox for Android doesn't implement orientation lock, so there's a button, and an installable version whose manifest declares it.
Plus JSON import and export, because the .mat format is ASCII art and it needed a bridge to present-day tools.
What comes next
There's still a question I was already asking myself at ten, staring at a level I couldn't beat: could a machine solve it?
The short answer is no, not really. I wrote a solver, a beam search. It solves 3 levels out of 26. The C engine runs at 900,000 states per second against 5,000 in GDScript, and it changes nothing: brute force is tens of orders of magnitude away from the problem. Pushing a stone creates irreversible dead ends, and that's exactly what makes Sokoban hard.
That will be the subject of the next article. It'll be a less cheerful one.