From 6c8a8e18e00813b38719e1af7bb806e021b89a80 Mon Sep 17 00:00:00 2001 From: Kara Alexandra Date: Fri, 16 Jan 2026 15:47:53 -0600 Subject: [PATCH] Add --tries arg --- CLI.py | 2 ++ DungeonRandomizer.py | 50 ++++++++++++++++++++------------- Rom.py | 4 +-- data/base2current.bps | Bin 156284 -> 156289 bytes resources/app/cli/lang/en.json | 5 ++++ 5 files changed, 40 insertions(+), 21 deletions(-) diff --git a/CLI.py b/CLI.py index 09b80675..0fc8e6a9 100644 --- a/CLI.py +++ b/CLI.py @@ -88,6 +88,7 @@ def parse_cli(argv, no_defaults=False): parser.add_argument('--seed', default=defval(int(settings["seed"]) if settings["seed"] != "" and settings["seed"] is not None else None), help="\n".join(fish.translate("cli", "help", "seed")), type=int) parser.add_argument('--count', default=defval(int(settings["count"]) if settings["count"] != "" and settings["count"] is not None else 1), help="\n".join(fish.translate("cli", "help", "count")), type=int) + parser.add_argument('--tries', default=defval(int(settings["tries"]) if settings["tries"] != "" and settings["tries"] is not None else 1), help="\n".join(fish.translate("cli", "help", "tries")), type=int) parser.add_argument('--customitemarray', default={}, help=argparse.SUPPRESS) # included for backwards compatibility @@ -294,6 +295,7 @@ def parse_settings(): "seed": "", "count": 1, + "tries": 1, "startinventory": "", 'beemizer': '0', "remote_items": False, diff --git a/DungeonRandomizer.py b/DungeonRandomizer.py index 94b83faf..06fec596 100755 --- a/DungeonRandomizer.py +++ b/DungeonRandomizer.py @@ -61,29 +61,41 @@ def start(): if args.gui: from Gui import guiMain guiMain(args) - elif args.count is not None and args.count > 1: + else: + count = args.count or 1 + tries = args.tries or 1 random.seed(None) seed = args.seed or random.randint(0, 999999999) failures = [] + attempts = 0 logger = logging.getLogger('') - for _ in range(args.count): - try: - main(seed=seed, args=args, fish=fish) - logger.info('%s %s', fish.translate("cli","cli","finished.run"), _+1) - except (FillError, EnemizerError, Exception, RuntimeError) as err: - failures.append((err, seed)) - logger.warning('%s: %s', fish.translate("cli","cli","generation.failed"), err) - seed = random.randint(0, 999999999) - for fail in failures: - logger.info('%s\tseed failed with: %s', fail[1], fail[0]) - fail_rate = 100 * len(failures) / args.count - success_rate = 100 * (args.count - len(failures)) / args.count - fail_rate = str(fail_rate).split('.') - success_rate = str(success_rate).split('.') - logger.info('Generation fail rate: ' + str(fail_rate[0] ).rjust(3, " ") + '.' + str(fail_rate[1] ).ljust(6, '0') + '%') - logger.info('Generation success rate: ' + str(success_rate[0]).rjust(3, " ") + '.' + str(success_rate[1]).ljust(6, '0') + '%') - else: - main(seed=args.seed, args=args, fish=fish) + for seednum in range(count): + for trynum in range(tries): + try: + attempts += 1 + main(seed=seed, args=args, fish=fish) + logger.info('%s %s', fish.translate("cli","cli","finished.run"), seednum + 1) + logger.info('') + seed = random.randint(0, 999999999) + break + except (FillError, EnemizerError, Exception, RuntimeError) as err: + failures.append((err, seed)) + logger.warning('%s: %s', fish.translate("cli","cli","generation.failed"), err) + logger.info('') + seed = random.randint(0, 999999999) + + if count > 1 or tries > 1: + for fail in failures: + logger.info('seed %9s failed with: %s', fail[1], fail[0]) + if len(failures) > 0: + logger.info('') + fail_rate = 100 * len(failures) / attempts + success_rate = 100 * (attempts - len(failures)) / attempts + logger.info('Generation failure rate: %6.2f%%', fail_rate) + logger.info('Generation success rate: %6.2f%%', success_rate) + + if len(failures) == attempts: + sys.exit(1) if __name__ == '__main__': diff --git a/Rom.py b/Rom.py index d79f7939..d62db40d 100644 --- a/Rom.py +++ b/Rom.py @@ -44,7 +44,7 @@ from source.enemizer.Enemizer import write_enemy_shuffle_settings JAP10HASH = '03a63945398191337e896e5771f77173' -RANDOMIZERBASEHASH = 'deecff935f83b9050e7b9ef86231d607' +RANDOMIZERBASEHASH = '1fb7cd3e386f1c48d4abc7cf12990197' class JsonRom(object): @@ -3162,7 +3162,7 @@ ConnectorEntrances = {'Elder House (East)': 'Elder House', 'Hookshot Cave': 'The rock on dark DM', 'Two Brothers House (West)': 'The door near the race game', 'Old Man Cave (East)': 'The SW-most cave on west DM', - 'Old Man House (Bottom)': 'A cave with a door on west DM', + 'Old Man House (Bottom)': 'A cave with a doorframe on west DM', 'Old Man House (Top)': 'The eastmost cave on west DM', 'Death Mountain Return Cave (East)': 'The westmost cave on west DM', 'Spectacle Rock Cave Peak': 'The highest cave on west DM', diff --git a/data/base2current.bps b/data/base2current.bps index 7df194c7c969747f607156fb9d194c63db0b3fa6..1d15d310fbcfef95dc59619ae3e154f92bc4edf5 100644 GIT binary patch delta 503 zcmWlSPe@cj9LHzgZ|3c8X^2QhS{j5H2ze+kSqKS1e{CsSy|_el5{d}SQ!{TJ^JVLE z8S=5c4#C5emTIv!gA$@$kyV6wR+GabMFbK_KtyIr&WIFH5h{;y$QD<<8N^aK!iY8Ub}N2ITC+u;_y|G zjhWmuP zAl+AajtI8N2sW;lG81fyS-M`_PTnJ3NP{M+xE-W3lssU0UE`$Z*i$wWNqJk9TVjG1QSWrd!+k?ebda5-@Vm^w&Tl)Hda-ehYiNK_oGkQ+&d*ycL;Cf}RMyJlYJa6vf=-=HnS(!q`j9Ndpc;^^K{trj#%M%9S4Z-C?Gr-2B8u(UdLAHDat4qXzH zAsz8y+5_RVWS2Wg0tp}uzJMC7!vZYAiWkkPPIIFB^q4zzrC)qNLJb}Wg>~^8tm)iO z_zmmeCAG8=RQ^!_15N+$b~Uq&%snXe%7y? zk8$@x%80@sJMR`#Mq6ft*=k|@CcDiHwMCTDcgaDdUPM|v;1$LxDYM5aY!)hPmOX&1 z(`woCY-I-I^N!tV`Wf{im`bDSl=c_)T`^PsaF*v{N0tx+7;e#j8_eL&FN<*}F05$T zNeXp2XK&&W6&o$|ZRI<-vt8I_G~A2%I-yOv(#?B#jrQs}z};TyCB!{V6MR6ElscN7 fG%8qpg&QUkXWquEXHOVyq2SQ*^*>#w?qvP}^Rdn- diff --git a/resources/app/cli/lang/en.json b/resources/app/cli/lang/en.json index e5093801..c8b427b6 100644 --- a/resources/app/cli/lang/en.json +++ b/resources/app/cli/lang/en.json @@ -352,6 +352,11 @@ "--seed given will produce the same %(default)s (different) rom(s) each", "time)." ], + "tries": [ + "Use to attempt multiple times to succeed at generating a seed.", + "If --seed is provided, it will be used for the first seed, then", + "used to derive the next seed, until one succeeds." + ], "fastmenu": [ "Select the rate at which the menu opens and closes. (default: %(default)s)" ],