Maze generation: Difference between revisions

Content added Content deleted
(Javascript: showing intermediate results)
Line 210: Line 210:


Note however that this leaves the final '#' in place on maze completion, and that the function <code>maze</code> no longer returns a result which represents a generated maze.
Note however that this leaves the final '#' in place on maze completion, and that the function <code>maze</code> no longer returns a result which represents a generated maze.

Note also that this display suggests an optimization. You can replace the line reading <code>path.push(here= next);</code> with:

<lang javascript> here= next;
if (1 < neighbors.length)
path.push(here);</lang>

And this does indeed save a negligible bit of processing, but the maze algorithm will still be forced to backtrack through a number of locations which have no unvisited neighbors.


=={{header|PicoLisp}}==
=={{header|PicoLisp}}==