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§
Sourcefn num_agents(&self) -> usize
fn num_agents(&self) -> usize
Number of agents in this environment.
Sourcefn get_agent_observation(&self, agent_id: usize) -> Vec<f32>
fn get_agent_observation(&self, agent_id: usize) -> Vec<f32>
Sourcefn agent_action_space(&self, agent_id: usize) -> Vec<usize>
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.
Sourcefn step_multi(&mut self, actions: &[Vec<i64>]) -> MultiAgentResult
fn step_multi(&mut self, actions: &[Vec<i64>]) -> MultiAgentResult
Step the environment with multiple actions (one per agent).
§Arguments
actions- One action vector per agent.actions.len()must equalMultiAgentEnvironment::num_agents. Each innerVec<i64>carries one entry per action dimension and must match the layout reported byMultiAgentEnvironment::agent_action_space.
§Returns
Multi-agent result containing observations, rewards, and termination flags for each agent.
Sourcefn active_agents(&self) -> Vec<bool>
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".