Maze generation: Difference between revisions

Added 11l
m (changed size.)
(Added 11l)
Line 16:
* [[Maze solving]].
<br><br>
 
=={{header|11l}}==
{{trans|Python}}
 
<lang 11l>F make_maze(w = 16, h = 8)
V vis = [[0] * w [+] [1]] * h [+] [[1] * (w + 1)]
V ver = [[‘| ’] * w [+] [String(‘|’)]] * h [+] [[String]()]
V hor = [[‘+--’] * w [+] [String(‘+’)]] * (h + 1)
 
F walk(Int x, Int y) -> N
@vis[y][x] = 1
V d = [(x - 1, y), (x, y + 1), (x + 1, y), (x, y - 1)]
random:shuffle(&d)
L(=xx, =yy) d
I yy == -1
yy = @vis.len - 1
I xx == -1
xx = @vis[0].len - 1
I @vis[yy][xx]
L.continue
I xx == x
@hor[max(y, yy)][x] = ‘+ ’
I yy == y
@ver[y][max(x, xx)] = ‘ ’
@walk(xx, yy)
 
walk(random:(w), random:(h))
 
V s = ‘’
L(a, b) zip(hor, ver)
s ‘’= (a [+] [String("\n")] + b [+] [String("\n")]).join(‘’)
R s
 
print(make_maze())
</lang>
 
{{out}}
<pre>
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
| | | |
+ +--+--+--+--+--+--+--+--+--+ + +--+ + +--+
| | | | | | |
+--+--+--+--+--+--+ + +--+ +--+ + + + + +
| | | | | | | | | |
+ + +--+--+ + +--+ + +--+ +--+ + +--+ +
| | | | | | | | |
+ +--+--+--+--+--+ + + + +--+ + +--+--+--+
| | | | | | | | | | |
+ +--+--+ + + + +--+ + + +--+--+ +--+ +
| | | | | | | | | |
+--+ + +--+ +--+ + +--+ + + +--+--+ + +
| | | | | | | | | | |
+ + +--+ +--+ +--+--+ +--+--+--+--+--+ + +
| | | |
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
</pre>
 
=={{header|Ada}}==
1,481

edits