From 63eb0ffc7b61d4667a2511f1a8a02361646c5ad7 Mon Sep 17 00:00:00 2001 From: caitsith2 Date: Thu, 18 Jun 2020 08:48:33 -0700 Subject: [PATCH 1/6] Max triforce pieces reduced to 90 --- EntranceRandomizer.py | 4 ++-- Mystery.py | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/EntranceRandomizer.py b/EntranceRandomizer.py index 80b2906c..19f62453 100755 --- a/EntranceRandomizer.py +++ b/EntranceRandomizer.py @@ -82,10 +82,10 @@ def parse_arguments(argv, no_defaults=False): 20 of them to beat the game. ''') parser.add_argument('--triforce_pieces_available', default=defval(30), - type=lambda value: min(max(int(value), 1), 112), + type=lambda value: min(max(int(value), 1), 90), help='''Set Triforce Pieces available in item pool.''') parser.add_argument('--triforce_pieces_required', default=defval(20), - type=lambda value: min(max(int(value), 1), 112), + type=lambda value: min(max(int(value), 1), 90), help='''Set Triforce Pieces required to win a Triforce Hunt''') parser.add_argument('--difficulty', default=defval('normal'), const='normal', nargs='?', choices=['normal', 'hard', 'expert'], diff --git a/Mystery.py b/Mystery.py index 9234ab29..173cf334 100644 --- a/Mystery.py +++ b/Mystery.py @@ -230,8 +230,8 @@ def get_choice(option, root) -> typing.Any: return interpret_on_off(root[option]) if not root[option]: return None - return interpret_on_off( - random.choices(list(root[option].keys()), weights=list(map(int, root[option].values())))[0]) + return interpret_on_off( + random.choices(list(root[option].keys()), weights=list(map(int, root[option].values())))[0]) def handle_name(name: str): @@ -297,12 +297,12 @@ def roll_settings(weights): ret.triforce_pieces_available = get_choice('triforce_pieces_available', weights) if "triforce_pieces_available" in weights else 30 - - ret.triforce_pieces_available = min(max(1, int(ret.triforce_pieces_available)), 112) + + ret.triforce_pieces_available = min(max(1, int(ret.triforce_pieces_available)), 90) ret.triforce_pieces_required = get_choice('triforce_pieces_required', weights) if "triforce_pieces_required" in weights else 20 - ret.triforce_pieces_required = min(max(1, int(ret.triforce_pieces_required)), 112) + ret.triforce_pieces_required = min(max(1, int(ret.triforce_pieces_required)), 90) ret.mode = get_choice('world_state', weights) if ret.mode == 'retro': From be48f96f654d0c91ce1c425b1b249e7a018c9c96 Mon Sep 17 00:00:00 2001 From: caitsith2 Date: Thu, 18 Jun 2020 08:49:54 -0700 Subject: [PATCH 2/6] Actually make sure excess heart pieces/containers become 20 rupees, since the max is 20 hearts anyways. --- ItemList.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ItemList.py b/ItemList.py index facb9b2f..62f6b662 100644 --- a/ItemList.py +++ b/ItemList.py @@ -64,8 +64,8 @@ difficulties = { progressive_armor_limit = 2, progressive_bow_limit = 2, progressive_bottle_limit = 4, - boss_heart_container_limit = 255, - heart_piece_limit = 255, + boss_heart_container_limit = 10, + heart_piece_limit = 24, ), 'hard': Difficulty( baseitems = normalbaseitems, From 75e185e43789d08d1b7dbacaeaf3ab79e856bf41 Mon Sep 17 00:00:00 2001 From: caitsith2 Date: Thu, 18 Jun 2020 08:51:38 -0700 Subject: [PATCH 3/6] Allow specififying returned default values. Disallow ALL zero weights. --- Mystery.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Mystery.py b/Mystery.py index 173cf334..2c91d74f 100644 --- a/Mystery.py +++ b/Mystery.py @@ -223,15 +223,17 @@ def convert_to_on_off(value): return {True: "on", False: "off"}.get(value, value) -def get_choice(option, root) -> typing.Any: +def get_choice(option, root, value=None) -> typing.Any: if option not in root: - return None + return value if type(root[option]) is not dict: return interpret_on_off(root[option]) if not root[option]: - return None + return value + if any(list(map(int, root[option].values()))): return interpret_on_off( random.choices(list(root[option].keys()), weights=list(map(int, root[option].values())))[0]) + raise RuntimeError(f"All options specified in {option} are weighted as zero.") def handle_name(name: str): From f8ad83c86d791756e2eb8af6cc3522f06a905acc Mon Sep 17 00:00:00 2001 From: caitsith2 Date: Thu, 18 Jun 2020 08:52:31 -0700 Subject: [PATCH 4/6] yaml descriptions are now optional --- Mystery.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Mystery.py b/Mystery.py index 2c91d74f..ad251f3b 100644 --- a/Mystery.py +++ b/Mystery.py @@ -63,14 +63,14 @@ def main(): weights_cache[args.weights] = get_weights(args.weights) except Exception as e: raise ValueError(f"File {args.weights} is destroyed. Please fix your yaml.") from e - print(f"Weights: {args.weights} >> {weights_cache[args.weights]['description']}") + print(f"Weights: {args.weights} >> {get_choice('description', weights_cache[args.weights], 'No description specified')}") if args.meta: try: weights_cache[args.meta] = get_weights(args.meta) except Exception as e: raise ValueError(f"File {args.meta} is destroyed. Please fix your yaml.") from e meta_weights = weights_cache[args.meta] - print(f"Meta: {args.meta} >> {meta_weights['meta_description']}") + print(f"Meta: {args.meta} >> {get_choice('meta_description', meta_weights, 'No description specified')}") if args.samesettings: raise Exception("Cannot mix --samesettings with --meta") @@ -80,7 +80,7 @@ def main(): try: if path not in weights_cache: weights_cache[path] = get_weights(path) - print(f"P{player} Weights: {path} >> {weights_cache[path]['description']}") + print(f"P{player} Weights: {path} >> {get_choice('description', weights_cache[path], 'No description specified')}") except Exception as e: raise ValueError(f"File {path} is destroyed. Please fix your yaml.") from e From d7d7f32d0cd60a2104944d6f05cc386562acdedd Mon Sep 17 00:00:00 2001 From: caitsith2 Date: Thu, 18 Jun 2020 08:55:15 -0700 Subject: [PATCH 5/6] Clean up get_choice(x,weights) if x in weights else y code. --- Mystery.py | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/Mystery.py b/Mystery.py index ad251f3b..e72ad0cf 100644 --- a/Mystery.py +++ b/Mystery.py @@ -259,8 +259,7 @@ def roll_settings(weights): ret.logic = {None: 'noglitches', 'none': 'noglitches', 'no_logic': 'nologic', 'overworld_glitches': 'owglitches', 'minor_glitches' : 'minorglitches'}[ glitches_required] - ret.progression_balancing = get_choice('progression_balancing', - weights) if 'progression_balancing' in weights else True + ret.progression_balancing = get_choice('progression_balancing', weights, True) # item_placement = get_choice('item_placement') # not supported in ER @@ -272,10 +271,10 @@ def roll_settings(weights): elif not dungeon_items: dungeon_items = "" - ret.mapshuffle = get_choice('map_shuffle', weights) if 'map_shuffle' in weights else 'm' in dungeon_items - ret.compassshuffle = get_choice('compass_shuffle', weights) if 'compass_shuffle' in weights else 'c' in dungeon_items - ret.keyshuffle = get_choice('smallkey_shuffle', weights) if 'smallkey_shuffle' in weights else 's' in dungeon_items - ret.bigkeyshuffle = get_choice('bigkey_shuffle', weights) if 'bigkey_shuffle' in weights else 'b' in dungeon_items + ret.mapshuffle = get_choice('map_shuffle', weights, 'm' in dungeon_items) + ret.compassshuffle = get_choice('compass_shuffle', weights, 'c' in dungeon_items) + ret.keyshuffle = get_choice('smallkey_shuffle', weights, 's' in dungeon_items) + ret.bigkeyshuffle = get_choice('bigkey_shuffle', weights, 'b' in dungeon_items) ret.accessibility = get_choice('accessibility', weights) @@ -297,13 +296,10 @@ def roll_settings(weights): ret.crystals_ganon = get_choice('ganon_open', weights) - ret.triforce_pieces_available = get_choice('triforce_pieces_available', - weights) if "triforce_pieces_available" in weights else 30 - + ret.triforce_pieces_available = get_choice('triforce_pieces_available', weights, 30) ret.triforce_pieces_available = min(max(1, int(ret.triforce_pieces_available)), 90) - ret.triforce_pieces_required = get_choice('triforce_pieces_required', - weights) if "triforce_pieces_required" in weights else 20 + ret.triforce_pieces_required = get_choice('triforce_pieces_required', weights, 20) ret.triforce_pieces_required = min(max(1, int(ret.triforce_pieces_required)), 90) ret.mode = get_choice('world_state', weights) @@ -343,7 +339,7 @@ def roll_settings(weights): ret.shufflepots = get_choice('pot_shuffle', weights) - ret.beemizer = int(get_choice('beemizer', weights)) if 'beemizer' in weights else 0 + ret.beemizer = int(get_choice('beemizer', weights, 0)) ret.timer = {'none': False, None: False, @@ -352,11 +348,11 @@ def roll_settings(weights): 'timed_ohko': 'timed-ohko', 'ohko': 'ohko', 'timed_countdown': 'timed-countdown', - 'display': 'display'}[get_choice('timer', weights)] if 'timer' in weights.keys() else False + 'display': 'display'}[get_choice('timer', weights, False)] - ret.dungeon_counters = get_choice('dungeon_counters', weights) if 'dungeon_counters' in weights else 'default' + ret.dungeon_counters = get_choice('dungeon_counters', weights, 'default') - ret.progressive = convert_to_on_off(get_choice('progressive', weights)) if "progressive" in weights else 'on' + ret.progressive = convert_to_on_off(get_choice('progressive', weights, 'on')) inventoryweights = weights.get('startinventory', {}) startitems = [] for item in inventoryweights.keys(): @@ -370,9 +366,9 @@ def roll_settings(weights): startitems.append(item) ret.startinventory = ','.join(startitems) - ret.glitch_boots = get_choice('glitch_boots', weights) if 'glitch_boots' in weights else True + ret.glitch_boots = get_choice('glitch_boots', weights, True) - ret.remote_items = get_choice('remote_items', weights) if 'remote_items' in weights else False + ret.remote_items = get_choice('remote_items', weights, False) ret.local_items = set() for item_name in weights.get('local_items', []): From 55a5812b6b29f9127c14afdac7f3911814c16301 Mon Sep 17 00:00:00 2001 From: caitsith2 Date: Thu, 18 Jun 2020 19:21:52 -0700 Subject: [PATCH 6/6] Remove list(map(int, x)) --- Mystery.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Mystery.py b/Mystery.py index e72ad0cf..6eda3ce3 100644 --- a/Mystery.py +++ b/Mystery.py @@ -230,7 +230,7 @@ def get_choice(option, root, value=None) -> typing.Any: return interpret_on_off(root[option]) if not root[option]: return value - if any(list(map(int, root[option].values()))): + if any(root[option].values()): return interpret_on_off( random.choices(list(root[option].keys()), weights=list(map(int, root[option].values())))[0]) raise RuntimeError(f"All options specified in {option} are weighted as zero.")