- DelphiTools - https://www.delphitools.info -

Old School Maze Pascal to JavaScript

Zarko Gajic [1] recently reposted Kostas Symeonidis’s Maze [2], this is an old code (2004) that generates a random maze using Prim’s algorithm [3] and solves it.

[4]I wondered how it would hold its own when compiled to JavaScript, and by that I mean compiling the old 2004 source… click on the picture to the right to run a version compiled with SmartMobileStudio [5]. Works in all the usual desktop and mobile suspects. Click or touch the maze to solve between arbitrary locations.

The original source works on a large static array that is passed as var parameter and where the bytes are used in a bitwise fashion. All in all it does its job in a brute-force native-compiler friendly way, but is quite suboptimal for a JS execution. Anyway I compiled as close as possible to the original (update source zip [6], 6kB).

Very few changes were required to get it to compile:

But the bulk of the code compiled without changes, and runs in Android, Chrome, IE9, etc. (only FireFox has a glitch, which is not related to the Maze code, but to the VJL and a Mozilla event name).