From f18df4c1df35bee66173dd219db5dbc0042f619a Mon Sep 17 00:00:00 2001 From: Alchav <59858495+Alchav@users.noreply.github.com> Date: Fri, 21 Oct 2022 21:29:20 -0400 Subject: [PATCH] [Core] Fix priority location handling in accessibility corrections (#1121) * Fix priority location handling in accessibility corrections * Don't lock empty locations * black sliver's suggested change Co-authored-by: black-sliver <59490463+black-sliver@users.noreply.github.com> Co-authored-by: black-sliver <59490463+black-sliver@users.noreply.github.com> --- Fill.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Fill.py b/Fill.py index 2c035995..cb9844b4 100644 --- a/Fill.py +++ b/Fill.py @@ -232,13 +232,13 @@ def accessibility_corrections(world: MultiWorld, state: CollectionState, locatio if location in state.events: state.events.remove(location) locations.append(location) - - if pool: + if pool and locations: + locations.sort(key=lambda loc: loc.progress_type != LocationProgressType.PRIORITY) fill_restrictive(world, state, locations, pool) def inaccessible_location_rules(world: MultiWorld, state: CollectionState, locations): - maximum_exploration_state = sweep_from_pool(state, []) + maximum_exploration_state = sweep_from_pool(state) unreachable_locations = [location for location in locations if not location.can_reach(maximum_exploration_state)] if unreachable_locations: def forbid_important_item_rule(item: Item): @@ -285,15 +285,10 @@ def distribute_items_restrictive(world: MultiWorld) -> None: nonlocal lock_later lock_later.append(location) - # "priority fill" - fill_restrictive(world, world.state, prioritylocations, progitempool, swap=False, on_place=mark_for_locking) - accessibility_corrections(world, world.state, prioritylocations, progitempool) - - for location in lock_later: - location.locked = True - del mark_for_locking, lock_later - if prioritylocations: + # "priority fill" + fill_restrictive(world, world.state, prioritylocations, progitempool, swap=False, on_place=mark_for_locking) + accessibility_corrections(world, world.state, prioritylocations, progitempool) defaultlocations = prioritylocations + defaultlocations if progitempool: @@ -304,6 +299,11 @@ def distribute_items_restrictive(world: MultiWorld) -> None: f'Not enough locations for progress items. There are {len(progitempool)} more items than locations') accessibility_corrections(world, world.state, defaultlocations) + for location in lock_later: + if location.item: + location.locked = True + del mark_for_locking, lock_later + inaccessible_location_rules(world, world.state, defaultlocations) remaining_fill(world, excludedlocations, filleritempool)