Reintroduce sweep_for_crystal_access - currently required in certain layouts (key door blocks flow of blue-state between reachable rooms)

This commit is contained in:
compiling
2020-01-17 21:19:31 +11:00
parent ee7d795780
commit b6d17e5f12
2 changed files with 34 additions and 34 deletions

View File

@@ -405,19 +405,21 @@ class CollectionState(object):
self.spread_crystal_access(candidate, CrystalBarrier.Either, rrp, ccr, player) self.spread_crystal_access(candidate, CrystalBarrier.Either, rrp, ccr, player)
else: else:
for entrance in candidate.entrances: for entrance in candidate.entrances:
door = self.world.check_for_door(entrance.name, player) if entrance.can_reach(self):
if door is None or entrance.parent_region.type != RegionType.Dungeon: door = self.world.check_for_door(entrance.name, player)
ccr[candidate] = CrystalBarrier.Orange if door is None or entrance.parent_region.type != RegionType.Dungeon:
if entrance.parent_region in ccr.keys(): ccr[candidate] = CrystalBarrier.Orange
color_type = ccr[entrance.parent_region] if entrance.parent_region in ccr.keys():
if door is not None and door.crystal != CrystalBarrier.Null: color_type = ccr[entrance.parent_region]
color_type &= door.crystal if door is not None and door.crystal != CrystalBarrier.Null:
if candidate in ccr.keys(): color_type &= door.crystal
color_type |= ccr[candidate] if candidate in ccr.keys():
ccr[candidate] = color_type color_type |= ccr[candidate]
if not candidate in ccr.keys() or color_type != ccr[candidate]:
ccr[candidate] = color_type
for ext in candidate.exits: for ext in candidate.exits:
connect = ext.connected_region connect = ext.connected_region
if connect in rrp and connect in ccr: if connect in rrp and ext.can_reach(self) and connect in ccr:
door = self.world.check_for_door(ext.name, player) door = self.world.check_for_door(ext.name, player)
if door is not None and not door.blocked: if door is not None and not door.blocked:
color_type = ccr[candidate] color_type = ccr[candidate]
@@ -437,17 +439,17 @@ class CollectionState(object):
for ext in region.exits: for ext in region.exits:
connect = ext.connected_region connect = ext.connected_region
if connect not in visited and connect is not None and connect.type == RegionType.Dungeon: if connect not in visited and connect is not None and connect.type == RegionType.Dungeon:
if connect in rrp and ext.can_reach(self) and connect: if connect in rrp and connect in ccr and ext.can_reach(self) and connect:
door = self.world.check_for_door(ext.name, player) door = self.world.check_for_door(ext.name, player)
current_crystal = ccr[connect] if door is not None and not door.blocked:
if door is not None and not door.blocked and current_crystal != crystal and current_crystal != CrystalBarrier.Either: current_crystal = ccr[connect]
if door.crystal in [CrystalBarrier.Either, CrystalBarrier.Null]: new_crystal = crystal
ccr[connect] = crystal if door.crystal != CrystalBarrier.Null:
queue.append((connect, crystal)) new_crystal &= door.crystal
else: new_crystal |= current_crystal
queue.append((connect, door.crystal)) if current_crystal != new_crystal:
if door.crystal != current_crystal: ccr[connect] = new_crystal
ccr[connect] = CrystalBarrier.Either queue.append((connect, new_crystal))
def copy(self): def copy(self):
ret = CollectionState(self.world) ret = CollectionState(self.world)
@@ -474,14 +476,14 @@ class CollectionState(object):
return spot.can_reach(self) return spot.can_reach(self)
# def sweep_for_crystal_access(self): def sweep_for_crystal_access(self):
# for player, rrp in self.reachable_regions.items():
# dungeon_regions = [x for x in rrp if x.type == RegionType.Dungeon] for player, rrp in self.reachable_regions.items():
# ccr = self.colored_regions[player] dungeon_regions = [x for x in rrp if x.type == RegionType.Dungeon]
# for region in dungeon_regions: ccr = self.colored_regions[player]
# if region in ccr.keys(): for region in dungeon_regions:
# self.spread_crystal_access(region, ccr[region], rrp, ccr, player) if region in ccr.keys():
# self.stale[player] = True self.spread_crystal_access(region, ccr[region], rrp, ccr, player)
def sweep_for_events(self, key_only=False, locations=None): def sweep_for_events(self, key_only=False, locations=None):
# this may need improvement # this may need improvement
@@ -500,8 +502,8 @@ class CollectionState(object):
self.collect(event.item, True, event) self.collect(event.item, True, event)
new_locations = len(reachable_events) > checked_locations new_locations = len(reachable_events) > checked_locations
checked_locations = len(reachable_events) checked_locations = len(reachable_events)
#if new_locations: if new_locations:
# self.sweep_for_crystal_access() self.sweep_for_crystal_access()
def can_reach_blue(self, region, player): def can_reach_blue(self, region, player):
if region not in self.colored_regions[player].keys(): if region not in self.colored_regions[player].keys():

View File

@@ -223,7 +223,7 @@ def main(args, seed=None):
world.spoiler.to_file(output_path('%s_Spoiler.txt' % outfilebase)) world.spoiler.to_file(output_path('%s_Spoiler.txt' % outfilebase))
logger.info('Done. Enjoy.') logger.info('Done. Enjoy.')
logger.debug('Total Time: %s', time.perf_counter() - start) logger.info('Total Time: %s', time.perf_counter() - start)
return world return world
@@ -363,7 +363,6 @@ def create_playthrough(world):
logging.getLogger('').debug('Building up collection spheres.') logging.getLogger('').debug('Building up collection spheres.')
while sphere_candidates: while sphere_candidates:
state.sweep_for_events(key_only=True) state.sweep_for_events(key_only=True)
#state.sweep_for_crystal_access()
sphere = [] sphere = []
# build up spheres of collection radius. Everything in each sphere is independent from each other in dependencies and only depends on lower spheres # build up spheres of collection radius. Everything in each sphere is independent from each other in dependencies and only depends on lower spheres
@@ -425,7 +424,6 @@ def create_playthrough(world):
collection_spheres = [] collection_spheres = []
while required_locations: while required_locations:
state.sweep_for_events(key_only=True) state.sweep_for_events(key_only=True)
#state.sweep_for_crystal_access()
sphere = list(filter(lambda loc: state.can_reach(loc) and state.not_flooding_a_key(world, loc), required_locations)) sphere = list(filter(lambda loc: state.can_reach(loc) and state.not_flooding_a_key(world, loc), required_locations))