From 430f0c7390ad820167ccf483c4efa09f43604625 Mon Sep 17 00:00:00 2001 From: Ziktofel Date: Tue, 9 Apr 2024 20:39:22 +0200 Subject: [PATCH] SC2: Fix possible non-determinism in goal selection --- worlds/sc2/PoolFilter.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/worlds/sc2/PoolFilter.py b/worlds/sc2/PoolFilter.py index 068c62314923..d1b58f9b2096 100644 --- a/worlds/sc2/PoolFilter.py +++ b/worlds/sc2/PoolFilter.py @@ -58,7 +58,8 @@ def filter_missions(world: World) -> Dict[MissionPools, List[SC2Mission]]: # Vanilla uses the entire mission pool goal_priorities: Dict[SC2Campaign, SC2CampaignGoalPriority] = {campaign: get_campaign_goal_priority(campaign) for campaign in enabled_campaigns} goal_level = max(goal_priorities.values()) - candidate_campaigns = [campaign for campaign, goal_priority in goal_priorities.items() if goal_priority == goal_level] + candidate_campaigns: List[SC2Campaign] = [campaign for campaign, goal_priority in goal_priorities.items() if goal_priority == goal_level] + candidate_campaigns.sort(key=lambda it: it.id) goal_campaign = world.random.choice(candidate_campaigns) if campaign_final_mission_locations[goal_campaign] is not None: mission_pools[MissionPools.FINAL] = [campaign_final_mission_locations[goal_campaign].mission] @@ -70,7 +71,8 @@ def filter_missions(world: World) -> Dict[MissionPools, List[SC2Mission]]: # Finding the goal map goal_priorities = {campaign: get_campaign_goal_priority(campaign, excluded_missions) for campaign in enabled_campaigns} goal_level = max(goal_priorities.values()) - candidate_campaigns = [campaign for campaign, goal_priority in goal_priorities.items() if goal_priority == goal_level] + candidate_campaigns: List[SC2Campaign] = [campaign for campaign, goal_priority in goal_priorities.items() if goal_priority == goal_level] + candidate_campaigns.sort(key=lambda it: it.id) goal_campaign = world.random.choice(candidate_campaigns) primary_goal = campaign_final_mission_locations[goal_campaign] if primary_goal is None or primary_goal.mission in excluded_missions: