行为树
参考网址:
(128条消息) 行为树(Behavior trees)_念去去~的博客-CSDN博客_行为树
(128条消息) 状态机和行为树_PresleyGo的博客-CSDN博客_行为树和状态机区别
(128条消息) 行为树概念_白霞的博客-CSDN博客_行为树
devildevilson/tiny_behaviour: Behaviour tree header only library (github.com)
BehaviorTree/BehaviorTree.CPP: Behavior Trees Library in C++. Batteries included. (github.com)
基础定义
Tree nodes description
BehaviorTreeBuilder class methods:
Compositor nodes:
1 | `sequence()` - updates all nodes until faces `Status::Failure` or `Status::Running` |
Binary nodes:
(Status::Success is true, Status::Failure is false)conjunction() - Status first && Status seconddisjunction() - Status first || Status secondequality() - Status first == Status secondimplication() - Status first -> Status second (!(Status first) || Status second) (Status::Running = Status::Failure)ifelse(predicate) - if contidion == true updates first, else second
Decorator nodes:
1 | inverter()` - inverts `Status::Success` and `Status::Failure`, `Status::Running` ignored |
Special nodes:
action(action) - userdefined action function, must return statuses
Other methods:
end() - use it after every Compositor or Binary nodesadd(node) - adds nodes to the current tree, NOTE: adding trees is under constructionleaf(arguments) - create userdefined action node build() - does some postworks and returns BehaviorTree pointerdebug(string) - just prints the stringsetDebugCallback(callback) - set callback function for the error strings
子树命名规则
| name | default | |
|---|---|---|
| input | tree_[tree_name]in[action_name]_[value_name] | {tree_[tree_name]in[action_name]_[value_name]} |
| output | tree_[tree_name]out[action_name]_[value_name] | tree_[tree_name]out[action_name]_[value_name] |
节点变量
| name | default | |
|---|---|---|
| input | action_[action_name]in[action_name]_[value_name] | {action_[up_tree_name]in[action_name]_[value_name]} |
| output | action_[action_name]out[action_name]_[value_name] | {action_[up_tree_name]out[action_name]_[value_name]} |
条件变量
| name | default | |
|---|---|---|
| input | condition_[action_name]in[condition_name]_[value_name] | {action_[up_tree_name]in[condition_name]_[value_name]} |
| output | condition_[action_name]out[condition_name]_[value_name] | {action_[up_tree_name]out[condition_name]_[value_name]} |
子树/节点/条件的命名规则
| name | name optional | name optional | |
|---|---|---|---|
| 子树 | Subtree_[tree name] | ||
| 节点 | Action_[action name]_Output | Action_[action name]_Input | ActionBase_[action name] |
| 条件 | Condition_[condition name] |
相关注意事项
- 同级子树,多个set对应一个get,以get所在变量名定义default.
- 同级子树,多个get对应一个set,以set所在变量名定义default.
- 同级子树,以default链接set与get时候,不需要加{}.
- 上级子树,以default链接set与get时候,需要加{}.
