agent_environment behaviour (macula_neuroevolution v0.28.0)

View Source

See also: agent_actuator, agent_bridge, agent_definition, agent_sensor.

Summary

Types

Action command from an actuator. See agent_actuator:action().

Unique identifier for an agent within an episode.

Agent-specific state containing position, energy, etc. See agent_sensor:agent_state().

Configuration passed to init/1. Structure is domain-defined, typically includes: max_ticks, seed, arena_size, etc.

Unique identifier for the environment type. Examples: <<"hex_arena">>, <<"maze">>, <<"open_field">>.

Environment state containing world information. Structure is domain-defined, typically includes: walls, food, tick, max_ticks, etc.

Performance metrics extracted after episode. Used by evaluator for fitness calculation.

Types

action/0

-type action() :: map().

Action command from an actuator. See agent_actuator:action().

agent_id/0

-type agent_id() :: term().

Unique identifier for an agent within an episode.

agent_state/0

-type agent_state() :: map().

Agent-specific state containing position, energy, etc. See agent_sensor:agent_state().

env_config/0

-type env_config() :: map().

Configuration passed to init/1. Structure is domain-defined, typically includes: max_ticks, seed, arena_size, etc.

env_name/0

-type env_name() :: binary().

Unique identifier for the environment type. Examples: <<"hex_arena">>, <<"maze">>, <<"open_field">>.

env_state/0

-type env_state() :: map().

Environment state containing world information. Structure is domain-defined, typically includes: walls, food, tick, max_ticks, etc.

metrics/0

-type metrics() :: map().

Performance metrics extracted after episode. Used by evaluator for fitness calculation.

Callbacks

apply_action/3

-callback apply_action(Action, AgentState, EnvState) -> {ok, AgentState, EnvState}
                          when Action :: action(), AgentState :: agent_state(), EnvState :: env_state().

extract_metrics/2

-callback extract_metrics(AgentState, EnvState) -> metrics()
                             when AgentState :: agent_state(), EnvState :: env_state().

init/1

-callback init(Config) -> {ok, EnvState} | {error, Reason}
                  when Config :: env_config(), EnvState :: env_state(), Reason :: term().

is_terminal/2

-callback is_terminal(AgentState, EnvState) -> boolean()
                         when AgentState :: agent_state(), EnvState :: env_state().

name/0

-callback name() -> env_name().

spawn_agent/2

-callback spawn_agent(AgentId, EnvState) -> {ok, AgentState, EnvState} | {error, Reason}
                         when
                             AgentId :: agent_id(),
                             EnvState :: env_state(),
                             AgentState :: agent_state(),
                             Reason :: term().

tick/2

-callback tick(AgentState, EnvState) -> {ok, AgentState, EnvState}
                  when AgentState :: agent_state(), EnvState :: env_state().

Functions

get_info(Module)

-spec get_info(Module) -> {ok, Info} | {error, Reason}
                  when Module :: module(), Info :: #{name := env_name()}, Reason :: term().

validate(Module)

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