2021-09-07 23:05:51 -04:00
|
|
|
## floodmaz.cmd -- solve maze by painting wall on the right
|
2021-08-31 21:40:34 -04:00
|
|
|
|
2017-05-18 23:19:13 -04:00
|
|
|
# 6 set $seed
|
2021-08-31 21:40:34 -04:00
|
|
|
# either maze.cmd or sharpmaz.cmd
|
|
|
|
execute-file sharpmaz.cmd
|
2017-05-18 23:19:13 -04:00
|
|
|
|
|
|
|
set %thisbuf $cbufname
|
2021-08-31 21:40:34 -04:00
|
|
|
set %meml $curline
|
|
|
|
set %memc $curcol
|
2017-05-18 23:19:13 -04:00
|
|
|
|
|
|
|
set $curline 1
|
|
|
|
set $curcol 0
|
2021-09-07 23:05:51 -04:00
|
|
|
!gosub pushxy #push stop position
|
2017-05-18 23:19:13 -04:00
|
|
|
set %x 1
|
|
|
|
set $curline 4
|
|
|
|
set $curcol %x
|
|
|
|
set %OC $curchar
|
|
|
|
set %NC &asc "█"
|
|
|
|
!while ¬ &equ %x 0
|
|
|
|
set $curchar %NC
|
|
|
|
set %cc $curcol
|
|
|
|
set %ll $curline
|
|
|
|
set $curcol &add %cc 1
|
2021-09-07 23:05:51 -04:00
|
|
|
!gosub probe
|
2017-05-18 23:19:13 -04:00
|
|
|
set $curcol &add %cc -1
|
2021-09-07 23:05:51 -04:00
|
|
|
!gosub probe
|
2017-05-18 23:19:13 -04:00
|
|
|
set $curline &add %ll 1
|
|
|
|
set $curcol %cc
|
2021-09-07 23:05:51 -04:00
|
|
|
!gosub probe
|
2017-05-18 23:19:13 -04:00
|
|
|
set $curline &add %ll -1
|
|
|
|
set $curcol %cc
|
2021-09-07 23:05:51 -04:00
|
|
|
!gosub probe
|
|
|
|
# pop x y
|
|
|
|
select-buffer stack
|
|
|
|
beginning-of-file
|
|
|
|
set %x $line
|
|
|
|
1 kill-to-end-of-line
|
|
|
|
set %y $line
|
|
|
|
1 kill-to-end-of-line
|
|
|
|
select-buffer %thisbuf
|
|
|
|
set $curline %y
|
|
|
|
set $curcol %x
|
2017-05-18 23:19:13 -04:00
|
|
|
!endwhile
|
2021-08-31 21:40:34 -04:00
|
|
|
|
|
|
|
set $curline %meml
|
|
|
|
set $curcol %memc
|
2021-07-21 04:40:36 -04:00
|
|
|
select-buffer stack
|
|
|
|
unmark-buffer
|
|
|
|
select-buffer %thisbuf
|
|
|
|
unmark-buffer
|
|
|
|
delete-buffer stack
|
2021-09-07 23:05:51 -04:00
|
|
|
!return
|
|
|
|
|
|
|
|
:probe
|
|
|
|
!if ¬ &or &equ $curchar %NC &equ $curchar 32
|
|
|
|
:pushxy # push x y
|
|
|
|
set %x $curcol
|
|
|
|
set %y $curline
|
|
|
|
select-buffer stack
|
|
|
|
beginning-of-file
|
|
|
|
insert-string %x
|
|
|
|
newline
|
|
|
|
insert-string %y
|
|
|
|
newline
|
|
|
|
select-buffer %thisbuf
|
|
|
|
!endif
|
|
|
|
!return
|