Maze generation: Difference between revisions

Content added Content deleted
(Javascript: added a small bit of documentation)
Line 143: Line 143:
# <code>x</code>,<code>y</code> -- dimensions of maze
# <code>x</code>,<code>y</code> -- dimensions of maze
# <code>n</code> -- number of openings to be generated
# <code>n</code> -- number of openings to be generated
# <code>horiz</code> -- two dimensional array of location of horizontal openings
# <code>horiz</code> -- two dimensional array of locations of horizontal openings (true means wall is open)
# <code>verti</code> -- two dimensional array of location of vertical openings
# <code>verti</code> -- two dimensional array of locations of vertical openings (true means wall is open)
# <code>here</code> -- current location under consideration
# <code>here</code> -- current location under consideration
# <code>path</code> -- history (stack) of locations that might need to be revisited
# <code>path</code> -- history (stack) of locations that might need to be revisited
# <code>unvisited</code> -- two dimensional array of locations that have not been visited (padded to avoid need for boundary tests)
# <code>unvisited</code> -- two dimensional array of locations that have not been visited, padded to avoid need for boundary tests (true means location needs to be visited)
# <code>potential</code> -- locations adjacent to <code>here</code>
# <code>potential</code> -- locations adjacent to <code>here</code>
# <code>neighbors</code> -- unvisited locations adjacent to <code>here</code>
# <code>neighbors</code> -- unvisited locations adjacent to <code>here</code>
Line 155: Line 155:
# <code>text</code> -- lines of text representing maze
# <code>text</code> -- lines of text representing maze
# <code>line</code> -- text of current line
# <code>line</code> -- text of current line

Note that this implementation relies on javascript arrays being treatable as infinite in size with false (empty) values springing into existence as needed, to support referenced array locations. (This significantly reduces the bulk of the necessary initialization code.)


Example use:
Example use: