rllib/env/multi_agent_env.py
def with_agent_groups(
        self,
        groups: Dict[str, List[AgentID]],
        obs_space: gym.Space = None,
            act_space: gym.Space = None) -> "MultiAgentEnv":
        """Convenience method for grouping together agents in this env.

        An agent group is a list of agent IDs that are mapped to a single
        logical agent. All agents of the group must act at the same time in the
        environment. The grouped agent exposes Tuple action and observation
        spaces that are the concatenated action and obs spaces of the
        individual agents.

        The rewards of all the agents in a group are summed. The individual
        agent rewards are available under the "individual_rewards" key of the
        group info return.

        Agent grouping is required to leverage algorithms such as Q-Mix.

        This API is experimental.

        Args:
            groups: Mapping from group id to a list of the agent ids
                of group members. If an agent id is not present in any group
                value, it will be left ungrouped.
            obs_space: Optional observation space for the grouped
                env. Must be a tuple space.
            act_space: Optional action space for the grouped env.
                Must be a tuple space.

        Examples:
            >>> from ray.rllib.env.multi_agent_env import MultiAgentEnv
            >>> class MyMultiAgentEnv(MultiAgentEnv): # doctest: +SKIP
            ...     # define your env here
            ...     ... # doctest: +SKIP
            >>> env = MyMultiAgentEnv(...) # doctest: +SKIP
            >>> grouped_env = env.with_agent_groups(env, { # doctest: +SKIP
            ...   "group1": ["agent1", "agent2", "agent3"], # doctest: +SKIP
            ...   "group2": ["agent4", "agent5"], # doctest: +SKIP
            ... }) # doctest: +SKIP
        """

        from ray.rllib.env.wrappers.group_agents_wrapper import \
            GroupAgentsWrapper
        return GroupAgentsWrapper(self, groups, obs_space, act_space)
Convenience method for grouping together agents in this env.

        An agent group is a list of agent IDs that are mapped to a single
        logical agent. All agents of the group must act at the same time in the
        environment. The grouped agent exposes Tuple action and observation
        spaces that are the concatenated action and obs spaces of the
        individual agents.

        The rewards of all the agents in a group are summed. The individual
        agent rewards are available under the "individual_rewards" key of the
        group info return.

        Agent grouping is required to leverage algorithms such as Q-Mix.

        This API is experimental.

        Args:
            groups: Mapping from group id to a list of the agent ids
                of group members. If an agent id is not present in any group
                value, it will be left ungrouped.
            obs_space: Optional observation space for the grouped
                env. Must be a tuple space.
            act_space: Optional action space for the grouped env.
                Must be a tuple space.

        Examples:
            >>> from ray.rllib.env.multi_agent_env import MultiAgentEnv
            >>> class MyMultiAgentEnv(MultiAgentEnv): # doctest: +SKIP
            ...     # define your env here
            ...     ... # doctest: +SKIP
            >>> env = MyMultiAgentEnv(...) # doctest: +SKIP
            >>> grouped_env = env.with_agent_groups(env, { # doctest: +SKIP
            ...   "group1": ["agent1", "agent2", "agent3"], # doctest: +SKIP
            ...   "group2": ["agent4", "agent5"], # doctest: +SKIP
            ... }) # doctest: +SKIP
        
Convenience method for grouping together agents in this env.
An agent group is a list of agent IDs that are mapped to a single
logical agent. All agents of the group must act at the same time in the
environment. The grouped agent exposes Tuple action and observation
spaces that are the concatenated action and obs spaces of the
individual agents.

The rewards of all the agents in a group are summed. The individual
agent rewards are available under the "individual_rewards" key of the
group info return.

Agent grouping is required to leverage algorithms such as Q-Mix.

This API is experimental.
Convenience method for grouping together agents in this env . An agent group is a list of agent IDs that are mapped to a single logical agent . All agents of the group must act at the same time in the environment . The grouped agent exposes Tuple action and observation spaces that are the concatenated action and obs spaces of the individual agents . The rewards of all the agents in a group are summed . The individual agent rewards are available under the " individual_rewards " key of the group info return . Agent grouping is required to leverage algorithms such as Q - Mix . This API is experimental .
def with_agent_groups(
        self,
        groups: Dict[str, List[AgentID]],
        obs_space: gym.Space = None,
            act_space: gym.Space = None) -> "MultiAgentEnv":
        from ray.rllib.env.wrappers.group_agents_wrapper import \
            GroupAgentsWrapper
        return GroupAgentsWrapper(self, groups, obs_space, act_space)
def with_agent_groups ( self , groups : Dict [ str , List [ AgentID ] ] , obs_space : gym . Space = None , act_space : gym . Space = None ) -> "MultiAgentEnv" : from ray . rllib . env . wrappers . group_agents_wrapper import GroupAgentsWrapper return GroupAgentsWrapper ( self , groups , obs_space , act_space )
Convenience method for grouping together agents in this env.
Convenience method for grouping together agents in this env .
"""Convenience method for grouping together agents in this env.

        An agent group is a list of agent IDs that are mapped to a single
        logical agent. All agents of the group must act at the same time in the
        environment. The grouped agent exposes Tuple action and observation
        spaces that are the concatenated action and obs spaces of the
        individual agents.

        The rewards of all the agents in a group are summed. The individual
        agent rewards are available under the "individual_rewards" key of the
        group info return.

        Agent grouping is required to leverage algorithms such as Q-Mix.

        This API is experimental.

        Args:
            groups: Mapping from group id to a list of the agent ids
                of group members. If an agent id is not present in any group
                value, it will be left ungrouped.
            obs_space: Optional observation space for the grouped
                env. Must be a tuple space.
            act_space: Optional action space for the grouped env.
                Must be a tuple space.

        Examples:
            >>> from ray.rllib.env.multi_agent_env import MultiAgentEnv
            >>> class MyMultiAgentEnv(MultiAgentEnv): # doctest: +SKIP
            ...     # define your env here
            ...     ... # doctest: +SKIP
            >>> env = MyMultiAgentEnv(...) # doctest: +SKIP
            >>> grouped_env = env.with_agent_groups(env, { # doctest: +SKIP
            ...   "group1": ["agent1", "agent2", "agent3"], # doctest: +SKIP
            ...   "group2": ["agent4", "agent5"], # doctest: +SKIP
            ... }) # doctest: +SKIP
        """
self
groups
Dict[str, List[AgentID]]
Mapping from group id to a list of the agent ids
of group members. If an agent id is not present in any group
value, it will be left ungrouped.
Mapping from group id to a list of the agent ids of group members . If an agent id is not present in any group value it will be left ungrouped .
obs_space
gym.Space
Optional observation space for the grouped
env. Must be a tuple space.
Optional observation space for the grouped env . Must be a tuple space .
act_space
gym.Space
Optional action space for the grouped env.
Must be a tuple space.
Optional action space for the grouped env . Must be a tuple space .
examples
>>> from ray.rllib.env.multi_agent_env import MultiAgentEnv
>>> class MyMultiAgentEnv(MultiAgentEnv): # doctest: +SKIP
# define your env here
# doctest: +SKIP
>>> env = MyMultiAgentEnv(...) # doctest: +SKIP
>>> grouped_env = env.with_agent_groups(env, { # doctest: +SKIP
"group1": ["agent1", "agent2", "agent3"], # doctest: +SKIP
"group2": ["agent4", "agent5"], # doctest: +SKIP
}) # doctest: +SKIP
>>> from ray . rllib . env . multi_agent_env import MultiAgentEnv >>> class MyMultiAgentEnv ( MultiAgentEnv ) : # doctest : + SKIP # define your env here # doctest : + SKIP >>> env = MyMultiAgentEnv ( ... ) # doctest : + SKIP >>> grouped_env = env . with_agent_groups ( env { # doctest : + SKIP " group1 " : [ " agent1 " " agent2 " " agent3 " ] # doctest : + SKIP " group2 " : [ " agent4 " " agent5 " ] # doctest : + SKIP } ) # doctest : + SKIP