diff --git a/Dungeons.py b/Dungeons.py index 711c17b9..2df052fe 100644 --- a/Dungeons.py +++ b/Dungeons.py @@ -103,14 +103,13 @@ def fill_dungeons(world): world.state._clear_cache() -def fill_dungeons_restrictive(world): +def fill_dungeons_restrictive(world, shuffled_locations): all_state_base = world.get_all_state() - 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 - - shuffled_locations=world.get_unfilled_locations() - random.shuffle(shuffled_locations) + skull_woods_big_chest = world.get_location('[dungeon-D3-B1] Skull Woods - South of Big Chest') + world.push_item(skull_woods_big_chest, ItemFactory('Small Key (Skull Woods)'), False) + skull_woods_big_chest.event = True + shuffled_locations.remove(skull_woods_big_chest) dungeon_items = [item for dungeon in world.dungeons for item in dungeon.all_items] diff --git a/Fill.py b/Fill.py index e98f2799..512229b3 100644 --- a/Fill.py +++ b/Fill.py @@ -199,9 +199,11 @@ def fill_restrictive(world, base_state, locations, itempool): spot_to_fill.event = True -def distribute_items_restrictive(world, gftower_trash_count=0): - # get list of locations to fill in - fill_locations = world.get_unfilled_locations() +def distribute_items_restrictive(world, gftower_trash_count=0,fill_locations=None): + # If not passed in, then get a shuffled list of locations to fill in + if not fill_locations: + fill_locations = world.get_unfilled_locations() + random.shuffle(fill_locations) # get items to distribute random.shuffle(world.itempool) @@ -221,24 +223,26 @@ def distribute_items_restrictive(world, gftower_trash_count=0): trashcnt += 1 random.shuffle(fill_locations) + fill_locations.reverse() fill_restrictive(world, world.state, fill_locations, progitempool) random.shuffle(fill_locations) - while prioitempool and fill_locations: - spot_to_fill = fill_locations.pop() - item_to_place = prioitempool.pop() - world.push_item(spot_to_fill, item_to_place, False) + fast_fill(world, prioitempool, fill_locations) - while restitempool and fill_locations: - spot_to_fill = fill_locations.pop() - item_to_place = restitempool.pop() - world.push_item(spot_to_fill, item_to_place, False) + fast_fill(world, restitempool, fill_locations) logging.getLogger('').debug('Unplaced items: %s - Unfilled Locations: %s' % ([item.name for item in progitempool + prioitempool + restitempool], [location.name for location in fill_locations])) +def fast_fill(world, item_pool, fill_locations): + while item_pool and fill_locations: + spot_to_fill = fill_locations.pop() + item_to_place = item_pool.pop() + world.push_item(spot_to_fill, item_to_place, False) + + def flood_items(world): # get items to distribute random.shuffle(world.itempool) diff --git a/Main.py b/Main.py index e716f0aa..f93e5fa0 100644 --- a/Main.py +++ b/Main.py @@ -57,8 +57,11 @@ def main(args, seed=None): logger.info('Placing Dungeon Items.') + shuffled_locations = None if args.algorithm == 'vt26': - fill_dungeons_restrictive(world) + shuffled_locations = world.get_unfilled_locations() + random.shuffle(shuffled_locations) + fill_dungeons_restrictive(world, shuffled_locations) else: fill_dungeons(world) @@ -75,7 +78,7 @@ def main(args, seed=None): elif args.algorithm == 'vt25': distribute_items_restrictive(world, 0) elif args.algorithm == 'vt26': - distribute_items_restrictive(world, random.randint(0, 15)) + distribute_items_restrictive(world, random.randint(0, 15), shuffled_locations) logger.info('Calculating playthrough.')