Skip to content

Commit

Permalink
Pokemon RB: make stage_post_fill deterministic (#4008)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Mysteryem authored Nov 8, 2024
1 parent 2bdc1e0 commit f52d65a
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion worlds/pokemon_rb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down

0 comments on commit f52d65a

Please sign in to comment.