-
Notifications
You must be signed in to change notification settings - Fork 21
BehaviourTree
A behaviour tree is a tree of hierarchical nodes that control the flow of decision making of an AI entity. At the extents of the tree are the actual commands that control the AI entity, and forming the branches are various types of utility nodes that control the AI’s walk down the trees to reach the sequences of commands best suited to the situation.
A behaviour tree is made up of several types of nodes, however some core functionality is common to any type of node in a behaviour tree. All nodes return one of three statuses: Success, Failure or Running.
The first two, as their names suggest, inform their parent that their operation was a success or a failure. The third means that success or failure is not yet determined, and the node is still running. The node will be ticked again next time the tree is ticked, at which point it will again have the opportunity to succeed, fail or continue running.
These are the lowest level node type, and are incapable of having any children. Actions are however the most powerful of node types, as these will be defined and implemented by your game to do the game specific or character specific tests or actions required to make your tree actually do useful stuff. An example of this would be Walk. A Walk action node would make a character walk to a specific point on the map, and return Success or Failure depending on the result.
Prints a message to the console.
Waits for the specified amount of time then returns Success.
Waits for one tick then returns Success.
Executes a behaviour sub-tree.
A composite node is a node that can have one or more children. They will process one or more of these children in either a first to last sequence or random order depending on the particular composite node in question, and at some stage will consider their processing complete and pass either Success or Failure to their parent, often determined by the Success or Failure of the child nodes. During the time they are processing children, they will continue to return Running to the parent.
Executes the children from first to last and returns Success if all children return Success or Failure if any child returns Failure.
Executes the children from first to last until one of them return Success. If none of the children return Success then the Selector will also return Failure.
Executes the children from first to last untill one of the following conditions is met:
- All children return Failure or any of the children returns Failure.
- All children return Success or any of the children returns Success.
Chooses one of the children randomly and executes it.
Chooses one of the children randomly and executes. Unlike the Random node, the WeightedRandom node also allows you to set different weights to it's children so some children are more likely to be selected than others.
A decorator node, like a composite node, can have a child node. Unlike a composite node, they can specifically only have a single child. Their function is either to transform the result they receive from their child node's status, to terminate the child, or repeat processing of the child, depending on the type of decorator node.
Executes its child and returns the result. All behaviour trees have a Root node. The Root node can't be deleted and you can't add other Root nodes to the behaviour tree.
This is a special type of node whose only purpose is to help you organise the behaviour tree in the editor. A NodeGroup can be collapsed or expanded in the editor to make the behaviour tree more readable.
The AlwaysFail node will always return Failure, regardless of what its child returns.
The AlwaysSucceed node will always return Success, regardless of what its child returns.
Invertes the result of its child. If the child returns Success, the inverter will return Failure. If the child returns Failure, the inverter will return Success.
The Limiter can only be executed a specific number of times. If you try to execute it more times than the maximum number of allowed execution then it will return Failure.
A Repeat node will reprocess its child node each time its child returns a result until it hits the specified repeat count.
This node will reprocess its child every time it returns a result.
This node will continue to reprocess its child as long as the child returns Failure.
This node will continue to reprocess its child as long as the child returns Success.
Each node can have a list of constraints and services. Constraints are executed from top to bottom and if any constraints fails the node will be aborted. Services are executed from top to buttom after the node is ticked and can be used to add extra functionality to the node.
See Also: Behaviour Tree Editor, AI Agent, Scripting