Skip to content

Commit

Permalink
OoT: create and copy less useless data state (ArchipelagoMW#2379)
Browse files Browse the repository at this point in the history
  • Loading branch information
Berserker66 authored and FlySniper committed Nov 14, 2023
1 parent 198cb3c commit e02211c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
4 changes: 4 additions & 0 deletions BaseClasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,10 @@ def player_ids(self) -> Tuple[int, ...]:
def get_game_players(self, game_name: str) -> Tuple[int, ...]:
return tuple(player for player in self.player_ids if self.game[player] == game_name)

@functools.lru_cache()
def get_game_groups(self, game_name: str) -> Tuple[int, ...]:
return tuple(group_id for group_id in self.groups if self.game[group_id] == game_name)

@functools.lru_cache()
def get_game_worlds(self, game_name: str):
return tuple(world for player, world in self.worlds.items() if
Expand Down
16 changes: 8 additions & 8 deletions worlds/oot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@

class OOTCollectionState(metaclass=AutoLogicRegister):
def init_mixin(self, parent: MultiWorld):
all_ids = parent.get_all_ids()
self.child_reachable_regions = {player: set() for player in all_ids}
self.adult_reachable_regions = {player: set() for player in all_ids}
self.child_blocked_connections = {player: set() for player in all_ids}
self.adult_blocked_connections = {player: set() for player in all_ids}
self.day_reachable_regions = {player: set() for player in all_ids}
self.dampe_reachable_regions = {player: set() for player in all_ids}
self.age = {player: None for player in all_ids}
oot_ids = parent.get_game_players(OOTWorld.game) + parent.get_game_groups(OOTWorld.game)
self.child_reachable_regions = {player: set() for player in oot_ids}
self.adult_reachable_regions = {player: set() for player in oot_ids}
self.child_blocked_connections = {player: set() for player in oot_ids}
self.adult_blocked_connections = {player: set() for player in oot_ids}
self.day_reachable_regions = {player: set() for player in oot_ids}
self.dampe_reachable_regions = {player: set() for player in oot_ids}
self.age = {player: None for player in oot_ids}

def copy_mixin(self, ret) -> CollectionState:
ret.child_reachable_regions = {player: copy.copy(self.child_reachable_regions[player]) for player in
Expand Down

0 comments on commit e02211c

Please sign in to comment.