2017-05-20 04:10:13 -04:00
|
|
|
## blindmaz.cmd -- solve maze by walking a left-handed blind mouse
|
|
|
|
|
|
|
|
#7 set $seed
|
2021-08-31 21:40:34 -04:00
|
|
|
# either maze.cmd, sharpmaz.cmd or floodmaz.cmd
|
|
|
|
execute-file floodmaz.cmd
|
|
|
|
|
2021-09-07 23:05:51 -04:00
|
|
|
set %dotc &asc "•" # alternatively use "."
|
|
|
|
set $curchar %dotc
|
|
|
|
set %x &add $curcol 1
|
|
|
|
set %y $curline
|
2017-05-20 04:10:13 -04:00
|
|
|
end-of-line
|
|
|
|
set %stopcol &sub $curcol 1
|
|
|
|
|
2021-09-07 23:05:51 -04:00
|
|
|
# X-Y offset for absolute direction: east, south, west, north
|
2017-05-20 04:10:13 -04:00
|
|
|
set %DX0 1
|
|
|
|
set %DY0 0
|
|
|
|
set %DX1 0
|
|
|
|
set %DY1 1
|
|
|
|
set %DX2 -1
|
|
|
|
set %DY2 0
|
|
|
|
set %DX3 0
|
|
|
|
set %DY3 -1
|
|
|
|
|
2021-09-07 23:05:51 -04:00
|
|
|
set %absD 0 # absolute direction: looking EAST
|
2017-05-20 04:10:13 -04:00
|
|
|
!while &les %x %stopcol
|
2021-09-07 23:05:51 -04:00
|
|
|
# try move on left, right or front
|
|
|
|
set %relD 3 # 3, 0, 1, 2 == left, front, right, back
|
|
|
|
!while ¬ &equ %relD 2
|
|
|
|
set %newD &mod &add %absD %relD 4
|
|
|
|
set %offX &ind &cat "%DX" %newD
|
|
|
|
set %offY &ind &cat "%DY" %newD
|
|
|
|
set %nx &add %x %offX
|
|
|
|
set %ny &add %y %offY
|
|
|
|
set $curline %ny
|
|
|
|
set $curcol %nx
|
|
|
|
!if &or &equ $curchar 32 &equ $curchar %dotc
|
|
|
|
!if &equ $curchar 32
|
|
|
|
set %C %dotc
|
|
|
|
!else
|
|
|
|
set %C &asc " " # erase (or highlight) when backtracking
|
2017-05-20 04:10:13 -04:00
|
|
|
!endif
|
2021-09-07 23:05:51 -04:00
|
|
|
set %absD %newD
|
|
|
|
set $curchar %C
|
|
|
|
set $curline %y
|
|
|
|
set $curcol %x
|
|
|
|
set $curchar %C
|
|
|
|
set %x &add %nx %offX
|
|
|
|
set %y &add %ny %offY
|
|
|
|
update-screen
|
|
|
|
!goto moveon
|
2017-05-20 04:10:13 -04:00
|
|
|
!endif
|
2021-09-07 23:05:51 -04:00
|
|
|
set %relD &mod &add %relD 1 4
|
|
|
|
!endwhile
|
|
|
|
# else turn around
|
2021-09-15 21:46:02 -04:00
|
|
|
set %absD &mod &add %absD 2 4 # face back!
|
2021-09-07 23:05:51 -04:00
|
|
|
:moveon
|
2017-05-20 04:10:13 -04:00
|
|
|
!endwhile
|
2021-09-07 23:05:51 -04:00
|
|
|
|
2021-09-15 21:46:02 -04:00
|
|
|
set $curcol &add %x -1
|
2021-07-21 04:40:36 -04:00
|
|
|
unmark-buffer
|