Maze generation: Difference between revisions

Content added Content deleted
m (→‎{{header|Erlang}}: Removed unnecessary "out" templates)
Line 1,869: Line 1,869:
Erlang is single assignment. To get mutability I use processes. The code is over-enginered for this task, but the extra is used for [[Maze_solving]]. Also, Erlang starts counting at 1, not 0, so the co-ordinate of the lower left corner is 1,1.
Erlang is single assignment. To get mutability I use processes. The code is over-enginered for this task, but the extra is used for [[Maze_solving]]. Also, Erlang starts counting at 1, not 0, so the co-ordinate of the lower left corner is 1,1.


{{out|Original example (implemented with multiple processes)}}
===Original example (implemented with multiple processes)===
<lang Erlang>
<lang Erlang>
-module( maze ).
-module( maze ).
Line 2,038: Line 2,038:
</pre>
</pre>


{{out|Alternative example (implemented with 2 diagraphs)}}
===Alternative example (implemented with 2 diagraphs)===
Uses 2 diagraph "objects": a) the 'matrix', a fully connected digraph of MxN vertices and b) the 'maze', an unconnected digraph, also MxN, that is populated while walking.
Uses 2 diagraph "objects": a) the 'matrix', a fully connected digraph of MxN vertices and b) the 'maze', an unconnected digraph, also MxN, that is populated while walking.
Employs a faux Visitor pattern to populate the maze while traversing the matrix in depth-first order.
Employs a faux Visitor pattern to populate the maze while traversing the matrix in depth-first order.