A chromosome stores the information about a Behavior Tree in its entirety. More...
#include <BTChromosome.h>
Public Member Functions | |
void | RegisterInitialBTAsset (FString btAssetID) |
FString | GetInitialBTAsset () |
const UBTCompositeNodeGene * | GetRoot () const |
UBTCompositeNodeGene * | GetRoot () |
void | SetRoot (UBTCompositeNodeGene *node) |
void | AddDecorator (UBTDecoratorGene *decorator) |
int32 | RemoveDecorator (UBTDecoratorGene *decorator) |
int32 | InsertDecorator (UBTDecoratorGene *decorator, int32 idx) |
int | GetNumDecorators () const |
UBTDecoratorGene * | GetDecorator (int idx) const |
UBTChromosome * | Duplicate (UObject *outer) |
FString | ToString () |
void | SetServiceInjector (UServiceInjector *serviceInjector) |
void | ToLog () |
A chromosome stores the information about a Behavior Tree in its entirety.
Each Chromosome represents a single Behavior Tree in gene form.
The Behavior Tree consists of a Root Node and a set of Root Decorators.
Under the Root Node Gene, you will find the rest of the tree.
The tree sturcture mirrors the structure of Unreal Engine Behavior Trees, and is as follows:
There are five node types:
This current class is a BTChromosome, which does not mirror a Unreal Engine node. These objects represent a container for the root node, and have: 0 to many BTDecoratorGene, which are conditionals to be applied to the root node 1 BTCompositeNodeGene, which is the root of the tree
The root node is a BTCompositeNodeGene, these nodes have: 0 to many BTChildContainerGene, which act as containers for child noded 0 to many BTServiceGene, which run in the background during the execution of the composite node
Each child of a BTCompositeNodeGene is a BTChildContainerGene, which acts as a container for either a BTTaskNodeGene or a BTCompositeNodeGene, these nodes have: 0 to many BTDecoratorGene, which are conditions to be applied to their node 1 of: 'taskChild' of type BTTaskNodeGene 'compositeChild' of type BTCompositeNodeGene
A BTTaskNodeGene is an action for the artificial agent to execute, it can be anything from a move instruction, to a wait or play sound instruction. These are the leaf nodes of the behavior tree, and they have: 0 to many BTServiceGene, which run in the background during the execution of the task node
BTServiceGene nodes can sit on all BTCompositeNodeGene nodes or BTTaskNodeGene nodes, there can be any number.
BTDecoratorGene nodes can sit on all BTChildContainerGene nodes, there can be any number.
An example sketch of this version of behavior tree is as follows:
- - | BTChromosome (Container for root node) | | | | (BTDecoratorGene 1) | | (BTDecoratorGene 2) | | | | | | BTCompositeNodeGene (root) | | | | (BTServiceGene 1) | - - || || || || || || - - - - | BTChildContainerGene 1 | | BTChildContainerGene 2 | | | | | | (BTDecoratorGene 1) | | BTCompositeNodeGene | | | - - | | || | BTTaskNodeGene | || | | || | (BTServiceGene 1) | || | (BTServiceGene 2) | || - - - - | BTChildContainerGene 1 | | | | (BTDecoratorGene 1) | | (BTDecoratorGene 2) | | (BTDecoratorGene 3) | | | | BTTaskNodeGene | - -