2017-05-20 04:10:13 -04:00
|
|
|
## blindmaz.cmd -- solve maze by walking a left-handed blind mouse
|
|
|
|
|
|
|
|
#7 set $seed
|
2019-06-22 02:03:15 -04:00
|
|
|
#execute-file maze.cmd
|
|
|
|
execute-file floodmaz.cmd
|
2017-05-20 04:10:13 -04:00
|
|
|
set %x 2
|
|
|
|
set %y $curline
|
|
|
|
end-of-line
|
|
|
|
set %stopcol &sub $curcol 1
|
|
|
|
|
|
|
|
set %DX0 1
|
|
|
|
set %DY0 0
|
|
|
|
set %DX1 0
|
|
|
|
set %DY1 1
|
|
|
|
set %DX2 -1
|
|
|
|
set %DY2 0
|
|
|
|
set %DX3 0
|
|
|
|
set %DY3 -1
|
|
|
|
|
|
|
|
set %dotc &asc "."
|
|
|
|
|
2019-06-22 02:03:15 -04:00
|
|
|
store-procedure probe
|
2017-05-20 04:10:13 -04:00
|
|
|
set %OX &ind &cat "%DX" %nD
|
|
|
|
set %OY &ind &cat "%DY" %nD
|
|
|
|
set %nx &add %x %OX
|
|
|
|
set %ny &add %y %OY
|
|
|
|
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 when backtracking (or highlight)
|
|
|
|
!endif
|
|
|
|
set %D %nD
|
|
|
|
set $curchar %C
|
|
|
|
set $curline %y
|
|
|
|
set $curcol %x
|
|
|
|
set $curchar %C
|
|
|
|
set %x &add %nx %OX
|
|
|
|
set %y &add %ny %OY
|
|
|
|
set $curline %y
|
|
|
|
set $curcol %x
|
|
|
|
set %res TRUE
|
|
|
|
!else
|
|
|
|
set %res FALSE
|
|
|
|
!endif
|
2020-05-10 00:08:24 -04:00
|
|
|
update-screen
|
2017-05-20 04:10:13 -04:00
|
|
|
!endm
|
|
|
|
|
|
|
|
set %D 0 # looking EAST
|
|
|
|
!while &les %x %stopcol
|
|
|
|
set %nD &mod &add %D 3 4 # Can go left?
|
2019-06-22 02:03:15 -04:00
|
|
|
run probe
|
2017-05-20 04:10:13 -04:00
|
|
|
!if &seq %res FALSE
|
|
|
|
set %nD %D # Can go straight?
|
2019-06-22 02:03:15 -04:00
|
|
|
run probe
|
2017-05-20 04:10:13 -04:00
|
|
|
!if &seq %res FALSE
|
|
|
|
set %nD &mod &add %D 1 4 # Can go right?
|
2019-06-22 02:03:15 -04:00
|
|
|
run probe
|
2017-05-20 04:10:13 -04:00
|
|
|
!if &seq %res FALSE
|
|
|
|
set %D &mod &add %D 2 4 # Go back!
|
|
|
|
!endif
|
|
|
|
!endif
|
|
|
|
!endif
|
|
|
|
!endwhile
|
|
|
|
beginning-of-file
|
|
|
|
set $curline 3
|
|
|
|
set $curcol 1
|
2021-07-21 04:40:36 -04:00
|
|
|
unmark-buffer
|