06.01
Behaviour trees.
I’m getting into some AI programming and i was looking around for some concepts for implementing some reusable AI logic. i came across finite state machine, hierarchical task network, and behavior trees.
Cause AngryAnt has made a really nice implementation of behavior trees in unity i started investigating in behavior trees.
I began collection information about behavior trees and writing it down. perhaps it can help other people as well.
Building blocks of behavior trees
A behavior tree is made of several components that are attached to each other. There are a couple of different components that each has specific properties.
To control the flow there are three components : Sequence, Selector, Parallel.
For preforming actions there are two components : Action, Decorator.
below a short description of each component:
Sequences
A sequence start running and ticks the first child (from left to right). if the child return success the sequence continues its execution and ticks the next a child can also return running. return running will cause the sequence to return running and the next time the sequence is called the child that was running is called.
If all child would return success the sequence executes 1,2,4,3. When the sequence finishes the return result is success.
if a child fails then the sequence stops and also returns failure and the next time the sequence will start with the first child.
Selectors
A selector starts running and ticks the first child. if a child returns success then the selector will return success also. if a selector returns Failure the selector will move on to the next child and return running.
if a selector reaches the end of its child the it return failure and the next time it will start at the first child.
Parallel
A parrallel component will tick all it’s childs the same time, unlike the sequence and selector (those will tick its child one by one).
Decorators
When a decorator is ticked its method or property get will get called.
- if a decorator returns Success it’s child will get called. the result of that child will be returned.
- if a decorator returns Failure it’s child will not be called . the result of the decorator will be
Succes.
- if a decorator returns Running the child will be called. the result of the decorator will be
Running.
Actions
When a action is ticked it’s method or property get will get called. whatever value return from the method or propertgy get will be the result.
No Comment.
Add Your Comment