Maze solving: Difference between revisions

Content added Content deleted
Line 1,473: Line 1,473:
.
.
endpos = n * n - 1
endpos = n * n - 1
startpos = n + 2
proc make_maze . .
proc make_maze . .
for i = 1 to len m[]
for i = 1 to len m[]
Line 1,484: Line 1,483:
m[n * n - n + i] = 2
m[n * n - n + i] = 2
.
.
h = 2 * random 15 - n + n * 2 * random 15
call m_maze startpos
call m_maze h
m[endpos] = 0
m[endpos] = 0
endpos += n
endpos += n
Line 1,511: Line 1,511:
call solve (dir + 1) mod 4 + 1 posn found
call solve (dir + 1) mod 4 + 1 posn found
if found = 0
if found = 0
call mark posn 777
call mark posn 888
sleep 0.08
sleep 0.08
.
.
Line 1,518: Line 1,518:
.
.
sleep 1
sleep 1
call solve 0 startpos found
call solve 0 n + 2 found
</syntaxhighlight>
</syntaxhighlight>