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.
Environments
TheEnvironment class defines the world in which agents operate. It provides observations to agents, processes their actions, manages state, and determines rewards. Creating custom environments is essential for training and evaluating agents.
Environment Class
TheEnvironment class is defined in neurenix/agent/environment.py and provides the base interface for all environments.
Constructor
Properties
state
Get the current state of the environment (returns a copy).Dict[str, Any] - Copy of the current environment state
agents
Get the agents registered with the environment (returns a copy).Dict[str, Any] - Dictionary mapping agent IDs to agents
Core Methods
reset()
Reset the environment to its initial state.Dict[str, Any] - Initial state of the environment
step(actions)
Apply actions to the environment and update its state. This method must be implemented by subclasses.actions(Dict[str, Any]): Dictionary mapping agent IDs to their actions
Dict[str, Any] - Dictionary containing:
rewards(dict): Dictionary mapping agent IDs to their rewardsdone(bool): Whether the episode is completeinfo(dict): Additional information
NotImplementedError if not overridden in subclass
observe(agent)
Get an observation of the environment for a specific agent. This method must be implemented by subclasses.agent(Any): The agent requesting the observation
Dict[str, Any] - Observation for the agent
Raises: NotImplementedError if not overridden in subclass
register_agent(agent)
Register an agent with the environment.agent(Any): The agent to register
unregister_agent(agent_id)
Unregister an agent from the environment.agent_id(str): ID of the agent to unregister
Creating Custom Environments
Grid World Environment
Create a simple grid-based environment:Continuous Environment
Create an environment with continuous state and action spaces:Multi-Agent Resource Collection
Create an environment where agents collect resources:Best Practices
1. Override _get_initial_state()
Define your environment’s initial state:2. Return Proper Step Results
Always return a dictionary withrewards, done, and info:
3. Agent-Specific Observations
Provide observations tailored to each agent’s perspective:4. Handle Agent Registration
Register agents if your environment needs to track them:5. Maintain State Immutability
Thestate property returns a copy for safety:
API Reference
Environment
Source:neurenix/agent/environment.py:7
See Also
- Single Agent - Create individual agents
- Multi-Agent Systems - Coordinate multiple agents
- Agents Overview - Agent system overview