Tweak fill algorithm to more closely match VT26
This commit is contained in:
parent
dcc34bd39f
commit
fcc97cef81
11
Dungeons.py
11
Dungeons.py
|
@ -103,14 +103,13 @@ def fill_dungeons(world):
|
||||||
world.state._clear_cache()
|
world.state._clear_cache()
|
||||||
|
|
||||||
|
|
||||||
def fill_dungeons_restrictive(world):
|
def fill_dungeons_restrictive(world, shuffled_locations):
|
||||||
all_state_base = world.get_all_state()
|
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)
|
skull_woods_big_chest = world.get_location('[dungeon-D3-B1] Skull Woods - South of Big Chest')
|
||||||
world.get_location('[dungeon-D3-B1] Skull Woods - South of Big Chest').event = True
|
world.push_item(skull_woods_big_chest, ItemFactory('Small Key (Skull Woods)'), False)
|
||||||
|
skull_woods_big_chest.event = True
|
||||||
shuffled_locations=world.get_unfilled_locations()
|
shuffled_locations.remove(skull_woods_big_chest)
|
||||||
random.shuffle(shuffled_locations)
|
|
||||||
|
|
||||||
dungeon_items = [item for dungeon in world.dungeons for item in dungeon.all_items]
|
dungeon_items = [item for dungeon in world.dungeons for item in dungeon.all_items]
|
||||||
|
|
||||||
|
|
24
Fill.py
24
Fill.py
|
@ -199,9 +199,11 @@ def fill_restrictive(world, base_state, locations, itempool):
|
||||||
spot_to_fill.event = True
|
spot_to_fill.event = True
|
||||||
|
|
||||||
|
|
||||||
def distribute_items_restrictive(world, gftower_trash_count=0):
|
def distribute_items_restrictive(world, gftower_trash_count=0,fill_locations=None):
|
||||||
# get list of locations to fill in
|
# If not passed in, then get a shuffled list of locations to fill in
|
||||||
|
if not fill_locations:
|
||||||
fill_locations = world.get_unfilled_locations()
|
fill_locations = world.get_unfilled_locations()
|
||||||
|
random.shuffle(fill_locations)
|
||||||
|
|
||||||
# get items to distribute
|
# get items to distribute
|
||||||
random.shuffle(world.itempool)
|
random.shuffle(world.itempool)
|
||||||
|
@ -221,24 +223,26 @@ def distribute_items_restrictive(world, gftower_trash_count=0):
|
||||||
trashcnt += 1
|
trashcnt += 1
|
||||||
|
|
||||||
random.shuffle(fill_locations)
|
random.shuffle(fill_locations)
|
||||||
|
fill_locations.reverse()
|
||||||
|
|
||||||
fill_restrictive(world, world.state, fill_locations, progitempool)
|
fill_restrictive(world, world.state, fill_locations, progitempool)
|
||||||
|
|
||||||
random.shuffle(fill_locations)
|
random.shuffle(fill_locations)
|
||||||
|
|
||||||
while prioitempool and fill_locations:
|
fast_fill(world, prioitempool, fill_locations)
|
||||||
spot_to_fill = fill_locations.pop()
|
|
||||||
item_to_place = prioitempool.pop()
|
|
||||||
world.push_item(spot_to_fill, item_to_place, False)
|
|
||||||
|
|
||||||
while restitempool and fill_locations:
|
fast_fill(world, restitempool, fill_locations)
|
||||||
spot_to_fill = fill_locations.pop()
|
|
||||||
item_to_place = restitempool.pop()
|
|
||||||
world.push_item(spot_to_fill, item_to_place, False)
|
|
||||||
|
|
||||||
logging.getLogger('').debug('Unplaced items: %s - Unfilled Locations: %s' % ([item.name for item in progitempool + prioitempool + restitempool], [location.name for location in 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):
|
def flood_items(world):
|
||||||
# get items to distribute
|
# get items to distribute
|
||||||
random.shuffle(world.itempool)
|
random.shuffle(world.itempool)
|
||||||
|
|
7
Main.py
7
Main.py
|
@ -57,8 +57,11 @@ def main(args, seed=None):
|
||||||
|
|
||||||
logger.info('Placing Dungeon Items.')
|
logger.info('Placing Dungeon Items.')
|
||||||
|
|
||||||
|
shuffled_locations = None
|
||||||
if args.algorithm == 'vt26':
|
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:
|
else:
|
||||||
fill_dungeons(world)
|
fill_dungeons(world)
|
||||||
|
|
||||||
|
@ -75,7 +78,7 @@ def main(args, seed=None):
|
||||||
elif args.algorithm == 'vt25':
|
elif args.algorithm == 'vt25':
|
||||||
distribute_items_restrictive(world, 0)
|
distribute_items_restrictive(world, 0)
|
||||||
elif args.algorithm == 'vt26':
|
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.')
|
logger.info('Calculating playthrough.')
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue