Description of the Lua behaviourtree nodes

Source: Internet
Author: User

Project Description
The code for this behavior tree is written in Lua, and all the content is also built on the underlying syntax of LUA because the company project needs a set of Lua behavior tree code, so try to extract code from the behavior tree associated with the famine. The vast majority of nodes behave the same as famine, but some nodes may change partly because of demand.
General Description
The behavior tree state is basically divided into 4 ready: Prepare state, the node has not been called. Or it has been called to end the state after reset running: Running state, usually the parent node waits for the child node runing end to mark its own status as the end, Of course, some nodes do not care about the runing state of the child nodes success: Run successfully failed: Run failure most of the nodes have corresponding Chinese names, but some nodes I do not know how to translate the behavior tree will be interrupted, when interrupted. The reset function of the child node is called. If necessary, the override of the reset function can handle the interrupted situation where the behavior tree is also paused in some cases. This tree leaves the associated pause (Suspend) and restart (Restart) functions. External calls are required when the tree is paused, and the method internally propagates the corresponding method to each node
Node DescriptionBehaviourtree
tree node, mainly used for child node invocation, state preservation and so on. No actual business functions
Behaviournode
The parent node of all nodes, without actual business meaning, is primarily a method of maintaining a variety of underlying states
Decoratornode (decorative node)
There is no real business sense, but usually the parent of a node with only one child node
Conditionnode (decision node)
This node is created by passing in a method that can obtain a decision value, which changes the state of the current node according to the value returned after the call to the method when it is run to this node. Nil or false converted to failed, otherwise converted to success
conditionwaitnode (conditional wait node)
is basically the same as the verdict. The difference is that it is determined to be running in the case of the original failed.
Actionnode (Action node)
A function is passed in when the node is created. When running to this node. This function is called, and the state of the node is marked as success
Waitnode (Waiting node)
A time value is passed in when the node is created. When running to this node, the state of the node from the start to the end of time will always be running. After the wait time is over, the node state is modified to success. PS: During the wait, this node will hibernate. To reduce performance consumption, other similar feature nodes should also need to make appropriate hibernation when writing
Sequencenode (sequential node)
When you create this node, you need to pass in a queue of nodes. When you run to this node. His child nodes will run one after the other. If his child node state is success, then he will run the next one, if his child node state is running, then he will also identify itself as running, and wait for the node to return other results, if his child node state is failed, Then he will mark his state as failed and return directly. All nodes return at the end of success then he identifies itself as a success and returns.
Selectornode (select node)
Like a sequential node, a list of nodes is required to be created, and when run to this node, his nodes run one after the other. If his child node is success, then he will identify itself as success and return it directly, if his child node state is running, then he will also identify itself as running, and wait for the node to return other results, if his child node state is failed, Then he will run the next. If no one node returns success, he will identify itself as failed and return
Notdecorator (Take the inverse node)
You need to pass in a child node when creating this node. The result of the child node's running result is reversed except running and returned
Failifrunningdecorator
You need to pass in a child node when creating this node. The child node is labeled as its own result except for the running result, and if the child node's state is running then the state of its own is identified as failed. and return
Runningiffaildecorator
You need to pass in a child node when creating this node. The child node is labeled as its own result except for the failed result, and if the child node's state is failed then the state of its own is identified as running. and return
Loopnode (Loop node)
The number of times a node queue and most loops need to be passed in when this node is created. The Loop node will attempt to execute n times after it identifies itself as success and returns the result. The running state is roughly consistent with the logic of the sequential nodes, and the running of the child nodes will prevent the next run, and the failed of the child nodes will be interrupted.
Randomnode (random node)
When you create this node, you need to pass in a node queue and a weight that can be passed without a list. In the absence of weights, all child nodes are completely random. In the case of weight, the child node chooses a node to run according to the set value of the weight, and identifies the running result of the node as its own state and returns. PS: The number of weights can be different from the number of child node lists. The number of weights will be filled with 1, and the excess will be truncated.
Parallelnode (parallel node)
When you create this node, you need to pass in a node queue. Run the child node one after another. If the state of a child node is failed, it identifies itself as failed and returns directly, and if the child node's state is success or running, then it runs the next node. Only all nodes are identified as success it will identify itself as success and return, otherwise he will identify himself as running. PS: Some nodes (Conditionnode, notdecorator) are forced to restart before they are run to determine
Parallelnodeany
Basically the same as Parallelnode, the only difference is that when any one node is identified as success, it identifies its state as success and returns
Whilenode
The extension node of the Parallelnode node, when the node is created, it is necessary to pass in a method and a child node that can get the decision value. When running to this node, you need to make a decision and then execute the node behind it. If the decision fails, it identifies itself as failed and returns. Otherwise, the state of the child node is identified as its own state and returned
Ifnode

The extension node of the Sequencenode node. and the Whilenode node basically consistent, the difference is that the condition of the decision only when the first entry into force, after the run will run directly behind the node

Lua Project Address Http://git.oschina.net/anxin1225/BehaviourTree

Description of the Lua behaviourtree nodes

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.