Maze Generator

Type of Maze
Horizontal size of maze – East/west (number of cells)
Vertical size of maze – North/South (number of cells)
Vertical size of maze – Up/Down (number of cells)
NOTE Can only be >1 for
rectangular mazes with 3D view
Viewpoint
Chance of continuous runs (Probability 0 to 1)
Chance of direction being continued in continuous runs (Probability 0 to 1)
Random seed (use zero for a new maze each time)




NOTE: 3D navigation of the maze requires that Javascript be enabled in your browser, and that the browser be a fairly recent revision. Also, the maze is opened in a new window (or tab) so your browser should allow this.

If you want to “solve” the maze, try working your way from the X to the square.

The probabilities in the last two numbers are probably the most interesting to play with.

Mazes have been a longtime fascination of mine. I wrote my first maze generation program back around 1986, on a Dick Smith VZ200.

  • Technically a single-solution maze such as is generated here is an undirected acyclic graph, with certain constraints applied.
  • The inherent geometry of a square graph is the same as a hex graph, except that a hex map allows connections to six neigbours rather than four. In fact, the algorithm used here represents a hex graph internally as a grid.
  • The 3D topology is now enabled. If you want to try the third dimension, I STRONGLY suggest you try a very small maze first. The 3D maze view includes a randomised goal.
  • More interestingly, the algorithm is also easily adapted to a four dimensional space, where each square allows you to warp to one of two interconnected hyperdimensions.I’ve thought about trying to implement this but thinking about the space rotations in four dimensions in order to generate the first person view gives me headaches. What I may do instead is code the algorithm to only do fourth dimension transitions if a third dimension path is not available, then add “warp up” and “warp down” buttons to the UI.I will probably do this sooner or later. Navigating a hypercube is just too cool an idea to pass up. I doubt that I’ll carry the hex generation across to that however.
  • The hex grid can be mapped trivially to a circular maze. (The center of the circle is the hex in the middle of the maze). I may or may not actually do this at some point. Calculating the arc segments isn’t inherently difficult but my last maths class was in 1988.
  • This is the first nontrivial program I’ve implemented using PHP (although I’ve tweaked existing code in the past). Ditto Javascript (the PHP has a boatload of embedded javascript to render the 3D view).

3 thoughts on “Maze Generator

  1. I really like your work on the first-person 3D maze. There’s a project I’m working on that could be joined together with your script to make something pretty awesome. Comment on this if you’re interested in doing business. I’d rather not leave too many details out here.

Leave a Reply

Your email address will not be published. Required fields are marked *