Skip to content

Commit

Permalink
fix determinism issues on fixed seeds
Browse files Browse the repository at this point in the history
  • Loading branch information
nbrochu committed Apr 12, 2024
1 parent 4e9791c commit 40f09ae
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
24 changes: 12 additions & 12 deletions worlds/zork_grand_inquisitor/data_funcs.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Dict, Set, Tuple, Union
from typing import Dict, List, Set, Tuple, Union

from .data.entrance_rule_data import entrance_rule_data
from .data.item_data import item_data, ZorkGrandInquisitorItemData
Expand Down Expand Up @@ -54,15 +54,15 @@ def id_to_locations() -> Dict[int, ZorkGrandInquisitorLocations]:
}


def item_groups() -> Dict[str, Set[str]]:
groups: Dict[str, Set[str]] = dict()
def item_groups() -> Dict[str, List[str]]:
groups: Dict[str, List[str]] = dict()

item: ZorkGrandInquisitorItems
data: ZorkGrandInquisitorItemData
for item, data in item_data.items():
if data.tags is not None:
for tag in data.tags:
groups.setdefault(tag.value, set()).add(item.value)
groups.setdefault(tag.value, list()).append(item.value)

return {k: v for k, v in groups.items() if len(v)}

Expand Down Expand Up @@ -92,31 +92,31 @@ def game_id_to_items() -> Dict[int, ZorkGrandInquisitorItems]:
return mapping


def location_groups() -> Dict[str, Set[str]]:
groups: Dict[str, Set[str]] = dict()
def location_groups() -> Dict[str, List[str]]:
groups: Dict[str, List[str]] = dict()

tag: ZorkGrandInquisitorTags
for tag in ZorkGrandInquisitorTags:
groups[tag.value] = set()
groups[tag.value] = list()

location: ZorkGrandInquisitorLocations
data: ZorkGrandInquisitorLocationData
for location, data in location_data.items():
if data.tags is not None:
for tag in data.tags:
groups[tag.value].add(location.value)
groups[tag.value].append(location.value)

return {k: v for k, v in groups.items() if len(v)}


def locations_by_region(include_deathsanity: bool = False) -> Dict[
ZorkGrandInquisitorRegions, Set[ZorkGrandInquisitorLocations]
ZorkGrandInquisitorRegions, List[ZorkGrandInquisitorLocations]
]:
mapping: Dict[ZorkGrandInquisitorRegions, Set[ZorkGrandInquisitorLocations]] = dict()
mapping: Dict[ZorkGrandInquisitorRegions, List[ZorkGrandInquisitorLocations]] = dict()

region: ZorkGrandInquisitorRegions
for region in ZorkGrandInquisitorRegions:
mapping[region] = set()
mapping[region] = list()

location: ZorkGrandInquisitorLocations
data: ZorkGrandInquisitorLocationData
Expand All @@ -126,7 +126,7 @@ def locations_by_region(include_deathsanity: bool = False) -> Dict[
):
continue

mapping[data.region].add(location)
mapping[data.region].append(location)

return mapping

Expand Down
9 changes: 5 additions & 4 deletions worlds/zork_grand_inquisitor/world.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, Dict, List, Set, Tuple
from typing import Any, Dict, List, Tuple

from BaseClasses import Item, ItemClassification, Location, Region, Tutorial

Expand Down Expand Up @@ -78,6 +78,7 @@ class ZorkGrandInquisitorWorld(World):

web = ZorkGrandInquisitorWebWorld()

filler_item_names: List[str] = item_groups()["Filler"]
item_name_to_item: Dict[str, ZorkGrandInquisitorItems] = item_names_to_item()

def create_regions(self) -> None:
Expand All @@ -89,13 +90,13 @@ def create_regions(self) -> None:
for region_enum_item in region_data.keys():
region_mapping[region_enum_item] = Region(region_enum_item.value, self.player, self.multiworld)

region_locations_mapping: Dict[ZorkGrandInquisitorRegions, Set[ZorkGrandInquisitorLocations]]
region_locations_mapping: Dict[ZorkGrandInquisitorRegions, List[ZorkGrandInquisitorLocations]]
region_locations_mapping = locations_by_region(include_deathsanity=deathsanity)

region_enum_item: ZorkGrandInquisitorRegions
region: Region
for region_enum_item, region in region_mapping.items():
regions_locations: Set[ZorkGrandInquisitorLocations] = region_locations_mapping[region_enum_item]
regions_locations: List[ZorkGrandInquisitorLocations] = region_locations_mapping[region_enum_item]

# Locations
location_enum_item: ZorkGrandInquisitorLocations
Expand Down Expand Up @@ -203,4 +204,4 @@ def fill_slot_data(self) -> Dict[str, Any]:
)

def get_filler_item_name(self) -> str:
return self.random.choice(list(self.item_name_groups["Filler"]))
return self.random.choice(self.filler_item_names)

0 comments on commit 40f09ae

Please sign in to comment.