Skip to content

High Level Overview

David Kamberský edited this page Jul 31, 2017 · 5 revisions

Here you can find an overview of some of the inner workings of the Behavior system.

Actor

The Actor is a decorated Entity, a class that facilitates adds Behavior related functionality to a given Entity.

Important parts of the Actor class:

  • Actor(EntityRef) constructor - an Actor can only be constructed over a given Entity
  • getEntity() - returns the underlying entity
  • getComponent(), getComponentField(), hasComponent() - QoL methods providing easier access to some parts of the underlying entity

and the following:

Blackboard & DataMap

dataMap, getValue(), setValue()

  • Data map functionality: every Behavior Node manipulates its stateful information through these methods, so the Nodes themselves can be stateless / reusable. the id arguments are the tree-unique IDs of the Nodes.

blackboard, readFromBlackboard(), writeToBlackboard()

  • Blackboard functionality - the Blackboard is there to facilitate inter-node communication: while in dataMap every node has its own little corner where it stores its info, blackboard is the shared space where nodes can co-ordinate any higher level stateful goals.

TreeNode and its derivatives

Behavior trees are composed of objects implementing the TreeNode interface. There are composite nodes, action nodes and decorators, but in an effort not to duplicate information too much, here's a link to the part of the wiki that explains the TreeNodes in detail.

Interpreters and BehaviorTree objects

The system is as follows: every Actor instance (entity with a behavior) has an associated Interpreter. That interpreter uses a BehaviorTreeRunner (currently DefaultBehaviorTreeRunner as we aren't using the bytecode/ASM parts of the system) to work on the given tree - there is a BehaviorTreeRunner for every given Actor. What's important is the BehaviorTree is a data class; it provides the underlying tree data, but it's shared between Actors, using the Intepreter/BehaviorTreeRunner combo.