implement progression balancing as an option in CLI, gui and MultiMystery
This commit is contained in:
		
							parent
							
								
									e1add44d83
								
							
						
					
					
						commit
						cb7d4d43e1
					
				| 
						 | 
				
			
			@ -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'])
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										6
									
								
								Gui.py
								
								
								
								
							
							
						
						
									
										6
									
								
								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()
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										2
									
								
								Main.py
								
								
								
								
							
							
						
						
									
										2
									
								
								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)
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										10
									
								
								Mystery.py
								
								
								
								
							
							
						
						
									
										10
									
								
								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
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue