02.13.07

PostScript is Amazing

Posted in Computers, Software Development at 12:59 am

A sample mazeWell, I finally completed a little toy project I’d been working on, off and on, for a while.

It’s a program written in PostScript that generates random mazes. You can try it out, and a random maze will be generated to a PDF file which you will see (if you have Adobe Acrobat Reader or some other PDF viewer). I have another version which produces six mazes to a page. The original PostScript version (which you can download, or see a syntax-highlighted version of) can be configured to print an arbitrary number of mazes to a page, and was written using the Test-Driven Development paradigm (so it includes a fairly complete set of regression tests).

I wrote it after I read the source code to the program “Amazing”, written in BASIC, which was presented in a book I used to read when I was a kid, to try things out on my TRS-80 or in Microsoft BASIC on my Macintosh Plus.

I dug up the source code again while I was searching for code to simple, text-based games that I could use as means to teach the C programming language to newbies. The example from the BASIC Computer Games book was rather illegible, and I spent a weekend deciphering it so I could understand the underlying algorithm. In the process, I ended up finding a couple bugs in the progress, such as the occasional omission of the maze exit point, or generating unreachable locations in the maze. I wish now that I’d found the original version of the program, which is much more readable. I think David Ahl’s version from the book must have been written to conserve absolutely as much space as possible, at the expense of comprehensibility.

2 Comments »

  1. micah.cowan.name » Cool Little Maze said,

    09.09.08 at 7:00 pm

    [...] (See also my own maze experiment.) [...]

  2. micah.cowan.name » How Strange Am I? said,

    01.26.09 at 4:10 pm

    [...] capable of accomplishing some exotic feats. I wrote a PostScript file for example, which results in a different randomly-generated maze every time you print it (note though that the primary links there are to static PDFs which are [...]

RSS feed for comments on this post · TrackBack URL

Leave a Comment