multispecies_environment behaviour (faber_neuroevolution v1.2.4)
View SourceMulti-Species Environment Behaviour.
Extends agent_environment to support multiple species coevolving in a shared environment.
Overview
A multi-species environment manages:
- Multiple agent types with different capabilities
- Species-specific spawning rules
- Inter-species interactions (predation, cooperation)
- Per-species metrics extraction
Agent State Extension
Each agent state must include:
#{
id := term(),
species := atom(), %% Species identifier
species_data := map(), %% Species-specific state
... %% Standard agent fields
}Interaction Types
┌─────────────────────────────────────────────────────┐
│ Interaction Matrix │
├─────────────────────────────────────────────────────┤
│ │ Forager │ Predator │ Scavenger │
├──────────────┼─────────┼──────────┼─────────────────┤
│ Forager │ compete │ prey │ ignore │
│ Predator │ hunt │ compete │ ignore │
│ Scavenger │ follow │ avoid │ compete │
└─────────────────────────────────────────────────────┘See also: agent_environment, agent_species.
Summary
Functions
Extracts metrics for all species.
Processes interactions between all agent pairs.
Spawns a population of agents for each species.
Validates a multi-species environment module.
Types
-type interaction() :: hunt | prey | compete | cooperate | ignore | avoid | follow.
-type species_spawn_config() :: #{energy := float(), spawn_zone := center | edge | random | {hex, {integer(), integer()}}, max_count => pos_integer(), spawn_delay => non_neg_integer()}.
Callbacks
Functions
-spec extract_all_metrics(Module, State) -> #{atom() => map()} when Module :: module(), State :: {[map()], map()}.
Extracts metrics for all species.
-spec process_interactions(Module, State) -> {ok, NewAgents, NewEnv} when Module :: module(), State :: {[map()], map()}, NewAgents :: [map()], NewEnv :: map().
Processes interactions between all agent pairs.
-spec spawn_population(Module, SpeciesConfigs, EnvState) -> {ok, AgentStates, EnvState} when Module :: module(), SpeciesConfigs :: #{atom() => {pos_integer(), species_spawn_config()}}, EnvState :: map(), AgentStates :: [map()].
Spawns a population of agents for each species.
Validates a multi-species environment module.
Note: This does NOT call agent_environment:validate/1 because multi-species environments use spawn_agent/3 instead of spawn_agent/2.