Skip to main content

MultiAgentEnvironment

Trait MultiAgentEnvironment 

Source
pub trait MultiAgentEnvironment: Environment {
    // Required methods
    fn num_agents(&self) -> usize;
    fn get_agent_observation(&self, agent_id: usize) -> Vec<f32>;
    fn agent_action_space(&self, agent_id: usize) -> Vec<usize>;
    fn step_multi(&mut self, actions: &[Vec<i64>]) -> MultiAgentResult;
    fn active_agents(&self) -> Vec<bool>;
}
Expand description

Multi-agent environment trait.

Environments implementing this trait support multiple agents interacting in the same game instance. The base Environment trait provides the single-agent reset / observation / action-space methods; this trait extends it with the per-agent variants needed by the multi-agent trainers.

Required Methods§

Source

fn num_agents(&self) -> usize

Number of agents in this environment.

Source

fn get_agent_observation(&self, agent_id: usize) -> Vec<f32>

Get observation for a specific agent.

§Arguments
  • agent_id - Index of the agent (0..num_agents).
Source

fn agent_action_space(&self, agent_id: usize) -> Vec<usize>

Per-agent action-space layout.

Returns one bin count per action dimension for the agent. For a pure-discrete agent with n choices this is vec![n]; for a factored agent with [house_index, mode] this is vec![10, 2].

The length of this vector must match the length of each per-agent action passed to MultiAgentEnvironment::step_multi, and it must match the per-dim cardinalities of any policy driving this agent.

Source

fn step_multi(&mut self, actions: &[Vec<i64>]) -> MultiAgentResult

Step the environment with multiple actions (one per agent).

§Arguments
§Returns

Multi-agent result containing observations, rewards, and termination flags for each agent.

Source

fn active_agents(&self) -> Vec<bool>

Get which agents are currently active (not terminated).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§