Current section

Files

Jump to
erlang_behaviour_trees include bt_nodes.hrl
Raw

include/bt_nodes.hrl

%% record definitions for nodes
%% TODO: should probably prefix everything with bt_ eg. bt_decorator
-record(decorator, {
name :: string(),
module :: atom(),
args :: map(),
state :: term(),
child :: bt_erl_node(),
metadata :: bt_metadata()
}).
-record(sequence, {
name :: string(),
namespace :: namespace(),
children :: list(bt_erl_node()),
metadata :: bt_metadata()
}).
%% TODO: add selector
-record(selector, {
name :: string(),
namespace :: namespace(),
children :: list(bt_erl_node()),
metadata :: bt_metadata()
}).
-record(task, {
name :: string(),
module :: atom(),
args :: map(),
state :: term(),
metadata :: bt_metadata()
}).
%% an intermediate representation of a node generator
%% this is used when defining an erlang based tree
%% this should NOT be present in parsed behaviour tree!
-record(bt_erl_tree, {
bb_keys = [] :: list(string()),
params = [] :: list(string()),
generator :: function(), %% arity 2: bb_keys, params as dictionaries
%% args will not be filled during definition! only when it is instantiated
%% should ideally have two different records for definition/instantiation?
args = #{} :: map()
}).
-record (bt_metadata, {
status=not_run :: bt_status() | not_run,
%% these are all optional right now, not filling them since not using them.
prev_state :: term(),
prev_bb :: blackboard() | undefined,
next_bb :: blackboard() | undefined
}).
-type namespace() :: list(string()) | undefined.
-type decorator() :: #decorator{}.
-type sequence() :: #sequence{}.
-type selector() :: #selector{}.
-type task() :: #task{}.
-type bt_erl_tree() :: #bt_erl_tree{}.
-type blackboard() :: map().
-type bt_event() :: term().
-type bt_status() :: success | failure | running.
-type bt_metadata() :: #bt_metadata{} | undefined.
-type bt_node() :: decorator() | sequence() | selector() | task().
-type bt_erl_node() :: bt_node() | bt_erl_tree().