Skip to main content

SpawnPolicy

Trait SpawnPolicy 

Source
pub trait SpawnPolicy {
    // Required method
    fn on_death(
        &mut self,
        dead_id: AgentId,
        alive_count: usize,
        fittest_genome: Option<&AgentGenome>,
        fittest_position: Option<Position>,
    ) -> Option<(AgentGenome, Position)>;
}
Expand description

Trait for spawn policies.

Required Methods§

Source

fn on_death( &mut self, dead_id: AgentId, alive_count: usize, fittest_genome: Option<&AgentGenome>, fittest_position: Option<Position>, ) -> Option<(AgentGenome, Position)>

Decide whether to spawn a new agent after a death.

Returns the genome and position for the new agent, or None if no spawn should occur (e.g., population cap reached).

Implementors§