Monday, September 19, 2011

Linear Maze

Different maze-generation algorithms can produce drastically different results.Up until now, in SpaceRL I've been using an algorithm that picks a random potential connection and adds it if it is joining two disjoint areas of the maze.Here is a version that does a depth-first traversal instead. It maintains a stack of potential connections to visit. Starting at the entrance, it pushes all potential outgoing edges onto the stack (in random order), then pops edges off until it finds one that goes to an unvisited room. After adding that edge it then pushes on all the unused exits from that room, and so forth until the stack is empty.The result is a maze with a much longer, more linear main path. I'm not sure whether this is good or not, but it's different.

No comments:

Post a Comment