toys

A Perl Module for Generating Mazes

Just for fun, I've written a Perl module that generates, and creates displayable renderings of, simple rectangular mazes. The algorithm that creates the maze is no great work of genius; someday I should scour the Web for really clever maze algorithms to adopt. But in the meantime here we are.

The module is "Maze.pm". Here is the POD HTML documentation, and the source. Here is also the source of a simple CGI script that uses the module to display small mazes, either as simple ASCII art, or as nicer HTML (with GIFs by yours truly in Paint). Reload either maze page to get another maze.

The mazes the module generates aren't very hard; I'm not sure if there are Secrets of Writing Hard Mazes that I don't know, or if smallish rectangular mazes are just always easy. If you crank up the maze size to something larger, the resulting mazes can be more time-consuming.

(I've also got a program that renders the mazes as 2.5D worlds for Doom, so you can walk through them in a first-person view. Anyone interested in that is welcome to contact me.)

This page last updated
December 18, 2000

toys