Wednesday, August 27, 2008

The Mysterious Production of Mazes

...is not so mysterious to me anymore. Have a maze generator implemented in Javascript and Scalable Vector Graphics (SVG), a spin-off from another project. As usual, a browser modern enough to support the seven year old SVG specification is required. That means Safari 3.1, Firefox 3, and in this case Opera 9.52 works, too. The current version of Internet Explorer is, as in all things SVG, useless.

There are no isolated areas in the maze, so it should always be possible to find a path between any two arbitrary points. If you're actually trying to solve the maze, I suggest trying to go from the top-left corner to the bottom-right. The maze is generated randomly, so it's vanishingly unlikely that any two loadings will ever produce the same maze (unless some browser does a poor job of seeding Javascript's pseudo-random number generator).

As always, you can open this SVG in a dedicated window (which will produce a new maze for that window), and make that window any size you wish - the maze will scale up or down arbitrarily. However, if you want to change the complexity of the maze, you'll have to save the source of the maze, and tweak the two values (height and width) passed to the Maze function (look for the line "new Maze(75, 75);" very near the bottom of the file), and you can have mazes of any size.

No comments:

Post a Comment