最後活躍 1747406569

capitalex's Avatar capitalex 已修改 1747406569. 還原成這個修訂版本

1 file changed, 20 insertions, 3 deletions

maze.nv

@@ -1,5 +1,13 @@
1 - = |pen position| -2 -2 =
2 - = || jump |cells| $row $col =
1 + = || jump pen x |pen position| $oldx $y |@math| $x =
2 + |pen position| $x $y
3 +
4 + = || jump pen y |pen position| $x $oldy |@math| $y =
5 + |pen position| $x $y
6 +
7 + = || jump |backtrack| $row $col =
8 + |@math| multiply $col 2
9 + |@math| multiply $row 2
10 + || jump pen x || jump pen y
3 11 |matrix position| $row $col
4 12 = || jump |generate| =
5 13
@@ -117,16 +125,25 @@
117 125 = || go in direction |@math| $n =
118 126 || clear navigation state || jump
119 127
128 + = || push location to backtrack stack |location| $row $col =
129 + |backtrack| $row $col
130 +
131 + = || push location to backtrack stack =
132 +
120 133 = || clear navigation state? |valid up neighbor| $r $c =
134 + || push location to backtrack stack
121 135 = || clear navigation state? |valid left neighbor| $r $c =
136 + || push location to backtrack stack
122 137 = || clear navigation state? |valid down neighbor| $r $c =
138 + || push location to backtrack stack
123 139 = || clear navigation state? |valid right neighbor| $r $c =
140 + || push location to backtrack stack
124 141 = || clear navigation state? |sweep| =
125 142 = || clear navigation state =
126 143
127 144 = || pick a random direction |matrix position| $row $col =
128 145 || find neighbors |location| $row $col
129 - || go in direction |sweep| |sweep| |sweep|
146 + || go in direction |location| $row $col |sweep| |sweep| |sweep|
130 147 |@math| random 1 5
131 148
132 149 = || update |generate|? =

capitalex's Avatar capitalex 已修改 1747369192. 還原成這個修訂版本

1 file changed, 142 insertions

maze.nv(檔案已創建)

@@ -0,0 +1,142 @@
1 + = |pen position| -2 -2 =
2 + = || jump |cells| $row $col =
3 + |matrix position| $row $col
4 + = || jump |generate| =
5 +
6 + = || restore cells |discarded cells| $row $col =
7 + |cells| $row $col || restore cells
8 + = || restore cells =
9 +
10 + = || delete cell |location| $row $col |cells| $row $col =
11 + || restore cells
12 + = || delete cell |location| $row $col? |cells| $r $c =
13 + |discarded cells| $r $c
14 + || delete cell
15 + = || delete cell |location| $row $col =
16 + || restore cells
17 +
18 + = || prepare cells |cells| 127 |@math| 127 =
19 + |cells| 127 127
20 +
21 + = || next column |@math| $col =
22 + |cells| 0 $col
23 + || prepare cells
24 +
25 + = || prepare cells |cells| $col |@math| 127 =
26 + |@math|add $col 1
27 + |cells| 127 $col
28 + || next column
29 +
30 + = || prepare cells |cells| $col |@math| $row =
31 + |@math| add $row 1
32 + |cells| $col
33 + |cells| $row $col
34 + || prepare cells
35 +
36 + = || prepare cells |cells| $row $col =
37 + |@math| add $row 1
38 + |cells| $col
39 + |cells| $row $col
40 + || prepare cells
41 +
42 + = || compute down $col |@math| $row =
43 + |down neighbor| $row $col
44 +
45 + = || compute right $row |@math| $col =
46 + |right neighbor| $row $col
47 +
48 + = || compute up $col |@math| $row =
49 + |up neighbor| $row $col
50 +
51 + = || compute left $row |@math| $col =
52 + |left neighbor| $row $col
53 +
54 + = || find valid neighbors? |down neighbor| $row $col |cells| $row $col =
55 + |discarded cells| $row $col
56 + |valid down neighbor| $row $col
57 +
58 + = || find valid neighbors? |right neighbor| $row $col |cells| $row $col =
59 + |discarded cells| $row $col
60 + |valid right neighbor| $row $col
61 +
62 + = || find valid neighbors? |up neighbor| $row $col |cells| $row $col =
63 + |discarded cells| $row $col
64 + |valid up neighbor| $row $col
65 +
66 + = || find valid neighbors? |left neighbor| $row $col |cells| $row $col =
67 + |discarded cells| $row $col
68 + |valid left neighbor| $row $col
69 +
70 + = || find valid neighbors? |cells| $row $col =
71 + |discarded cells| $row $col
72 +
73 + = |up neighbor| $row $col =
74 + = |right neighbor| $row $col =
75 + = |down neighbor| $row $col =
76 + = |left neighbor| $row $col =
77 +
78 + = || find valid neighbors =
79 + || restore cells
80 +
81 + = || find neighbors |location| $row $col =
82 + || compute down $col |@math| add $row 1
83 + || compute right $row |@math| add $col 1
84 + || compute up $col |@math| add $row -1
85 + || compute left $row |@math| add $col -1
86 + || find valid neighbors
87 +
88 + = || go in direction |@math| 1 |valid up neighbor| $row $col =
89 + || move up || move up
90 + || delete cell |location| $row $col
91 + |matrix position| $row $col || clear navigation state
92 +
93 + = || go in direction |@math| 2 |valid right neighbor| $row $col =
94 + || move right || move right
95 + || delete cell |location| $row $col
96 + |matrix position| $row $col || clear navigation state
97 +
98 + = || go in direction |@math| 3 |valid down neighbor| $row $col =
99 + || move down || move down
100 + || delete cell |location| $row $col
101 + |matrix position| $row $col || clear navigation state
102 +
103 + = || go in direction |@math| 4 |valid left neighbor| $row $col =
104 + || move left || move left
105 + || delete cell |location| $row $col
106 + |matrix position| $row $col || clear navigation state
107 +
108 + = || go in direction? |@math| 1 |sweep|=
109 + |@math| 2
110 + = || go in direction? |@math| 2 |sweep|=
111 + |@math| 3
112 + = || go in direction? |@math| 3 |sweep|=
113 + |@math| 4
114 + = || go in direction? |@math| 4 |sweep|=
115 + |@math| 1
116 +
117 + = || go in direction |@math| $n =
118 + || clear navigation state || jump
119 +
120 + = || clear navigation state? |valid up neighbor| $r $c =
121 + = || clear navigation state? |valid left neighbor| $r $c =
122 + = || clear navigation state? |valid down neighbor| $r $c =
123 + = || clear navigation state? |valid right neighbor| $r $c =
124 + = || clear navigation state? |sweep| =
125 + = || clear navigation state =
126 +
127 + = || pick a random direction |matrix position| $row $col =
128 + || find neighbors |location| $row $col
129 + || go in direction |sweep| |sweep| |sweep|
130 + |@math| random 1 5
131 +
132 + = || update |generate|? =
133 + || pick a random direction
134 +
135 + ==
136 + |cells| 1 0 |matrix position| 0 0 |screen resolution| 256 256
137 + || prepare cells
138 + || pen brush pencil
139 + || pen down
140 + || pen color 255 255 255
141 + |generate|
142 +
上一頁 下一頁