implement progression balancing as an option in CLI, gui and MultiMystery

This commit is contained in:
Fabian Dill 2020-05-11 02:17:18 +02:00
parent e1add44d83
commit cb7d4d43e1
5 changed files with 19 additions and 4 deletions

View File

@ -274,6 +274,8 @@ def parse_arguments(argv, no_defaults=False):
Output .json patch to stdout instead of a patched rom. Used Output .json patch to stdout instead of a patched rom. Used
for VT site integration, do not use otherwise. 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('--skip_playthrough', action='store_true', default=defval(False))
parser.add_argument('--enemizercli', default=defval('EnemizerCLI/EnemizerCLI.Core')) parser.add_argument('--enemizercli', default=defval('EnemizerCLI/EnemizerCLI.Core'))
parser.add_argument('--shufflebosses', default=defval('none'), choices=['none', 'basic', 'normal', 'chaos']) parser.add_argument('--shufflebosses', default=defval('none'), choices=['none', 'basic', 'normal', 'chaos'])

6
Gui.py
View File

@ -85,7 +85,9 @@ def guiMain(args=None):
hintsCheckbutton = Checkbutton(checkBoxFrame, text="Include Helpful Hints", variable=hintsVar) hintsCheckbutton = Checkbutton(checkBoxFrame, text="Include Helpful Hints", variable=hintsVar)
customVar = IntVar() customVar = IntVar()
customCheckbutton = Checkbutton(checkBoxFrame, text="Use custom item pool", variable=customVar) 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) createSpoilerCheckbutton.pack(expand=True, anchor=W)
suppressRomCheckbutton.pack(expand=True, anchor=W) suppressRomCheckbutton.pack(expand=True, anchor=W)
openpyramidCheckbutton.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) shuffleGanonCheckbutton.pack(expand=True, anchor=W)
hintsCheckbutton.pack(expand=True, anchor=W) hintsCheckbutton.pack(expand=True, anchor=W)
customCheckbutton.pack(expand=True, anchor=W) customCheckbutton.pack(expand=True, anchor=W)
balancingCheckbutton.pack(expand=True, anchor=W)
romOptionsFrame = LabelFrame(rightHalfFrame, text="Rom options") romOptionsFrame = LabelFrame(rightHalfFrame, text="Rom options")
romOptionsFrame.columnconfigure(0, weight=1) romOptionsFrame.columnconfigure(0, weight=1)
@ -434,6 +437,7 @@ def guiMain(args=None):
guiargs.difficulty = difficultyVar.get() guiargs.difficulty = difficultyVar.get()
guiargs.item_functionality = itemfunctionVar.get() guiargs.item_functionality = itemfunctionVar.get()
guiargs.timer = timerVar.get() guiargs.timer = timerVar.get()
guiargs.skip_progression_balancing = not balancingVar.get()
if guiargs.timer == "none": if guiargs.timer == "none":
guiargs.timer = False guiargs.timer = False
guiargs.dungeon_counters = dungeonCounterVar.get() guiargs.dungeon_counters = dungeonCounterVar.get()

View File

@ -145,7 +145,7 @@ def main(args, seed=None):
elif args.algorithm == 'balanced': elif args.algorithm == 'balanced':
distribute_items_restrictive(world, True) distribute_items_restrictive(world, True)
if world.players > 1: if world.players > 1 and not args.skip_progression_balancing:
logger.info('Balancing multiworld progression.') logger.info('Balancing multiworld progression.')
balance_multiworld_progression(world) balance_multiworld_progression(world)

View File

@ -62,14 +62,18 @@ def main():
except Exception as e: except Exception as e:
raise ValueError(f"File {args.weights} is destroyed. Please fix your yaml.") from 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} >> {weights_cache[args.weights]['description']}")
progression_balancing = True
if args.meta: if args.meta:
try: try:
weights_cache[args.meta] = get_weights(args.meta) weights_cache[args.meta] = get_weights(args.meta)
except Exception as e: except Exception as e:
raise ValueError(f"File {args.meta} is destroyed. Please fix your yaml.") from 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: if args.samesettings:
raise Exception("Cannot mix --samesettings with --meta") 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): for player in range(1, args.multi + 1):
path = getattr(args, f'p{player}') path = getattr(args, f'p{player}')
@ -82,6 +86,7 @@ def main():
except Exception as e: except Exception as e:
raise ValueError(f"File {path} is destroyed. Please fix your yaml.") from e raise ValueError(f"File {path} is destroyed. Please fix your yaml.") from e
erargs = parse_arguments(['--multi', str(args.multi)]) erargs = parse_arguments(['--multi', str(args.multi)])
erargs.skip_progression_balancing = not progression_balancing
erargs.seed = seed erargs.seed = seed
erargs.name = {x: "" for x in range(1, args.multi + 1)} # only so it can be overwrittin in mystery 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 erargs.create_spoiler = args.create_spoiler
@ -94,6 +99,7 @@ def main():
if args.loglevel: if args.loglevel:
erargs.loglevel = args.loglevel erargs.loglevel = args.loglevel
loglevel = {'error': logging.ERROR, 'info': logging.INFO, 'warning': logging.WARNING, 'debug': logging.DEBUG}[erargs.loglevel] loglevel = {'error': logging.ERROR, 'info': logging.INFO, 'warning': logging.WARNING, 'debug': logging.DEBUG}[erargs.loglevel]
import sys import sys
class LoggerWriter(object): class LoggerWriter(object):
def __init__(self, writer): 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")) logging.basicConfig(format='%(message)s', level=loglevel, filename=os.path.join(args.log_output_path, f"{seed}.log"))
else: else:
logging.basicConfig(format='%(message)s', level=loglevel) logging.basicConfig(format='%(message)s', level=loglevel)
logging.info(progression_balancing)
if args.rom: if args.rom:
erargs.rom = args.rom erargs.rom = args.rom

View File

@ -11,6 +11,9 @@
# inverted # inverted
#this means, if world_state is meta-rolled and the result happens to be inverted, then defer to the player's yaml instead. #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 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: goals:
ganon: 10 ganon: 10
fast_ganon: 25 fast_ganon: 25