• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

quabug/godot_behavior_tree: behavior tree module for godot game engine

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

quabug/godot_behavior_tree

开源软件地址:

https://github.com/quabug/godot_behavior_tree

开源编程语言:

C++ 99.1%

开源软件介绍:

Behavior Tree for Godot Engine

References

Understanding Behavior Trees by Alex J. Champandard

Behavior trees for AI: How they work by Chris Simpson

An Introduction to Behavior Trees by Renato Pereira

Behavior tree series by Bjoern Knafla (this series of behavior tree is really helpful, but unfortunately the original post cannot be accessed since altdev.co was dead)

Compiling as Godot module

Link or copy src directory to $(GODOT_ROOT)/modules/behaviortree, then compile engine.

Usage

After success compile godot engine with this module, you can find those new types of node in editor: BTRootNode, BTParallelNode, BTSelectorNode, BTSequenceNode, BTDecoratorNode, BTActionNode.

BTActionNode, BTDecoratorNode and BTRootNode can be extend by script for creating your own AI.

BTParallelNode, BTSelectorNode and BTSequenceNode are composite node which cannot be extend by script.

Beware that node extend by script cannot control access flow. If you need extra composite or a special decorator which can control access flow, you must write that composite or decorator in c++.

BTRootNode

Inherit: BTDecorator

Constraint: Must be placed at top of behavior tree.

  • void tick(Object context, int running_data_index) travel entire behavior tree.

  • void step(Object context, int running_data_index) just one step forward

BTDecoratorNode

Inherit: BTNode

Constraint: Only one child allowed.

  • void _bt_continue(int index, Object context) continue running if this node was running last tick
  • void _bt_prepare(int index, Object context) prepare for running if this node was not running last tick
  • E_State _bt_pre_update(int index, Object context) before run child
  • E_State _bt_post_update(int index, Object context, E_State child_state) after run child
  • void _bt_abort(int index, Object context) abort this running node

BTParallelNode

Inherit: BTCompositeNode

Execute children nodes without interruption.

BTSelectorNode

Inherit: BTCompositeNode

Always execute child from left/top to right/down. Report BH_SUCESS or BH_RUNNING to parent when a child node reported a BH_SUCCESS or BH_RUNNING, report BH_FAILURE to parent when all its children reported a BH_FAILURE.

BTSequenceNode

Inherit: BTCompositeNode

Execute child from left/top to right/down, or restart execute at last running child. Report BH_FAILURE or BH_RUNNING to parent when a child node reported a BH_FAILURE or BH_RUNNING, report BH_SUCCESS to parent when all its children reported a BH_SUCCESS.

BTActionNode

Inherit: BTNode

Constraint: Cannot have any child.

  • void _bt_continue(int index, Object context) continue running if this node was running last tick
  • void _bt_prepare(int index, Object context) prepare for running if this node was not running last tick
  • E_State _bt_update(int index, Object context) execute action
  • void _bt_abort(int index, Object context) abort this running node

TODO

  1. Extend godot editor for behavior tree.
  • Cannot add child into BTActionNode.
  • Cannot add more than one child into BTDecoratorNode and BTRootNode.
  • Constrain BTRootNode at the top of tree.
  1. Add random pick composite.
  2. Add error handler decorator.
  3. Add more parallel nodes with different report police.
  4. More composite and decorator?
  5. A specific editor view for behavior tree in godot editor.



鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap