行为树的两种运行方式

行为树的两种运行方式

(金庆的专栏 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里至少有多种办法。

具体为:

  • 前置节点
  • 并行节点
  • 监测节点
  • 事件子树
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值