From b6d17e5f128024d44d25961439ffd864ce95f130 Mon Sep 17 00:00:00 2001 From: compiling <8335770+compiling@users.noreply.github.com> Date: Fri, 17 Jan 2020 21:19:31 +1100 Subject: [PATCH] Reintroduce sweep_for_crystal_access - currently required in certain layouts (key door blocks flow of blue-state between reachable rooms) --- BaseClasses.py | 64 ++++++++++++++++++++++++++------------------------ Main.py | 4 +--- 2 files changed, 34 insertions(+), 34 deletions(-) diff --git a/BaseClasses.py b/BaseClasses.py index dfe71b27..063f7f9d 100644 --- a/BaseClasses.py +++ b/BaseClasses.py @@ -405,19 +405,21 @@ class CollectionState(object): self.spread_crystal_access(candidate, CrystalBarrier.Either, rrp, ccr, player) else: for entrance in candidate.entrances: - door = self.world.check_for_door(entrance.name, player) - if door is None or entrance.parent_region.type != RegionType.Dungeon: - ccr[candidate] = CrystalBarrier.Orange - if entrance.parent_region in ccr.keys(): - color_type = ccr[entrance.parent_region] - if door is not None and door.crystal != CrystalBarrier.Null: - color_type &= door.crystal - if candidate in ccr.keys(): - color_type |= ccr[candidate] - ccr[candidate] = color_type + if entrance.can_reach(self): + door = self.world.check_for_door(entrance.name, player) + if door is None or entrance.parent_region.type != RegionType.Dungeon: + ccr[candidate] = CrystalBarrier.Orange + if entrance.parent_region in ccr.keys(): + color_type = ccr[entrance.parent_region] + if door is not None and door.crystal != CrystalBarrier.Null: + color_type &= door.crystal + if candidate in ccr.keys(): + color_type |= ccr[candidate] + if not candidate in ccr.keys() or color_type != ccr[candidate]: + ccr[candidate] = color_type for ext in candidate.exits: 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) if door is not None and not door.blocked: color_type = ccr[candidate] @@ -437,17 +439,17 @@ class CollectionState(object): for ext in region.exits: connect = ext.connected_region 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) - current_crystal = ccr[connect] - if door is not None and not door.blocked and current_crystal != crystal and current_crystal != CrystalBarrier.Either: - if door.crystal in [CrystalBarrier.Either, CrystalBarrier.Null]: - ccr[connect] = crystal - queue.append((connect, crystal)) - else: - queue.append((connect, door.crystal)) - if door.crystal != current_crystal: - ccr[connect] = CrystalBarrier.Either + if door is not None and not door.blocked: + current_crystal = ccr[connect] + new_crystal = crystal + if door.crystal != CrystalBarrier.Null: + new_crystal &= door.crystal + new_crystal |= current_crystal + if current_crystal != new_crystal: + ccr[connect] = new_crystal + queue.append((connect, new_crystal)) def copy(self): ret = CollectionState(self.world) @@ -474,14 +476,14 @@ class CollectionState(object): return spot.can_reach(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] - # ccr = self.colored_regions[player] - # for region in dungeon_regions: - # if region in ccr.keys(): - # self.spread_crystal_access(region, ccr[region], rrp, ccr, player) - # self.stale[player] = True + 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] + ccr = self.colored_regions[player] + for region in dungeon_regions: + if region in ccr.keys(): + self.spread_crystal_access(region, ccr[region], rrp, ccr, player) def sweep_for_events(self, key_only=False, locations=None): # this may need improvement @@ -500,8 +502,8 @@ class CollectionState(object): self.collect(event.item, True, event) new_locations = len(reachable_events) > checked_locations checked_locations = len(reachable_events) - #if new_locations: - # self.sweep_for_crystal_access() + if new_locations: + self.sweep_for_crystal_access() def can_reach_blue(self, region, player): if region not in self.colored_regions[player].keys(): diff --git a/Main.py b/Main.py index bf39881c..678067b4 100644 --- a/Main.py +++ b/Main.py @@ -223,7 +223,7 @@ def main(args, seed=None): world.spoiler.to_file(output_path('%s_Spoiler.txt' % outfilebase)) logger.info('Done. Enjoy.') - logger.debug('Total Time: %s', time.perf_counter() - start) + logger.info('Total Time: %s', time.perf_counter() - start) return world @@ -363,7 +363,6 @@ def create_playthrough(world): logging.getLogger('').debug('Building up collection spheres.') while sphere_candidates: state.sweep_for_events(key_only=True) - #state.sweep_for_crystal_access() sphere = [] # 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 = [] while required_locations: 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))