Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Algorithms for 3D Mazes [closed]

Are there algorithms to produce 3 dimensional mazes? Essentially the same as a 2D maze but the Z depth axis can be traversed? The idea is still the same though, to get from Start to End. Could backtracking still be used?

Which algorithm should I use to generate a 3D maze?

See here. I mean that you can go into the cube too, not just iterate the faces of it.

like image 256
jmasterx Avatar asked Dec 10 '11 00:12

jmasterx


1 Answers

I made 2d mazes a few years ago using Kruskal's Algorithm here. There should be no reason this couldn't work with the 3d case you described. Basically you'd consider a cell a cube, and have a large array that has (for every cells), 6 walls in the +/- x, y, and z directions. The algorithm initially starts with all walls everywhere and randomly makes walls disappear until every cell in the maze is connected.

like image 143
Ben Goodrich Avatar answered Sep 22 '22 10:09

Ben Goodrich