Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix goal hint nondeterminism introduced by #2021 #2030

Merged
merged 1 commit into from
Jul 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Hints.py
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ def get_goal_hint(spoiler: Spoiler, world: World, checked: set[str]) -> HintRetu

# Collect set of unhinted locations for the category. Reduces the bias
# from locations in multiple goals for the category.
location_reverse_map = defaultdict(set)
location_reverse_map = defaultdict(list)
for goal in goals:
if zero_weights or goal.weight > 0:
goal_locations = list(filter(lambda location:
Expand All @@ -641,7 +641,7 @@ def get_goal_hint(spoiler: Spoiler, world: World, checked: set[str]) -> HintRetu
goal.required_locations))
for location in goal_locations:
for world_id in location[3]:
location_reverse_map[location[0]].add((goal, world_id))
location_reverse_map[location[0]].append((goal, world_id))

if not location_reverse_map:
del world.goal_categories[goal_category.name]
Expand All @@ -651,8 +651,8 @@ def get_goal_hint(spoiler: Spoiler, world: World, checked: set[str]) -> HintRetu
else:
goals = goal_category.goals

location, goal_set = random.choice(list(location_reverse_map.items()))
goal, world_id = random.choice(list(goal_set))
location, goal_list = random.choice(list(location_reverse_map.items()))
goal, world_id = random.choice(goal_list)
checked.add(location.name)

# Make sure this wasn't the last hintable location for other goals.
Expand Down