Maze building algorithm