Overview
TheMultiAgent 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
int
Number of steps.
Core Methods
step
- Gets observations for each agent from the environment
- Has each agent select an action based on its observation
- Applies all actions to the environment
- Returns the results
Dict[str, Any]
Dictionary containing observations, actions, rewards, and done flags for each agent:
observations: Dict mapping agent IDs to observationsactions: Dict mapping agent IDs to actionsrewards: Dict mapping agent IDs to rewardsdone: Boolean indicating if the episode is completeinfo: Additional information
reset
- Resets the environment
- Resets each agent
- Returns the initial observations
Dict[str, Any]
Dictionary containing initial observations for each agent.
Agent Management
add_agent
Agent
required
Agent to add.
remove_agent
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
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