I'm looking for a very simple implementation of the Depth-first search random maze generation algorithm. I'm trying to get my head around it, but i just can't understand the neighbor identification part.
http://en.wikipedia.org/wiki/Maze_generation_algorithm#Depth-first_search
开发者_如何学运维Maybe someone can provide a simple snippet? :)
What do you mean, "the neighbor identification part"? If you're at (x,y)
, the neighbors are (x-1,y)
, (x,y-1)
, (x+1,y)
and (x,y+1)
.
You want to randomly select an edge (Wall) from a vertex. Each vertex has 4 edges (North, South, West, East). First off you want to build a tree with all vertex IMO in Zig-Zag order?
精彩评论