-
Notifications
You must be signed in to change notification settings - Fork 7
/
floodmaz.cmd
67 lines (62 loc) · 1.16 KB
/
floodmaz.cmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
## floodmaz.cmd -- solve maze by painting wall on the right
# 6 set $seed
# either maze.cmd or sharpmaz.cmd
execute-file sharpmaz.cmd
set %thisbuf $cbufname
set %meml $curline
set %memc $curcol
set $curline 1
set $curcol 0
!gosub pushxy #push stop position
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
!gosub probe
set $curcol &add %cc -1
!gosub probe
set $curline &add %ll 1
set $curcol %cc
!gosub probe
set $curline &add %ll -1
set $curcol %cc
!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
!endwhile
set $curline %meml
set $curcol %memc
select-buffer stack
unmark-buffer
select-buffer %thisbuf
unmark-buffer
delete-buffer stack
!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