AEC API#

class pettingzoo.utils.env.AECEnv#

The AECEnv steps agents one at a time.

If you are unsure if you have implemented a AECEnv correctly, try running the api_test documented in the Developer documentation on the website.

Attributes#

AECEnv.agents: List[str]#

A list of the names of all current agents, typically integers. These may be changed as an environment progresses (i.e. agents can be added or removed).

Type:

List[AgentID]

AECEnv.num_agents#

The length of the agents list.

AECEnv.possible_agents: List[str]#

A list of all possible_agents the environment could generate. Equivalent to the list of agents in the observation and action spaces. This cannot be changed through play or resetting.

Type:

List[AgentID]

AECEnv.max_num_agents#

The length of the possible_agents list.

AECEnv.agent_selection: str#

An attribute of the environment corresponding to the currently selected agent that an action can be taken for.

Type:

AgentID

AECEnv.terminations: Dict[str, bool]#
AECEnv.truncations: Dict[str, bool]#
AECEnv.rewards: Dict[str, float]#

A dict of the rewards of every current agent at the time called, keyed by name. Rewards the instantaneous reward generated after the last step. Note that agents can be added or removed from this attribute. last() does not directly access this attribute, rather the returned reward is stored in an internal variable. The rewards structure looks like:

{0:[first agent reward], 1:[second agent reward] ... n-1:[nth agent reward]}
Type:

Dict[AgentID, float]

AECEnv.infos: Dict[str, Dict[str, Any]]#

A dict of info for each current agent, keyed by name. Each agent’s info is also a dict. Note that agents can be added or removed from this attribute. last() accesses this attribute. The returned dict looks like:

infos = {0:[first agent info], 1:[second agent info] ... n-1:[nth agent info]}
Type:

Dict[AgentID, Dict[str, Any]]

AECEnv.observation_spaces: Dict[str, Space]#

A dict of the observation spaces of every agent, keyed by name. This cannot be changed through play or resetting.

Type:

Dict[AgentID, gymnasium.spaces.Space]

AECEnv.action_spaces: Dict[str, Space]#

A dict of the action spaces of every agent, keyed by name. This cannot be changed through play or resetting.

Type:

Dict[AgentID, gymnasium.spaces.Space]

Methods#

AECEnv.step(action: ActionType) None#

Accepts and executes the action of the current agent_selection in the environment.

Automatically switches control to the next agent.

AECEnv.reset(seed: Optional[int] = None, return_info: bool = False, options: Optional[dict] = None) None#

Resets the environment to a starting state.

AECEnv.observe(agent: str) Optional[ObsType]#

Returns the observation an agent currently can make.

last() calls this function.

AECEnv.render() None | np.ndarray | str | list#

Renders the environment as specified by self.render_mode.

Render mode can be human to display a window. Other render modes in the default environments are ‘rgb_array’ which returns a numpy array and is supported by all environments outside of classic, and ‘ansi’ which returns the strings printed (specific to classic environments).

AECEnv.seed(seed: Optional[int] = None) None#

Reseeds the environment (making the resulting environment deterministic).

AECEnv.close()#

Closes any resources that should be released.

Closes the rendering window, subprocesses, network connections, or any other resources that should be released.