Skip to main content

Decision

Description:

  A decision tree framework for creating game AI structures.

Sel

Type: Function.

Description:

  Creates a selector node with the specified child nodes. A selector node will go through the child nodes until one succeeds.

Signature:

Sel: function(nodes: {Leaf}): Leaf

Parameters:

ParameterTypeDescription
nodes{Leaf}An array of Leaf nodes.

Returns:

Return TypeDescription
LeafA Leaf node that represents a selector.

Seq

Type: Function.

Description:

  Creates a sequence node with the specified child nodes. A sequence node will go through the child nodes until all node succeeds.

Signature:

Seq: function(nodes: {Leaf}): Leaf

Parameters:

ParameterTypeDescription
nodes{Leaf}An array of Leaf nodes.

Returns:

Return TypeDescription
LeafA Leaf node that represents a sequence.

Con

Type: Function.

Description:

  Creates a condition node with the specified name and handler function.

Signature:

Con: function(name: string, check: function(self: Unit): boolean): Leaf

Parameters:

ParameterTypeDescription
namestringThe name of the condition.
checkfunctionThe check function that takes a Unit parameter and returns a boolean result.

Returns:

Return TypeDescription
LeafA Leaf node that represents a condition check.

Act

Type: Function.

Description:

  Creates an action node with the specified action name.

Signature:

Act: function(actionName: string): Leaf

Parameters:

ParameterTypeDescription
actionNamestringThe name of the action to perform.

Returns:

Return TypeDescription
LeafA Leaf node that represents an action.

Act

Type: Function.

Description:

  Creates an action node with the specified handler function.

Signature:

Act: function(handler: function(self: Unit): string): Leaf

Parameters:

ParameterTypeDescription
handlerfunctionThe handler function that takes a Unit parameter which is the running AI agent and returns an action.

Returns:

Return TypeDescription
LeafA Leaf node that represents an action.

Accept

Type: Function.

Description:

  Creates a leaf node that represents accepting the current behavior tree. Always get success result from this node.

Signature:

Accept: function(): Leaf

Returns:

Return TypeDescription
LeafA Leaf node.

Reject

Type: Function.

Description:

  Creates a leaf node that represents rejecting the current behavior tree. Always get failure result from this node.

Signature:

Reject: function(): Leaf

Returns:

Return TypeDescription
LeafA Leaf node.

Behave

Type: Function.

Description:

  Creates a leaf node with the specified behavior tree as its root. It is possible to include a Behavior Tree as a node in a Decision Tree by using the Behave() function. This allows the AI to use a combination of decision-making and behavior execution to achieve its goals.

Signature:

Behave: function(name: string, root: Behavior.Leaf): Leaf

Parameters:

ParameterTypeDescription
namestringThe name of the behavior tree.
rootBehavior.LeafThe root node of the behavior tree.

Returns:

Return TypeDescription
LeafA Leaf node.

AI

Type: Field.

Description:

  The singleton instance to retrieve information while executing the decision tree.

Signature:

AI: AI