1
0
mirror of https://github.com/rfivet/uemacs.git synced 2024-12-24 10:06:30 -05:00
uemacs/blindmaz.cmd

69 lines
1.2 KiB
Batchfile
Raw Normal View History

## blindmaz.cmd -- solve maze by walking a left-handed blind mouse
#7 set $seed
#execute-file maze.cmd
execute-file floodmaz.cmd
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 "."
store-procedure probe
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
!endm
set %D 0 # looking EAST
!while &les %x %stopcol
set %nD &mod &add %D 3 4 # Can go left?
run probe
!if &seq %res FALSE
set %nD %D # Can go straight?
run probe
!if &seq %res FALSE
set %nD &mod &add %D 1 4 # Can go right?
run probe
!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