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