Fixed a bug when trying to pathfind when player is surrounded by inaccessible tiles

This commit is contained in:
Nicolas Margulies 2020-12-10 22:28:12 +01:00
parent cc6033e8e4
commit 01cc77e146
1 changed files with 3 additions and 2 deletions

View File

@ -136,7 +136,8 @@ class Player(FightingEntity):
# iterable, and we associate the points to their distance, sort # iterable, and we associate the points to their distance, sort
# along the distance, then only keep the points. # along the distance, then only keep the points.
self.paths = {} self.paths = {}
for y, x in reduce(set.union, [set(p.keys()) for p in predecessors]): for y, x in reduce(set.union,
[set(p.keys()) for p in predecessors], set()):
self.paths[(y, x)] = [p for d, p in sorted( self.paths[(y, x)] = [p for d, p in sorted(
[(distances[i][(y, x)], predecessors[i][(y, x)]) [(distances[i][(y, x)], predecessors[i][(y, x)])
for i in range(len(distances)) if (y, x) in predecessors[i]])] for i in range(len(distances)) if (y, x) in predecessors[i]])]