Maze solving: Difference between revisions

m (syntax highlighting fixup automation)
Line 1,436:
[https://easylang.online/apps/_r_maze.html Run it]
 
<syntaxhighlight lang="text">size = 20
size = 20
n = 2 * size + 1
endpos = n * n - 21
startpos = n + 12
#
f = 100 / (n - 0.5)
Line 1,447 ⟶ 1,448:
func show_maze . .
clear
for i range= 1 to len m[]
if m[i] = 0
x = (i - 1) mod n
y = (i - 1) div n
color 777
move x * f - f / 2 y * f - f / 2
Line 1,465 ⟶ 1,466:
m[pos] = 0
call show_maze
d[] = [ 0 1 2 3 4 ]
for i = 34 downto 01
d = random (i + 1)
dir = d[d]
d[d] = d[i]
r = (pos - 1) div n
c = (pos - 1) mod n
posn = pos + 2 * offs[dir]
if c <> brdc[dir] and r <> brdr[dir] and m[posn] <> 0
Line 1,481 ⟶ 1,482:
.
func make_maze . .
for i range= 1 to len m[]
m[i] = 1
.
Line 1,491 ⟶ 1,492:
#
func mark pos col . .
x = (pos - 1) mod n
y = (pos - 1) div n
color col
move x * f + f / 4 y * f + f / 4
Line 1,503 ⟶ 1,504:
found = 1
else
for dir range= 1 to 4
posn = pos + offs[dir]
if dir <> dir0 and m[posn] = 0 and found = 0
call solve (dir + 21) mod 4 + 1 posn found
if found = 0
call mark posn 777
Line 1,515 ⟶ 1,516:
.
.
sleep 32
call solve -10 startpos found</syntaxhighlight>
</syntaxhighlight>
 
=={{header|EGL}}==
2,060

edits