From 5cb26896093c4a558f7c7563a50344924dfecc9a Mon Sep 17 00:00:00 2001 From: Fabian Dill Date: Fri, 7 May 2021 21:01:13 +0200 Subject: [PATCH] LttP: speed up ER shuffling caves --- worlds/alttp/EntranceShuffle.py | 14 ++++---------- worlds/alttp/Rom.py | 1 + 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/worlds/alttp/EntranceShuffle.py b/worlds/alttp/EntranceShuffle.py index fa441bbf..b7d43235 100644 --- a/worlds/alttp/EntranceShuffle.py +++ b/worlds/alttp/EntranceShuffle.py @@ -2027,16 +2027,9 @@ def connect_caves(world, lw_entrances, dw_entrances, caves, player): world.random.shuffle(lw_entrances) world.random.shuffle(dw_entrances) world.random.shuffle(caves) - while caves: - # connect highest exit count caves first, prevent issue where we have 2 or 3 exits accross worlds left to fill - cave_candidate = (None, 0) - for i, cave in enumerate(caves): - if isinstance(cave, str): - cave = (cave,) - if len(cave) > cave_candidate[1]: - cave_candidate = (i, len(cave)) - cave = caves.pop(cave_candidate[0]) - + # connect highest exit count caves first, prevent issue where we have 2 or 3 exits accross worlds left to fill + caves.sort(key=lambda cave: 1 if isinstance(cave, str) else len(cave), reverse=True) + for cave in caves: target = lw_entrances if world.random.randint(0, 1) == 0 else dw_entrances if isinstance(cave, str): cave = (cave,) @@ -2048,6 +2041,7 @@ def connect_caves(world, lw_entrances, dw_entrances, caves, player): for exit in cave: connect_two_way(world, target.pop(), exit, player) + caves.clear() # emulating old behaviour of popping caves from the list in-place def connect_doors(world, doors, targets, player): diff --git a/worlds/alttp/Rom.py b/worlds/alttp/Rom.py index 439e0ef6..964ec34b 100644 --- a/worlds/alttp/Rom.py +++ b/worlds/alttp/Rom.py @@ -511,6 +511,7 @@ class Sprite(): palette_size = 120 glove_size = 4 author_name: Optional[str] = None + base_data: bytes def __init__(self, filename): if not hasattr(Sprite, "base_data"):