金庆的专栏

  C++博客 :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理 ::
  355 随笔 :: 0 文章 :: 454 评论 :: 0 Trackbacks
行为树的两种运行方式

(金庆的专栏 2017.8)

行为树每个Tick运行有两种实现方式:
* 从根节点重新开始运行
* 继续上次运行的节点

http://blog.renatopp.com/2014/08/15/an-introduction-to-behavior-trees-part-3/

> One common question when implementing a Behavior Tree is that: what to do in the next tick after a node returned a running state? There are two answer to it: starting the graph traversal from the running node or starting it over from the first node.

Behavior3 是每次都从根节点运行的。这种实现简单,正在运行中的行为可以自然地中止切换到其他行为。

缺点是每次运行都是遍历整个树,对于庞大的行为树,性能较差。

http://www.gamasutra.com/blogs/ChrisSimpson/20140717/221339/Behavior_trees_for_AI_How_they_work.php

> In the basic implementation of behaviour trees, the system will traverse down from the root of the tree every single frame, testing each node down the tree to see which is active, rechecking any nodes along the way, until it reaches the currently active node to tick it again.

> This isn’t a very efficient way to do things, especially when the behaviour tree gets deeper as its developed and expanded during development. I’d say its a must that any behaviour tree you implement should store any currently processing nodes so they can be ticked directly within the behaviour tree engine rather than per tick traversal of the entire tree.

Behaviac 实现为继续当前节点运行。

http://www.behaviac.com/concepts/

> 当节点持续返回“运行”的时候,BT树的内部“知道”该节点是在持续“运行”的,从而在后续的执行过程中“直接”继续执行该节点,而不需要从头开始执行,直到该运行状态的节点返回“成功”或“失败”,从而继续后续的节点。

但是为了处理事件打断当前运行,需要复杂的实现。

> 如果发生了其他“重要”的事情需要处理怎么办?
> 在behaviac里至少有多种办法。

具体为:

* 前置节点
* 并行节点
* 监测节点
* 事件子树

posted on 2017-08-26 12:45 金庆 阅读(304) 评论(0)  编辑 收藏 引用

只有注册用户登录后才能发表评论。
【推荐】超50万行VC++源码: 大型组态工控、电力仿真CAD与GIS源码库
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理