Skip to main content

Overview

The MultiAgent class provides functionality for coordinating multiple agents, enabling them to interact with each other and with a shared environment.

Class Definition

Parameters

List[Agent]
required
List of agents in the system.
Environment
required
Shared environment for the agents.

Properties

step_count

Get the number of steps taken in the current episode.
int
Number of steps.

Core Methods

step

Perform a single step of the multi-agent system. This method:
  1. Gets observations for each agent from the environment
  2. Has each agent select an action based on its observation
  3. Applies all actions to the environment
  4. Returns the results
Dict[str, Any]
Dictionary containing observations, actions, rewards, and done flags for each agent:
  • observations: Dict mapping agent IDs to observations
  • actions: Dict mapping agent IDs to actions
  • rewards: Dict mapping agent IDs to rewards
  • done: Boolean indicating if the episode is complete
  • info: Additional information

reset

Reset the multi-agent system. This method:
  1. Resets the environment
  2. Resets each agent
  3. Returns the initial observations
Dict[str, Any]
Dictionary containing initial observations for each agent.

Agent Management

add_agent

Add a new agent to the system.
Agent
required
Agent to add.

remove_agent

Remove an agent from the system.
str
required
ID of the agent to remove.
Optional[Agent]
The removed agent, or None if no agent with the given ID was found.

len

Get the number of agents in the system.
int
Number of agents.

Example Usage

Use Cases

Cooperative Tasks

Multiple agents working together to achieve a common goal

Competitive Games

Agents competing against each other in zero-sum games

Mixed Settings

Combination of cooperation and competition

Swarm Intelligence

Large numbers of simple agents exhibiting collective behavior