mirror of
https://github.com/rfivet/uemacs.git
synced 2024-11-16 09:36:29 -05:00
Add sample script to solve maze using blind mouse algorithm.
This commit is contained in:
parent
b4ff6798cd
commit
6d40d82dea
68
blindmaz.cmd
Normal file
68
blindmaz.cmd
Normal file
@ -0,0 +1,68 @@
|
||||
## 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 "."
|
||||
|
||||
12 store-macro
|
||||
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?
|
||||
execute-macro-12
|
||||
!if &seq %res FALSE
|
||||
set %nD %D # Can go straight?
|
||||
execute-macro-12
|
||||
!if &seq %res FALSE
|
||||
set %nD &mod &add %D 1 4 # Can go right?
|
||||
execute-macro-12
|
||||
!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
|
Loading…
Reference in New Issue
Block a user