-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWALLS.py
More file actions
274 lines (240 loc) · 12.2 KB
/
Copy pathWALLS.py
File metadata and controls
274 lines (240 loc) · 12.2 KB
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
import numpy as np
WALLS = {
'EmptyRoom':
np.array([
[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
[1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1],
[1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1],
[1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1],
[1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1],
[1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1],
[1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1],
[1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1],
[1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1],
[1,0,0,0,0,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# [1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1],
# [1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1],
# [1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1],
# [1,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,1],
# [1,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,1],
# [1,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,1],
# [1,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,1],
# [1,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,1],
# [1,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1],
# [1,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,1],
# [1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1],
# [1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1],
# [1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1],
# [1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1],
# [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
# ]),
'EmptyRoomBounds':
np.array([
# x1, y1, x2, y2
(0, 0, 17, 1), # Left wall
(0, 16, 17, 17), # Right wall
(0, 0, 1, 17), # Top wall
(16, 0, 17, 17), # Bottom wall
]),
# 'EmptyRoomBounds':
# np.array([
# # x1, y1, x2, y2
# (0, 0, 17, 1), # Left wall
# (0, 16, 17, 17), # Right wall
# (0, 0, 1, 17), # Top wall
# (16, 0, 17, 17), # Bottom wall
# # middle 1s
# (11,5,12,6),
# (10,6,11,7),
# (9,7,10,8),
# (8,8,9,9),
# (7,9,8,10),
# (6,10,7,11),
# (5,11,6,12),
# (10,5,11,6),
# (9,6,10,7),
# (8,7,9,8),
# (7,8,8,9),
# (6,9,7,10),
# (5,10,6,11),
# (11,6,12,7),
# (10,7,11,8),
# (9,8,10,9),
# (8,9,9,10),
# (7,10,8,11),
# (6,11,7,12),
# ]),
'FourRooms':
np.array([
[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
[1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1],
[1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1],
[1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1],
[1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1], ## tunnel
[1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1],
[1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1],
[1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1],
[1,1,1,1,0,1,1,1,1,1,1,1,0,1,1,1,1], ## tunnel
[1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1],
[1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1],
[1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1],
[1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1], ## tunnel
[1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1],
[1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1],
[1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1],
[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
]),
'FourRoomsBounds':
np.array([
# x1, y1, x2, y2
(0, 0, 17, 1), # Left wall
(0, 16, 17, 17), # Right wall
(0, 0, 1, 17), # Top wall
(16, 0, 17, 17), # Bottom wall
(1, 8, 4, 9), # middle up wall
(5, 8, 12, 9), # middle mid wall
(13, 8, 16, 9), # middle down wall
(8, 1, 9, 4), # middle left wall
(8, 5, 9, 12), # middle mid wall
(8, 13, 9, 16), # middle right wall
]),
# ------------------------------------------------------------
# New maze for "repair (SFT) + stitch-to-goal (RL)" demonstration
# ------------------------------------------------------------
# Updated: green regions -> empty (0), yellow region -> walls (1)
"GuidanceCorridorMaze": np.array(
[
[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
[1,0,0,0,0,1,0,1,0,0,0,1,0,0,0,0,1],
[1,0,0,0,0,1,0,1,0,0,0,1,0,0,0,0,1],
[1,0,0,0,0,1,0,1,1,0,1,1,0,0,0,0,1],
[1,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1],
[1,0,0,0,0,0,0,1,1,0,0,1,0,0,0,0,1],
[1,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,1],
[1,1,1,1,1,1,1,1,1,0,1,1,1,1,0,1,1],
[1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1],
[1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1],
[1,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1],
[1,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1],
[1,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1],
[1,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1],
[1,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1],
[1,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1],
[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
],
dtype=np.int32,
),
# This bounds array matches the grid EXACTLY (outer border + internal rectangles).
# "GuidanceCorridorMazeBounds": np.array(
# [
# # --- Outer Borders ---
# (0, 0, 17, 1), # Left Wall (Rows 0-17, Col 0)
# (0, 16, 17, 17), # Right Wall (Rows 0-17, Col 16)
# (0, 0, 1, 17), # Top Wall (Row 0, Cols 0-17)
# (16, 0, 17, 17), # Bottom Wall (Row 16, Cols 0-17)
# # --- Middle Barrier (Row 7) ---
# # Grid logic: Walls at indices 0-8, Gap at 9, Walls at 10-13, Gap at 14, Walls at 15-16
# # Format: (RowStart, ColStart, RowEnd, ColEnd)
# (7, 0, 8, 9), # Wall Left of door (Cols 0 to 9 exclusive)
# (7, 10, 8, 14), # Wall Middle segment (Cols 10 to 14 exclusive)
# (7, 15, 8, 17), # Wall Right segment (Cols 15 to 17 exclusive)
# # # --- Upper Maze Internal Walls (Rows 1-6) ---
# # # Based on the numpy array provided
# (1, 5, 4, 6), # Vertical Wall @ Col 5 (Rows 1-3)
# (1, 7, 4, 8), # Vertical Wall @ Col 7 (Rows 1-3)
# (3, 8, 4, 9), # Single block @ Row 3, Col 8
# (3, 10, 4, 11), # Single block @ Row 3, Col 10
# (1, 11, 4, 12), # Vertical Wall @ Col 11 (Rows 1-3)
# (7, 6, 8, 7),
# # --- Upper Maze Internal Walls (Rows 1-6) ---
# # (1, 5, 4, 6), # Vertical Wall @ Col 5 (Rows 1-6)
# # (1, 7, 4, 8), # Vertical Wall @ Col 7 (Rows 1-3)
# # (3, 8, 4, 10), # Horizontal block @ Row 3, Cols 8-9
# # (3, 10, 4, 11), # Single block @ Row 3, Col 10
# # (1, 11, 7, 12), # Vertical Wall @ Col 11-12 (Rows 1-6)
# # Row 5 obstacles
# (5, 7, 6, 9), # Horizontal block @ Row 5, Cols 7-8
# (5, 11, 6, 12), # Single block @ Row 5, Col 11
# # --- Lower Maze Internal Walls (Rows 8-15) ---
# # Based on the large blocks of 1s in the bottom half
# # Row 10: Walls at Cols 10-16
# (10, 10, 11, 17),
# # Rows 11-14: Walls at Cols 6-16 (The large solid block)
# (11, 6, 15, 17),
# # Row 15: Walls at Cols 10-16
# (15, 10, 16, 17),
# ],
# dtype=np.int32,
# ),
"GuidanceCorridorMazeBounds": np.array(
[
# --- Outer Borders ---
(0, 0, 17, 1), # Left
(0, 16, 17, 17), # Right
(0, 0, 1, 17), # Top
(16, 0, 17, 17), # Bottom
# --- Middle Barrier (Row 7) ---
(7, 0, 8, 9), # Cols 0-8
(7, 10, 8, 14), # Cols 10-13
(7, 15, 8, 17), # Cols 15-16
# --- Upper Maze Internal Walls (Rows 1-6) ---
(1, 5, 4, 6), # Col 5, rows 1-3
(1, 7, 4, 8), # Col 7, rows 1-3
(3, 8, 4, 9), # (3,8)
(3, 10, 4, 11), # (3,10)
# FIX: col 11 is a continuous vertical wall rows 1-6
(1, 11, 7, 12), # Col 11, rows 1-6
# Row 5 obstacles
(5, 7, 6, 9), # Row 5, cols 7-8
# FIX: single wall cell at (6,5)
(6, 5, 7, 6), # (6,5)
# --- Lower Maze Internal Walls (Rows 8-15) ---
(10, 10, 11, 17), # Row 10, cols 10-16
(11, 6, 15, 17), # Rows 11-14, cols 6-16
(15, 10, 16, 17), # Row 15, cols 10-16
],
dtype=np.int32,
),
}
def check_bounds_match_grid(grid, bounds):
cov = np.zeros_like(grid, dtype=np.int32)
for r0, c0, r1, c1 in bounds:
cov[r0:r1, c0:c1] = 1
missing = np.argwhere((grid == 1) & (cov == 0))
extra = np.argwhere((grid == 0) & (cov == 1))
return missing, extra
missing, extra = check_bounds_match_grid(WALLS["GuidanceCorridorMaze"], WALLS["GuidanceCorridorMazeBounds"])
print("missing wall cells:", missing.tolist())
print("extra covered cells:", extra.tolist())