Maze solving: Difference between revisions
→{{header|EasyLang}}
Thundergnat (talk | contribs) m (syntax highlighting fixup automation) |
|||
Line 1,436:
[https://easylang.online/apps/_r_maze.html Run it]
<syntaxhighlight lang="text">
size = 20
n = 2 * size + 1
endpos = n * n -
startpos = n +
#
f = 100 / (n - 0.5)
Line 1,447 ⟶ 1,448:
func show_maze . .
clear
for i
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[] = [
for i =
d = random
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
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
posn = pos + offs[dir]
if dir <> dir0 and m[posn] = 0 and found = 0
call solve (dir +
if found = 0
call mark posn 777
Line 1,515 ⟶ 1,516:
.
.
sleep
call solve
</syntaxhighlight>
=={{header|EGL}}==
|