From cb7d4d43e15a9401c27e1273c7d2697c77d9a939 Mon Sep 17 00:00:00 2001 From: Fabian Dill Date: Mon, 11 May 2020 02:17:18 +0200 Subject: [PATCH] implement progression balancing as an option in CLI, gui and MultiMystery --- EntranceRandomizer.py | 2 ++ Gui.py | 6 +++++- Main.py | 2 +- Mystery.py | 10 ++++++++-- meta.yaml | 3 +++ 5 files changed, 19 insertions(+), 4 deletions(-) diff --git a/EntranceRandomizer.py b/EntranceRandomizer.py index fba67eb5..4a93bb85 100755 --- a/EntranceRandomizer.py +++ b/EntranceRandomizer.py @@ -274,6 +274,8 @@ def parse_arguments(argv, no_defaults=False): Output .json patch to stdout instead of a patched rom. Used for VT site integration, do not use otherwise. ''') + parser.add_argument('--skip_progression_balancing', action='store_true', default=defval(False), + help="Skip Multiworld Progression balancing.") parser.add_argument('--skip_playthrough', action='store_true', default=defval(False)) parser.add_argument('--enemizercli', default=defval('EnemizerCLI/EnemizerCLI.Core')) parser.add_argument('--shufflebosses', default=defval('none'), choices=['none', 'basic', 'normal', 'chaos']) diff --git a/Gui.py b/Gui.py index 75c969d1..d2eb545b 100755 --- a/Gui.py +++ b/Gui.py @@ -85,7 +85,9 @@ def guiMain(args=None): hintsCheckbutton = Checkbutton(checkBoxFrame, text="Include Helpful Hints", variable=hintsVar) customVar = IntVar() customCheckbutton = Checkbutton(checkBoxFrame, text="Use custom item pool", variable=customVar) - + balancingVar = IntVar() + balancingVar.set(1) #set default + balancingCheckbutton = Checkbutton(checkBoxFrame, text="Multiworld Progression Balancing", variable=balancingVar) createSpoilerCheckbutton.pack(expand=True, anchor=W) suppressRomCheckbutton.pack(expand=True, anchor=W) openpyramidCheckbutton.pack(expand=True, anchor=W) @@ -99,6 +101,7 @@ def guiMain(args=None): shuffleGanonCheckbutton.pack(expand=True, anchor=W) hintsCheckbutton.pack(expand=True, anchor=W) customCheckbutton.pack(expand=True, anchor=W) + balancingCheckbutton.pack(expand=True, anchor=W) romOptionsFrame = LabelFrame(rightHalfFrame, text="Rom options") romOptionsFrame.columnconfigure(0, weight=1) @@ -434,6 +437,7 @@ def guiMain(args=None): guiargs.difficulty = difficultyVar.get() guiargs.item_functionality = itemfunctionVar.get() guiargs.timer = timerVar.get() + guiargs.skip_progression_balancing = not balancingVar.get() if guiargs.timer == "none": guiargs.timer = False guiargs.dungeon_counters = dungeonCounterVar.get() diff --git a/Main.py b/Main.py index 5793c678..e34524a1 100644 --- a/Main.py +++ b/Main.py @@ -145,7 +145,7 @@ def main(args, seed=None): elif args.algorithm == 'balanced': distribute_items_restrictive(world, True) - if world.players > 1: + if world.players > 1 and not args.skip_progression_balancing: logger.info('Balancing multiworld progression.') balance_multiworld_progression(world) diff --git a/Mystery.py b/Mystery.py index 0669956d..22eac6c6 100644 --- a/Mystery.py +++ b/Mystery.py @@ -62,14 +62,18 @@ def main(): 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']}") + progression_balancing = True 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 - print(f"Meta: {args.meta} >> {weights_cache[args.meta]['meta_description']}") + meta_weights = weights_cache[args.meta] + print(f"Meta: {args.meta} >> {meta_weights['meta_description']}") if args.samesettings: raise Exception("Cannot mix --samesettings with --meta") + if "progression_balancing" in meta_weights: + progression_balancing = get_choice("progression_balancing", meta_weights) for player in range(1, args.multi + 1): path = getattr(args, f'p{player}') @@ -82,6 +86,7 @@ def main(): except Exception as e: raise ValueError(f"File {path} is destroyed. Please fix your yaml.") from e erargs = parse_arguments(['--multi', str(args.multi)]) + erargs.skip_progression_balancing = not progression_balancing erargs.seed = seed erargs.name = {x: "" for x in range(1, args.multi + 1)} # only so it can be overwrittin in mystery erargs.create_spoiler = args.create_spoiler @@ -94,6 +99,7 @@ def main(): if args.loglevel: erargs.loglevel = args.loglevel loglevel = {'error': logging.ERROR, 'info': logging.INFO, 'warning': logging.WARNING, 'debug': logging.DEBUG}[erargs.loglevel] + import sys class LoggerWriter(object): def __init__(self, writer): @@ -120,7 +126,7 @@ def main(): logging.basicConfig(format='%(message)s', level=loglevel, filename=os.path.join(args.log_output_path, f"{seed}.log")) else: logging.basicConfig(format='%(message)s', level=loglevel) - + logging.info(progression_balancing) if args.rom: erargs.rom = args.rom diff --git a/meta.yaml b/meta.yaml index 9eeef267..f8051cf0 100644 --- a/meta.yaml +++ b/meta.yaml @@ -11,6 +11,9 @@ # inverted #this means, if world_state is meta-rolled and the result happens to be inverted, then defer to the player's yaml instead. meta_description: Meta-Mystery file with the intention of having similar-length completion times for a hopefully better experience +progression_balancing: # only available in meta.yaml + on: 1 + off: 0 # if you turn this off, then prepare for a lot of logical BK goals: ganon: 10 fast_ganon: 25