PHP Maze Generator class

MazeI looked for PHP maze generation algorithms today and couldn’t find anything. Fortunately Wikipedia has an article on Maze generation algorithm with source code written in Java. The easiest part was to transfer the code to PHP (it looks like PHP supports the same bitwise operators’ syntax as Java), and the hardest to make it work properly (the problem was at the rendering stage). More information on mazes and ways to generate them, can be found here.

See the class in action as HTML output here and as SVG output here

Example usage for the class:

  require('class.maze.php');
  $maze = new Maze(40, 40);
  echo $maze->getStyle();
  echo $maze->render();

Update: (01.03.2008) version 1.1.0 now supports SVG output

Download:classmazephp.zip

Comments

comments powered by Disqus