确保boss和lock只能在路径上生成
This commit is contained in:
parent
b88edf5d84
commit
e5b6011d41
@ -19,15 +19,21 @@ class SourceCollector:
|
|||||||
self.end_pos = None
|
self.end_pos = None
|
||||||
self.path = []
|
self.path = []
|
||||||
self.node_path = []
|
self.node_path = []
|
||||||
|
self.boss_pos = None
|
||||||
|
self.lock_pos = None
|
||||||
if self.filename:
|
if self.filename:
|
||||||
self.maze = []
|
self.maze = []
|
||||||
with open(f"{self.filename}",'r') as f:
|
with open(f"{self.filename}",'r') as f:
|
||||||
reader = csv.reader(f)
|
reader = csv.reader(f)
|
||||||
for row in reader:
|
for idx,row in enumerate(reader):
|
||||||
t = []
|
t = []
|
||||||
for i in row:
|
for idy,i in enumerate(row):
|
||||||
if i.startswith('b') or i.startswith('l'):
|
if i.startswith('b'):
|
||||||
t.append('0')
|
t.append('0')
|
||||||
|
self.boss_pos = (idx,idy)
|
||||||
|
elif i.startswith('l'):
|
||||||
|
t.append('0')
|
||||||
|
self.lock_pos = (idx,idy)
|
||||||
else:
|
else:
|
||||||
t.append(i)
|
t.append(i)
|
||||||
self.maze.append(t)
|
self.maze.append(t)
|
||||||
@ -142,8 +148,8 @@ class SourceCollector:
|
|||||||
children = sn.children[:]
|
children = sn.children[:]
|
||||||
for child in children:
|
for child in children:
|
||||||
self.dfs(child)
|
self.dfs(child)
|
||||||
|
if self.colNums < 11:
|
||||||
children.sort(key=lambda c: len(c.path))
|
children.sort(key=lambda c: len(c.path))
|
||||||
cur = None
|
cur = None
|
||||||
for idx, child in enumerate(children):
|
for idx, child in enumerate(children):
|
||||||
if child.dp > 0:
|
if child.dp > 0:
|
||||||
@ -203,11 +209,8 @@ class SourceCollector:
|
|||||||
if idx > 0:
|
if idx > 0:
|
||||||
if item == self.path[idx-1]:
|
if item == self.path[idx-1]:
|
||||||
del self.path[idx]
|
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:])
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user