From ccb35fd1b111bcb8275c737565212faf9a7ce3ab Mon Sep 17 00:00:00 2001 From: aerinon Date: Fri, 16 Dec 2022 15:56:53 -0700 Subject: [PATCH] Small key door limit per dungeon RainPrevention fix --- DoorShuffle.py | 18 +++++++++++------- RELEASENOTES.md | 2 ++ Rom.py | 2 +- data/base2current.bps | Bin 93478 -> 93478 bytes source/dungeon/DungeonStitcher.py | 1 - 5 files changed, 14 insertions(+), 9 deletions(-) diff --git a/DoorShuffle.py b/DoorShuffle.py index 573332c3..17679ab7 100644 --- a/DoorShuffle.py +++ b/DoorShuffle.py @@ -1893,6 +1893,7 @@ def shuffle_big_key_doors(door_type_pools, used_doors, start_regions_map, world, def shuffle_small_key_doors(door_type_pools, used_doors, start_regions_map, world, player): + max_computation = 11 # this is around 6 billion worse case factorial don't want to exceed this much for pool, door_type_pool in door_type_pools: ttl = 0 suggestion_map, small_map, flex_map = {}, {}, {} @@ -1919,27 +1920,28 @@ def shuffle_small_key_doors(door_type_pools, used_doors, start_regions_map, worl calculated = int(round(builder.key_doors_num*total_keys/ttl)) max_keys = max(0, builder.location_cnt - calc_used_dungeon_items(builder, world, player)) cand_len = max(0, len(builder.candidates.small) - builder.key_drop_cnt) - limit = min(max_keys, cand_len) + limit = min(max_keys, cand_len, max_computation) suggested = min(calculated, limit) - combo_size = ncr(len(builder.candidates.small), suggested + builder.key_drop_cnt) + key_door_num = min(suggested + builder.key_drop_cnt, max_computation) + combo_size = ncr(len(builder.candidates.small), key_door_num) while combo_size > 500000 and suggested > 0: suggested -= 1 - combo_size = ncr(len(builder.candidates.small), suggested + builder.key_drop_cnt) - suggestion_map[dungeon] = builder.key_doors_num = suggested + builder.key_drop_cnt + combo_size = ncr(len(builder.candidates.small), key_door_num) + suggestion_map[dungeon] = builder.key_doors_num = key_door_num remaining -= suggested + builder.key_drop_cnt builder.combo_size = combo_size flex_map[dungeon] = (limit - suggested) if suggested < limit else 0 for dungeon in pool: builder = world.dungeon_layouts[player][dungeon] if total_adjustable: - builder.total_keys = suggestion_map[dungeon] + builder.total_keys = max(suggestion_map[dungeon], builder.key_drop_cnt) valid_doors, small_number = find_valid_combination(builder, suggestion_map[dungeon], start_regions_map[dungeon], world, player) small_map[dungeon] = valid_doors actual_chest_keys = small_number - builder.key_drop_cnt if actual_chest_keys < suggestion_map[dungeon]: if total_adjustable: - builder.total_keys = actual_chest_keys + builder.total_keys = actual_chest_keys + builder.key_drop_cnt flex_map[dungeon] = 0 remaining += suggestion_map[dungeon] - actual_chest_keys suggestion_map[dungeon] = small_number @@ -1950,6 +1952,8 @@ def shuffle_small_key_doors(door_type_pools, used_doors, start_regions_map, worl builder = queue.popleft() dungeon = builder.name increased = suggestion_map[dungeon] + 1 + if increased > max_computation: + continue builder.key_doors_num = increased valid_doors, small_number = find_valid_combination(builder, increased, start_regions_map[dungeon], world, player) @@ -1959,7 +1963,7 @@ def shuffle_small_key_doors(door_type_pools, used_doors, start_regions_map, worl suggestion_map[dungeon] = increased flex_map[dungeon] -= 1 if total_adjustable: - builder.total_keys = actual_chest_keys + builder.total_keys = max(increased, builder.key_drop_cnt) if flex_map[dungeon] > 0: builder.combo_size = ncr(len(builder.candidates.small), builder.key_doors_num) queue.append(builder) diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 120335b4..865e3c41 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -113,6 +113,8 @@ These are now independent of retro mode and have three options: None, Random, an * Added new ganonhunt and completionist goals * Fixed the issue when defeating Agahnim and standing in the doorway can cause door state to linger. * Fix for Inverted Lean/Lite ER + * Fix for vanilla Doors + Standard + ER + * Added a limit per dungeon on small key doors to ensure reasonable generation * Fixed many small bugs # Known Issues diff --git a/Rom.py b/Rom.py index f5a529fd..03ab0283 100644 --- a/Rom.py +++ b/Rom.py @@ -37,7 +37,7 @@ from source.dungeon.RoomList import Room0127 JAP10HASH = '03a63945398191337e896e5771f77173' -RANDOMIZERBASEHASH = '54cfc4c5e85c80fb2958cb458d36ad14' +RANDOMIZERBASEHASH = 'f204143853a58e55a5fbc4c5bc87045e' class JsonRom(object): diff --git a/data/base2current.bps b/data/base2current.bps index e9709333a2475617d136d5e83f868116597e4c94..41a996a35b4b37b1f6e70916a66e816e618ce471 100644 GIT binary patch delta 39 xcmV+?0NDSg+6AWC1+ZQL1N$)qgJA);VF3Xm4FMvzgbo3kUI??V>FIFDtR^Bf4<-Nr delta 39 vcmZ2>i*?y8)(vrt%*PEaniCnfCo(cB@iK;OZ{cH{6~}Sa+%ciY@|P$88-)#> diff --git a/source/dungeon/DungeonStitcher.py b/source/dungeon/DungeonStitcher.py index 0a0d3ad4..205941b5 100644 --- a/source/dungeon/DungeonStitcher.py +++ b/source/dungeon/DungeonStitcher.py @@ -218,7 +218,6 @@ def modify_proposal(proposed_map, explored_state, doors_to_connect, hash_code_se else: logger.debug(f' Re-Linking {attempt.name} -> {new_door.name}') logger.debug(f' Re-Linking {old_attempt.name} -> {old_target.name}') - hash_code_set.add(hash_code) return proposed_map, hash_code