agent_species behaviour (faber_neuroevolution v1.2.4)

View Source

Agent Species Behaviour - Defines a species/culture of agents.

This behaviour extends agent_definition to support multi-species coevolution. Each species has its own network topology, sensors, actuators, and fitness function.

Overview

Species represent distinct agent types that coevolve in a shared environment. Examples:

  • Foragers - Optimized for finding and consuming food
  • Predators - Optimized for hunting other agents
  • Scavengers - Optimized for following and opportunistic feeding

Two-Level Speciation

  Level 1: EXPLICIT SPECIES (user-defined)
    - Different network topologies
    - Different sensors/actuators
    - Different fitness functions
 
  Level 2: BEHAVIORAL SUB-SPECIES (emergent)
    - Same topology, different behaviors
    - Identified via behavioral fingerprinting
    - Preserves diversity within species
  ```
 
  == Example Implementation ==
 
  ```
  -module(forager_species).
  -behaviour(agent_species).
 
  name() -> <<"forager">>.
  network_topology() -> {29, [32, 16], 9}.
  sensors() -> [vision_sensor, smell_sensor, state_sensor].
  actuators() -> [movement_actuator, signal_actuator].
  evaluator() -> forager_evaluator.
  spawn_config() -> #{energy => 150, spawn_zone => center}.
  subspeciation_threshold() -> 1.5.

See also: species_registry.

Summary

Functions

Converts species to bridge config for single-species training.

Extracts species configuration from a module.

Validates that a module correctly implements agent_species.

Types

species_config/0

-type species_config() ::
          #{name := binary(),
            topology := {pos_integer(), [pos_integer()], pos_integer()},
            sensors := [module()],
            actuators := [module()],
            evaluator := module(),
            spawn_config := map(),
            subspeciation_threshold := float() | infinity,
            mutation_config => map()}.

species_id/0

-type species_id() :: atom() | binary().

subspecies_id/0

-type subspecies_id() :: {species_id(), non_neg_integer()}.

Callbacks

actuators/0

-callback actuators() -> [module()].

evaluator/0

-callback evaluator() -> module().

mutation_config/0

(optional)
-callback mutation_config() -> map().

name/0

-callback name() -> binary().

network_topology/0

-callback network_topology() -> {pos_integer(), [pos_integer()], pos_integer()}.

sensors/0

-callback sensors() -> [module()].

spawn_config/0

-callback spawn_config() -> map().

subspeciation_threshold/0

-callback subspeciation_threshold() -> float() | infinity.

version/0

-callback version() -> binary().

Functions

to_bridge_config(Module, Environment)

-spec to_bridge_config(Module, Environment) -> agent_bridge:bridge_config()
                          when Module :: module(), Environment :: module().

Converts species to bridge config for single-species training.

to_config(Module)

-spec to_config(Module) -> species_config() when Module :: module().

Extracts species configuration from a module.

validate(Module)

-spec validate(Module) -> ok | {error, Reasons} when Module :: module(), Reasons :: [term()].

Validates that a module correctly implements agent_species.