diff --git a/squirrelbattle/entities/player.py b/squirrelbattle/entities/player.py index dd4d6f0..45e2bdf 100644 --- a/squirrelbattle/entities/player.py +++ b/squirrelbattle/entities/player.py @@ -133,10 +133,11 @@ class Player(FightingEntity): # For each tile that is reached by at least one Dijkstra, sort the # different paths by distance to the player. For the technical bits : # The reduce function is a fold starting on the first element of the - # 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. 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( [(distances[i][(y, x)], predecessors[i][(y, x)]) for i in range(len(distances)) if (y, x) in predecessors[i]])]