Documentation Index
Fetch the complete documentation index at: https://mintlify.com/MilesONerd/neurenix/llms.txt
Use this file to discover all available pages before exploring further.
Multi-Agent Systems
TheMultiAgent class enables you to coordinate multiple agents interacting in a shared environment. This is essential for multi-agent reinforcement learning, competitive/cooperative scenarios, and complex simulations.
MultiAgent Class
TheMultiAgent class is defined in neurenix/agent/multi_agent.py and provides functionality for coordinating multiple agents in a shared environment.
Constructor
agents(List[Agent]): List of agents in the systemenvironment(Environment): Shared environment for the agents
Properties
agents
The list of agents in the system.environment
The shared environment for the agents.step_count
Get the number of steps taken in the current episode.int - Number of steps taken
Core Methods
step()
Perform a single step of the multi-agent system. This method:- 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(dict): Observations for each agent (keyed by agent.id)actions(dict): Actions taken by each agent (keyed by agent.id)rewards(dict): Rewards for each agent (keyed by agent.id)done(bool): Whether the episode is completeinfo(dict): Additional information from the environment
reset()
Reset the multi-agent system. This method:- Resets the environment
- Resets each agent
- Returns the initial observations
Dict[str, Any] - Dictionary containing initial observations for each agent (keyed by agent.id)
add_agent(agent)
Add a new agent to the system.agent(Agent): The agent to add
remove_agent(agent_id)
Remove an agent from the system.agent_id(str): ID of the agent to remove
Optional[Agent] - The removed agent, or None if not found
Examples
Basic Multi-Agent Simulation
Run a simple multi-agent simulation:Competitive Multi-Agent RL
Create a competitive multi-agent reinforcement learning scenario:Cooperative Multi-Agent Task
Create agents that cooperate to achieve a shared goal:Dynamic Agent Management
Add and remove agents dynamically during simulation:Best Practices
1. Agents Need an id Attribute
The MultiAgent class uses agent.id to identify agents. Make sure your agents have this attribute:
2. Environment Must Support Multi-Agent
Your environment should handle actions from multiple agents:3. Register Agents with Environment
If your environment needs to track agents, register them:4. Handle Episode Termination
Decide when episodes end based on your use case:API Reference
MultiAgent
Source:neurenix/agent/multi_agent.py:10
See Also
- Single Agent - Create individual agents
- Environments - Create custom environments
- Agents Overview - Agent system overview