确保boss和lock只能在路径上生成

This commit is contained in:
Guanforever 2025-06-30 18:30:01 +08:00
parent b88edf5d84
commit e5b6011d41

View File

@ -19,15 +19,21 @@ class SourceCollector:
self.end_pos = None
self.path = []
self.node_path = []
self.boss_pos = None
self.lock_pos = None
if self.filename:
self.maze = []
with open(f"{self.filename}",'r') as f:
reader = csv.reader(f)
for row in reader:
for idx,row in enumerate(reader):
t = []
for i in row:
if i.startswith('b') or i.startswith('l'):
for idy,i in enumerate(row):
if i.startswith('b'):
t.append('0')
self.boss_pos = (idx,idy)
elif i.startswith('l'):
t.append('0')
self.lock_pos = (idx,idy)
else:
t.append(i)
self.maze.append(t)
@ -142,8 +148,8 @@ class SourceCollector:
children = sn.children[:]
for child in children:
self.dfs(child)
children.sort(key=lambda c: len(c.path))
if self.colNums < 11:
children.sort(key=lambda c: len(c.path))
cur = None
for idx, child in enumerate(children):
if child.dp > 0:
@ -203,11 +209,8 @@ class SourceCollector:
if idx > 0:
if item == self.path[idx-1]:
del self.path[idx]
if self.path and self.end_pos and self.path[-1] != self.end_pos:
bfs_tail = self.bfs_path(self.path[-1], self.end_pos)
if bfs_tail:
self.path.extend(bfs_tail[1:])