From f8a1d68ee14ff73a38c86d2fe6eb5ccd1ed801ad Mon Sep 17 00:00:00 2001 From: Nicholas Saylor Date: Thu, 25 Dec 2025 00:08:33 -0500 Subject: [PATCH 1/8] First pass of core using `use_cache` --- Fill.py | 2 +- entrance_rando.py | 2 +- test/bases.py | 2 +- test/benchmark/locations.py | 2 +- test/general/test_implemented.py | 2 +- test/general/test_reachability.py | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Fill.py b/Fill.py index 48ed7253d9d1..e7c46ce3bdd8 100644 --- a/Fill.py +++ b/Fill.py @@ -1146,7 +1146,7 @@ def failed(warning: str, force: bool | str) -> None: candidates = [candidate for candidate in locations if candidate.item is None and bool(candidate.address) == is_real] multiworld.random.shuffle(candidates) - allstate = multiworld.get_all_state(False) + allstate = multiworld.get_all_state() mincount = placement.count["min"] allowed_margin = len(item_candidates) - mincount fill_restrictive(multiworld, allstate, candidates, item_candidates, lock=True, diff --git a/entrance_rando.py b/entrance_rando.py index a417767036ee..13a16afa3503 100644 --- a/entrance_rando.py +++ b/entrance_rando.py @@ -186,7 +186,7 @@ def __init__(self, world: World, entrance_lookup: EntranceLookup, coupled: bool) self.pairings = [] self.world = world self.coupled = coupled - self.collection_state = world.multiworld.get_all_state(False, True) + self.collection_state = world.multiworld.get_all_state(allow_partial_entrances=True) self.entrance_lookup = entrance_lookup @property diff --git a/test/bases.py b/test/bases.py index dd93ca6452dd..1926e16a1a46 100644 --- a/test/bases.py +++ b/test/bases.py @@ -202,7 +202,7 @@ def test_all_state_can_reach_everything(self): if not (self.run_default_tests and self.constructed): return with self.subTest("Game", game=self.game, seed=self.multiworld.seed): - state = self.multiworld.get_all_state(False) + state = self.multiworld.get_all_state() for location in self.multiworld.get_locations(): with self.subTest("Location should be reached", location=location.name): reachable = location.can_reach(state) diff --git a/test/benchmark/locations.py b/test/benchmark/locations.py index 245dcb604e07..f7c1775225ff 100644 --- a/test/benchmark/locations.py +++ b/test/benchmark/locations.py @@ -88,7 +88,7 @@ def main(self): if not locations: continue - all_state = multiworld.get_all_state(False) + all_state = multiworld.get_all_state() for location in locations: time_taken = self.location_test(location, multiworld.state, "empty_state") summary_data["empty_state"][location.name] = time_taken diff --git a/test/general/test_implemented.py b/test/general/test_implemented.py index de432e369099..254c2544b06b 100644 --- a/test/general/test_implemented.py +++ b/test/general/test_implemented.py @@ -61,7 +61,7 @@ def test_prefill_items(self): with self.subTest(gamename): multiworld = setup_solo_multiworld(world_type, ("generate_early", "create_regions", "create_items", "set_rules", "connect_entrances", "generate_basic")) - allstate = multiworld.get_all_state(False) + allstate = multiworld.get_all_state() locations = multiworld.get_locations() reachable = multiworld.get_reachable_locations(allstate) unreachable = [location for location in locations if location not in reachable] diff --git a/test/general/test_reachability.py b/test/general/test_reachability.py index b45a2bdfc0ef..ffb30117c871 100644 --- a/test/general/test_reachability.py +++ b/test/general/test_reachability.py @@ -49,7 +49,7 @@ def test_default_all_state_can_reach_everything(self): unreachable_regions = self.default_settings_unreachable_regions.get(game_name, set()) with self.subTest("Game", game=game_name): multiworld = setup_solo_multiworld(world_type) - state = multiworld.get_all_state(False) + state = multiworld.get_all_state() for location in multiworld.get_locations(): with self.subTest("Location should be reached", location=location.name): self.assertTrue(location.can_reach(state), f"{location.name} unreachable") From d50849dd5870205152298cf0b879fba2d5910c50 Mon Sep 17 00:00:00 2001 From: Nicholas Saylor Date: Thu, 25 Dec 2025 00:47:03 -0500 Subject: [PATCH 2/8] A few more tests --- test/general/test_entrances.py | 4 ++-- test/general/test_state.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test/general/test_entrances.py b/test/general/test_entrances.py index 79025534ac68..b80279f20e07 100644 --- a/test/general/test_entrances.py +++ b/test/general/test_entrances.py @@ -48,14 +48,14 @@ def test_all_state_before_connect_entrances(self): original_get_all_state = multiworld.get_all_state - def patched_get_all_state(use_cache: bool | None = None, allow_partial_entrances: bool = False, + def patched_get_all_state(allow_partial_entrances: bool = False, **kwargs): self.assertTrue(allow_partial_entrances, ( "Before the connect_entrances step finishes, other worlds might still have partial entrances. " "As such, any call to get_all_state must use allow_partial_entrances = True." )) - return original_get_all_state(use_cache, allow_partial_entrances, **kwargs) + return original_get_all_state(allow_partial_entrances, **kwargs) multiworld.get_all_state = patched_get_all_state diff --git a/test/general/test_state.py b/test/general/test_state.py index 06c4046a6942..e1b4a1c52d90 100644 --- a/test/general/test_state.py +++ b/test/general/test_state.py @@ -26,4 +26,4 @@ def test_all_state_is_available(self): for step in self.test_steps: with self.subTest("Step", step=step): call_all(multiworld, step) - self.assertTrue(multiworld.get_all_state(False, allow_partial_entrances=True)) + self.assertTrue(multiworld.get_all_state(allow_partial_entrances=True)) From 660620ab435697e5b079c92118fb99e9f65c611c Mon Sep 17 00:00:00 2001 From: Nicholas Saylor Date: Thu, 25 Dec 2025 00:48:10 -0500 Subject: [PATCH 3/8] Odd addition in benchmark_locations.py --- worlds/stardew_valley/test/script/benchmark_locations.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/worlds/stardew_valley/test/script/benchmark_locations.py b/worlds/stardew_valley/test/script/benchmark_locations.py index 3dcfc4dbebfb..0eb7ac0beed2 100644 --- a/worlds/stardew_valley/test/script/benchmark_locations.py +++ b/worlds/stardew_valley/test/script/benchmark_locations.py @@ -70,7 +70,7 @@ def main(self): else: locations = sorted(multiworld.get_unfilled_locations()) - all_state = multiworld.get_all_state(False) + all_state = multiworld.get_all_state() for location in locations: if state != "all_state": time_taken = self.location_test(location, multiworld.state, "empty_state") From 29b663f0b49be186fe56b0e6603b0dde9a97b4be Mon Sep 17 00:00:00 2001 From: Nicholas Saylor Date: Thu, 25 Dec 2025 01:00:45 -0500 Subject: [PATCH 4/8] ALTTP fix? --- worlds/alttp/Rules.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/worlds/alttp/Rules.py b/worlds/alttp/Rules.py index 18e2965d8c5a..f11cdf185088 100644 --- a/worlds/alttp/Rules.py +++ b/worlds/alttp/Rules.py @@ -1132,7 +1132,7 @@ def set_trock_key_rules(multiworld, player): for entrance in ['Turtle Rock Dark Room Staircase', 'Turtle Rock (Chain Chomp Room) (North)', 'Turtle Rock (Chain Chomp Room) (South)', 'Turtle Rock Entrance to Pokey Room', 'Turtle Rock (Pokey Room) (South)', 'Turtle Rock (Pokey Room) (North)', 'Turtle Rock Big Key Door']: set_rule(multiworld.get_entrance(entrance, player), lambda state: False) - all_state = multiworld.get_all_state(use_cache=False, allow_partial_entrances=True) + all_state = multiworld.get_all_state(allow_partial_entrances=True) all_state.reachable_regions[player] = set() # wipe reachable regions so that the locked doors actually work all_state.stale[player] = True From 7f81e97574dffe606ff591b58df16672878630ca Mon Sep 17 00:00:00 2001 From: Nicholas Saylor Date: Thu, 25 Dec 2025 01:27:06 -0500 Subject: [PATCH 5/8] Final changes? --- BaseClasses.py | 2 +- Utils.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/BaseClasses.py b/BaseClasses.py index 4d88fde4f3db..53821f096bb7 100644 --- a/BaseClasses.py +++ b/BaseClasses.py @@ -427,7 +427,7 @@ def get_entrance(self, entrance_name: str, player: int) -> Entrance: def get_location(self, location_name: str, player: int) -> Location: return self.regions.location_cache[player][location_name] - def get_all_state(self, use_cache: bool | None = None, allow_partial_entrances: bool = False, + def get_all_state(self, allow_partial_entrances: bool = False, collect_pre_fill_items: bool = True, perform_sweep: bool = True) -> CollectionState: """ Creates a new CollectionState, and collects all precollected items, all items in the multiworld itempool, those diff --git a/Utils.py b/Utils.py index 2fe5d0f5629c..b1d9d30918f9 100644 --- a/Utils.py +++ b/Utils.py @@ -1072,7 +1072,7 @@ def visualize_regions(root_region: Region, file_name: str, *, Example usage in World code: from Utils import visualize_regions - state = self.multiworld.get_all_state(False) + state = self.multiworld.get_all_state() state.update_reachable_regions(self.player) visualize_regions(self.get_region("Menu"), "my_world.puml", show_entrance_names=True, regions_to_highlight=state.reachable_regions[self.player]) From bef098c65dcc468ed21285865a7be21f102d5184 Mon Sep 17 00:00:00 2001 From: Nicholas Saylor Date: Thu, 25 Dec 2025 01:30:55 -0500 Subject: [PATCH 6/8] Base classes still needed that --- BaseClasses.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BaseClasses.py b/BaseClasses.py index 53821f096bb7..4d88fde4f3db 100644 --- a/BaseClasses.py +++ b/BaseClasses.py @@ -427,7 +427,7 @@ def get_entrance(self, entrance_name: str, player: int) -> Entrance: def get_location(self, location_name: str, player: int) -> Location: return self.regions.location_cache[player][location_name] - def get_all_state(self, allow_partial_entrances: bool = False, + def get_all_state(self, use_cache: bool | None = None, allow_partial_entrances: bool = False, collect_pre_fill_items: bool = True, perform_sweep: bool = True) -> CollectionState: """ Creates a new CollectionState, and collects all precollected items, all items in the multiworld itempool, those From a6fcd9823c847ea0b3a93db688074c4112eb8d56 Mon Sep 17 00:00:00 2001 From: Nicholas Saylor Date: Thu, 25 Dec 2025 21:09:57 -0500 Subject: [PATCH 7/8] Revert inadvertent stardew change --- worlds/stardew_valley/test/script/benchmark_locations.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/worlds/stardew_valley/test/script/benchmark_locations.py b/worlds/stardew_valley/test/script/benchmark_locations.py index 0eb7ac0beed2..3dcfc4dbebfb 100644 --- a/worlds/stardew_valley/test/script/benchmark_locations.py +++ b/worlds/stardew_valley/test/script/benchmark_locations.py @@ -70,7 +70,7 @@ def main(self): else: locations = sorted(multiworld.get_unfilled_locations()) - all_state = multiworld.get_all_state() + all_state = multiworld.get_all_state(False) for location in locations: if state != "all_state": time_taken = self.location_test(location, multiworld.state, "empty_state") From 30f27ed154147d1bb75cf5916f95240d782d7ae2 Mon Sep 17 00:00:00 2001 From: Nicholas Saylor Date: Sun, 4 Jan 2026 21:23:08 -0500 Subject: [PATCH 8/8] Avoid potential type error in test_entrances.py --- test/general/test_entrances.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/general/test_entrances.py b/test/general/test_entrances.py index b80279f20e07..5f09544d70ca 100644 --- a/test/general/test_entrances.py +++ b/test/general/test_entrances.py @@ -48,8 +48,8 @@ def test_all_state_before_connect_entrances(self): original_get_all_state = multiworld.get_all_state - def patched_get_all_state(allow_partial_entrances: bool = False, - **kwargs): + def patched_get_all_state(use_cache: bool | None = None, allow_partial_entrances: bool = False, + **kwargs): #TODO: Remove use_cache once get_all_state() fully deprecates it self.assertTrue(allow_partial_entrances, ( "Before the connect_entrances step finishes, other worlds might still have partial entrances. " "As such, any call to get_all_state must use allow_partial_entrances = True."