diff --git a/blindmaz.cmd b/blindmaz.cmd index ae8ae74..2dd6c18 100644 --- a/blindmaz.cmd +++ b/blindmaz.cmd @@ -1,11 +1,13 @@ ## blindmaz.cmd -- solve maze by walking a left-handed blind mouse #7 set $seed -#execute-file maze.cmd -#execute-file floodmaz.cmd -execute-file sharpmaz.cmd -set %x 2 -set %y $curline +# either maze.cmd, sharpmaz.cmd or floodmaz.cmd +execute-file floodmaz.cmd + +set %meml $curline # save entrance location +set %memc $curcol +set %x &add %memc 1 +set %y %meml end-of-line set %stopcol &sub $curcol 1 @@ -18,7 +20,7 @@ set %DY2 0 set %DX3 0 set %DY3 -1 -set %dotc &asc "." +set %dotc &asc "•" # alternatively use "." store-procedure probe set %OX &ind &cat "%DX" %nD @@ -65,7 +67,6 @@ set %D 0 # looking EAST !endif !endif !endwhile -beginning-of-file -set $curline 3 -set $curcol 1 +set $curline %meml +set $curcol %memc unmark-buffer diff --git a/floodmaz.cmd b/floodmaz.cmd index 5d2d20a..8ca7c2f 100644 --- a/floodmaz.cmd +++ b/floodmaz.cmd @@ -1,7 +1,12 @@ +## floodmaz.cmd -- solve maze by painting right wall + # 6 set $seed -execute-file maze.cmd +# either maze.cmd or sharpmaz.cmd +execute-file sharpmaz.cmd set %thisbuf $cbufname +set %meml $curline +set %memc $curcol store-procedure pushxy # push x y set %x $curcol @@ -27,6 +32,12 @@ store-procedure popxy # pop x y set $curcol %x !endm +store-procedure probe + !if ¬ &or &equ $curchar %NC &equ $curchar 32 + run pushxy + !endif +!endm + set $curline 1 set $curcol 0 run pushxy #push stop position @@ -40,27 +51,20 @@ set %NC &asc "█" set %cc $curcol set %ll $curline set $curcol &add %cc 1 - !if &equ $curchar %OC - run pushxy - !endif + run probe set $curcol &add %cc -1 - !if &equ $curchar %OC - run pushxy - !endif + run probe set $curline &add %ll 1 set $curcol %cc - !if &equ $curchar %OC - run pushxy - !endif + run probe set $curline &add %ll -1 set $curcol %cc - !if &equ $curchar %OC - run pushxy - !endif + run probe run popxy !endwhile -set $curline 3 -set $curcol 1 + +set $curline %meml +set $curcol %memc select-buffer stack unmark-buffer select-buffer %thisbuf diff --git a/maze.cmd b/maze.cmd index 18b49d7..edea298 100644 --- a/maze.cmd +++ b/maze.cmd @@ -1,6 +1,7 @@ -# record seed +## maze.cmd -- draw a block maze + # 5 set $seed -set %S $seed +set %S $seed # record seed # setup direction offsets set %D1 0 diff --git a/sharpmaz.cmd b/sharpmaz.cmd index 44bd71a..32c2488 100644 --- a/sharpmaz.cmd +++ b/sharpmaz.cmd @@ -1,51 +1,53 @@ +## sharpmaz.cmd -- redraw a block maze using line characters + execute-file maze.cmd +set %meml $curline +set %memc $curcol end-of-line set %ec &sub $curcol 1 end-of-file set %el &sub $curline 1 -set $curline %el +previous-line set %spaces $line -set $curline 1 +beginning-of-file set %old $line set $line %spaces -set %l 2 -!while &less %l %el - set $curline %l - set %c 1 - !while &less %c %ec - set $curcol %c +next-line +!while &less $curline %el + set $curcol 1 + !while &less $curcol %ec !if ¬ &equ $curchar 32 set %v 0 - set $curline &sub %l 1 - set $curcol %c + previous-line !if ¬ &equ $curchar 32 set %v &add %v 1 !endif - set $curline %l - set $curcol &sub %c 1 + next-line + backward-character !if ¬ &equ $curchar 32 set %v &add %v 2 !endif - set $curcol &add %c 1 + 2 forward-character !if ¬ &equ $curchar 32 set %v &add %v 4 !endif - set $curline &add %l 1 - set $curcol %c + next-line + backward-character !if ¬ &equ $curchar 32 set %v &add %v 8 !endif - set $curline %l - set $curcol %c - set $curchar &asc &mid "╳╵╴┘╶└─┴╷│┐┤┌├┬┼" &add %v 1 1 + previous-line + # alternatively use single width "╳╵╴┘╶└─┴╷│┐┤┌├┬┼" + set $curchar &asc &mid "╳╹╸┛╺┗━┻╻┃┓┫┏┣┳╋" &add %v 1 1 !endif - set %c &add %c 1 + forward-character !endwhile - set %l &add %l 1 + next-line !endwhile -set $curline 1 + +beginning-of-file set $line %old -set $curline 3 -set $curcol 1 +set $curline %meml +set $curcol %memc