def _space_contains(self, space: gym.Space, x: MultiEnvDict) -> bool: """Check if the given space contains the observations of x. Args: space: The space to if x's observations are contained in. x: The observations to check. Returns: True if the observations of x are contained in space. """ agents = set(self.get_agent_ids()) for multi_agent_dict in x.values(): for agent_id, obs in multi_agent_dict.items(): # this is for the case where we have a single agent # and we're checking a Vector env thats been converted to # a BaseEnv if agent_id == _DUMMY_AGENT_ID: if not space.contains(obs): return False # for the MultiAgent env case elif (agent_id not in agents) or (not space[agent_id].contains(obs)): return False return True
def _space_contains(self, space: gym.Space, x: MultiEnvDict) -> bool: """Check if the given space contains the observations of x. Args: space: The space to if x's observations are contained in. x: The observations to check. Returns: True if the observations of x are contained in space. """ agents = set(self.get_agent_ids()) for multi_agent_dict in x.values(): for agent_id, obs in multi_agent_dict: if (agent_id not in agents) or (not space[agent_id].contains(obs)): return False return True
def action_space_contains(self, x: MultiEnvDict) -> bool: return all(self.envs[0].action_space_contains(val) for val in x.values())