From 530c5500c35798e6d943403a10f20b2e0f2ded94 Mon Sep 17 00:00:00 2001 From: Alchav <59858495+Alchav@users.noreply.github.com> Date: Sun, 3 Jul 2022 11:11:11 -0400 Subject: [PATCH] Break out of fill loop if locations is empty (#690) --- Fill.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Fill.py b/Fill.py index 39c4f547..a5cf155e 100644 --- a/Fill.py +++ b/Fill.py @@ -42,8 +42,16 @@ def fill_restrictive(world: MultiWorld, base_state: CollectionState, locations: has_beaten_game = world.has_beaten_game(maximum_exploration_state) - for item_to_place in items_to_place: + while items_to_place: + # if we have run out of locations to fill,break out of this loop + if not locations: + unplaced_items += items_to_place + break + item_to_place = items_to_place.pop(0) + spot_to_fill: typing.Optional[Location] = None + + # if minimal accessibility, only check whether location is reachable if game not beatable if world.accessibility[item_to_place.player] == 'minimal': perform_access_check = not world.has_beaten_game(maximum_exploration_state, item_to_place.player) \ @@ -54,7 +62,7 @@ def fill_restrictive(world: MultiWorld, base_state: CollectionState, locations: for i, location in enumerate(locations): if (not single_player_placement or location.player == item_to_place.player) \ and location.can_fill(maximum_exploration_state, item_to_place, perform_access_check): - # poping by index is faster than removing by content, + # popping by index is faster than removing by content, spot_to_fill = locations.pop(i) # skipping a scan for the element break