From 197b34194057a4e61cb6b3bf9e7ef983c44b6e72 Mon Sep 17 00:00:00 2001 From: LLCoolDave Date: Fri, 23 Jun 2017 19:07:34 +0200 Subject: [PATCH] Some fixups to restrictive algo --- Dungeons.py | 6 ++++-- Main.py | 23 ++++++++++++++++++----- Rules.py | 3 ++- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/Dungeons.py b/Dungeons.py index 86bcd200..e77805bc 100644 --- a/Dungeons.py +++ b/Dungeons.py @@ -23,8 +23,10 @@ def fill_dungeons(world): all_state_base = world.get_all_state() # this key is in a fixed location (for now) - world.push_item(world.get_location('[dungeon-D3-B1] Skull Woods - South of Big Chest'), ItemFactory('Small Key (Skull Woods)'), False) - world.get_location('[dungeon-D3-B1] Skull Woods - South of Big Chest').event = True + mandatory_sw_key_location = random.choice(['[dungeon-D3-B1] Skull Woods - South of Big Chest'] if world.shuffle != 'vanilla' else ['[dungeon-D3-B1] Skull Woods - South of Big Chest', '[dungeon-D3-B1] Skull Woods - Push Statue Room', '[dungeon-D3-B1] Skull Woods - Compass Room']) + + world.push_item(world.get_location(mandatory_sw_key_location), ItemFactory('Small Key (Skull Woods)'), False) + world.get_location(mandatory_sw_key_location).event = True for dungeon_regions, big_key, small_keys, dungeon_items in [TR, ES, EP, DP, ToH, AT, PoD, TT, SW, SP, IP, MM, GT]: # this is what we need to fill diff --git a/Main.py b/Main.py index 8fc32996..a1d6718c 100644 --- a/Main.py +++ b/Main.py @@ -249,10 +249,9 @@ def distribute_items_staleness(world): logging.getLogger('').debug('Unplaced items: %s - Unfilled Locations: %s' % ([item.name for item in itempool], [location.name for location in fill_locations])) -def distribute_items_restrictive(world): +def distribute_items_restrictive(world, gftower_trash_count=10): # get list of locations to fill in fill_locations = world.get_unfilled_locations() - random.shuffle(fill_locations) # get items to distribute random.shuffle(world.itempool) @@ -260,17 +259,29 @@ def distribute_items_restrictive(world): prioitempool = [item for item in world.itempool if not item.advancement and item.priority] restitempool = [item for item in world.itempool if not item.advancement and not item.priority] - def sweep_from_pool(excluded_item): + # fill in gtower locations with trash first + gtower_locations = [location for location in fill_locations if 'Ganons Tower' in location.name] + random.shuffle(gtower_locations) + trashcnt = 0 + while gtower_locations and restitempool and trashcnt < gftower_trash_count: + spot_to_fill = gtower_locations.pop() + item_to_place = restitempool.pop() + world.push_item(spot_to_fill, item_to_place, False) + fill_locations.remove(spot_to_fill) + trashcnt += 1 + + random.shuffle(fill_locations) + + def sweep_from_pool(): new_state = world.state.copy() for item in progitempool: new_state.collect(item, True) - new_state.remove(excluded_item) new_state.sweep_for_events() return new_state while progitempool and fill_locations: item_to_place = progitempool.pop() - maximum_exploration_state = sweep_from_pool(item_to_place) + maximum_exploration_state = sweep_from_pool() spot_to_fill = None for location in fill_locations: @@ -289,6 +300,8 @@ def distribute_items_restrictive(world): fill_locations.remove(spot_to_fill) spot_to_fill.event = True + random.shuffle(fill_locations) + while prioitempool and fill_locations: spot_to_fill = fill_locations.pop() item_to_place = prioitempool.pop() diff --git a/Rules.py b/Rules.py index 34079844..ef9d0b4e 100644 --- a/Rules.py +++ b/Rules.py @@ -248,7 +248,8 @@ def global_rules(world): set_rule(world.get_location('[dungeon-D6-B1] Misery Mire - Hub Room'), lambda state: state.has('Small Key (Misery Mire)', 1) or state.has('Big Key (Misery Mire)')) set_rule(world.get_location('[dungeon-D6-B1] Misery Mire - Map Room'), lambda state: state.has('Small Key (Misery Mire)', 1) or state.has('Big Key (Misery Mire)')) # we can place a small key in the West wing iff it also contains/blocks the Big Key, as we cannot reach and softlock with the basement key door yet - set_rule(world.get_entrance('Misery Mire (West)'), lambda state: state.has('Small Key (Misery Mire)', 3) if state.can_reach('Misery Mire (Final Area)') else state.has('Small Key (Misery Mire)', 2)) + set_rule(world.get_entrance('Misery Mire (West)'), lambda state: state.has('Small Key (Misery Mire)', 2) if ((state.world.get_location('[dungeon-D6-B1] Misery Mire - Compass Room').item is not None and state.world.get_location('[dungeon-D6-B1] Misery Mire - Compass Room').item.name in ['Big Key (Misery Mire)']) or + (state.world.get_location('[dungeon-D6-B1] Misery Mire - Big Key Room').item is not None and state.world.get_location('[dungeon-D6-B1] Misery Mire - Big Key Room').item.name in ['Big Key (Misery Mire)'])) else state.has('Small Key (Misery Mire)', 3)) set_rule(world.get_location('[dungeon-D6-B1] Misery Mire - Compass Room'), lambda state: state.has_fire_source()) set_rule(world.get_location('[dungeon-D6-B1] Misery Mire - Big Key Room'), lambda state: state.has_fire_source()) set_rule(world.get_entrance('Misery Mire (Vitreous)'), lambda state: state.has('Cane of Somaria') and (state.has('Bow') or state.has_blunt_weapon()))