speed up can_beat_game

This commit is contained in:
Fabian Dill 2021-04-29 09:54:49 +02:00
parent 3a1d33f499
commit bed8fe82cf
1 changed files with 5 additions and 5 deletions

View File

@ -405,24 +405,24 @@ class MultiWorld():
if self.has_beaten_game(self.state):
return True
state = CollectionState(self)
prog_locations = {location for location in self.get_locations() if location.item is not None and (
location.item.advancement or location.event) and location not in state.locations_checked}
prog_locations = {location for location in self.get_locations() if location.item
and location.item.advancement and location not in state.locations_checked}
while prog_locations:
sphere = []
sphere = set()
# build up spheres of collection radius.
# Everything in each sphere is independent from each other in dependencies and only depends on lower spheres
for location in prog_locations:
if location.can_reach(state):
sphere.append(location)
sphere.add(location)
if not sphere:
# ran out of places and did not finish yet, quit
return False
for location in sphere:
prog_locations.remove(location)
state.collect(location.item, True, location)
prog_locations -= sphere
if self.has_beaten_game(state):
return True