Maze generation: Difference between revisions

m
(→‎Quality Breadth-First: Remove fr (frontier cells) hash table that contributes nothing.)
Line 2,041:
| | | |
+---+---+---+---+---+---+---+---+---+---+---+---+---+---+</pre>
=={{header|Easyprog.online}}==
 
<lang easyprog.online>size = 20
#
sz = 2 * size + 1
# we only have one-dimensional arrays
len f[] sz * sz
#
func make_maze . .
for i range len f[]
f[i] = 1
.
f[(sz - 1) * sz + sz - 2] = 0
visited = 1
x = 1 + 2 * random size
y = 1 + 2 * random size
f[x + y * sz] = 0
#
while visited < size * size
oldx = x
oldy = y
dir = random 4
if dir = 0
if x + 2 < sz
x += 2
.
elif dir = 1
if y + 2 < sz
y += 2
.
elif dir = 2
if x > 2
x -= 2
.
else
if y > 2
y -= 2
.
.
if f[y * sz + x] = 1
f[y * sz + x] = 0
f[(y + oldy) / 2 * sz + (x + oldx) / 2] = 0
visited += 1
.
.
.
func show_maze . .
c2# = (100 - 24 / size) / size / 2
c10# = c2# / 5
linewidth 2 * c10#
color 997
move 0 0
rect 100 100
color 543
for r range sz
for c range sz
if f[r * sz + c] = 1
if r mod 2 = 0
if c mod 2 = 1
move c10# + (c - 1) * c2# c10# + r * c2#
line c10# + (c + 1) * c2# c10# + r * c2#
.
else
move c10# + c * c2# c10# + (r - 1) * c2#
line c10# + c * c2# c10# + (r + 1) * c2#
.
.
.
.
.
call make_maze
call show_maze</lang>
 
=={{header|EGL}}==
2,076

edits