From f52d65a1418539935794d97b6a3eeeb8b85505c9 Mon Sep 17 00:00:00 2001 From: Mysteryem Date: Fri, 8 Nov 2024 11:11:41 +0000 Subject: [PATCH] Pokemon RB: make stage_post_fill deterministic (#4008) stage_post_fill iterates sets of locations, so the iteration order is non-deterministic, resulting in different items being converted from Progression to Useful when generating with the same seed. This patch makes stage_post_fill deterministic by sorting the duplicate pokemon locations in each sphere before choosing which of the duplicates should remain as progression. --- worlds/pokemon_rb/__init__.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/worlds/pokemon_rb/__init__.py b/worlds/pokemon_rb/__init__.py index 2065507e0d59..6db0c9e0f8bf 100644 --- a/worlds/pokemon_rb/__init__.py +++ b/worlds/pokemon_rb/__init__.py @@ -526,6 +526,7 @@ def stage_post_fill(cls, multiworld): # This cuts down on time spent calculating the spoiler playthrough. found_mons = set() for sphere in multiworld.get_spheres(): + mon_locations_in_sphere = {} for location in sphere: if (location.game == "Pokemon Red and Blue" and (location.item.name in poke_data.pokemon_data.keys() or "Static " in location.item.name) @@ -534,7 +535,15 @@ def stage_post_fill(cls, multiworld): if key in found_mons: location.item.classification = ItemClassification.useful else: - found_mons.add(key) + mon_locations_in_sphere.setdefault(key, []).append(location) + for key, mon_locations in mon_locations_in_sphere.items(): + found_mons.add(key) + if len(mon_locations) > 1: + # Sort for deterministic results. + mon_locations.sort() + # Convert all but the first to useful classification. + for location in mon_locations[1:]: + location.item.classification = ItemClassification.useful def create_regions(self): if (self.options.old_man == "vanilla" or