pub trait SpaceInteraction<A: PositionedAgent>: Space {
type Error: Debug + Display;
// Required methods
fn random_position<R: RngCore>(&self, rng: &mut R) -> A::Position;
fn add_agent(&mut self, agent: &A) -> Result<(), Self::Error>;
fn remove_agent(&mut self, agent: &A) -> Result<(), Self::Error>;
fn nearby_ids(&self, position: &A::Position, radius: usize) -> Vec<AgentId> ⓘ;
}Expand description
Trait that spaces implement to support agent lifecycle and neighbor queries.
Each space type defines its own Error type and provides methods to
add/remove agents, generate random positions, and find nearby agent IDs.
Required Associated Types§
Required Methods§
Sourcefn random_position<R: RngCore>(&self, rng: &mut R) -> A::Position
fn random_position<R: RngCore>(&self, rng: &mut R) -> A::Position
Generate a random valid position within this space.
Sourcefn add_agent(&mut self, agent: &A) -> Result<(), Self::Error>
fn add_agent(&mut self, agent: &A) -> Result<(), Self::Error>
Register an agent with the space at its current position.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.