行為樹的兩種運行方式
(金慶的專欄 2017.8)
行為樹每個Tick運行有兩種實現(xiàn)方式:
* 從根節(jié)點重新開始運行
* 繼續(xù)上次運行的節(jié)點
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 是每次都從根節(jié)點運行的。這種實現(xiàn)簡單,正在運行中的行為可以自然地中止切換到其他行為。
缺點是每次運行都是遍歷整個樹,對于龐大的行為樹,性能較差。
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 實現(xiàn)為繼續(xù)當(dāng)前節(jié)點運行。
http://www.behaviac.com/concepts/
> 當(dāng)節(jié)點持續(xù)返回“運行”的時候,BT樹的內(nèi)部“知道”該節(jié)點是在持續(xù)“運行”的,從而在后續(xù)的執(zhí)行過程中“直接”繼續(xù)執(zhí)行該節(jié)點,而不需要從頭開始執(zhí)行,直到該運行狀態(tài)的節(jié)點返回“成功”或“失敗”,從而繼續(xù)后續(xù)的節(jié)點。
但是為了處理事件打斷當(dāng)前運行,需要復(fù)雜的實現(xiàn)。
> 如果發(fā)生了其他“重要”的事情需要處理怎么辦?
> 在behaviac里至少有多種辦法。
具體為:
* 前置節(jié)點
* 并行節(jié)點
* 監(jiān)測節(jié)點
* 事件子樹
(金慶的專欄 2017.8)
行為樹每個Tick運行有兩種實現(xiàn)方式:
* 從根節(jié)點重新開始運行
* 繼續(xù)上次運行的節(jié)點
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 是每次都從根節(jié)點運行的。這種實現(xiàn)簡單,正在運行中的行為可以自然地中止切換到其他行為。
缺點是每次運行都是遍歷整個樹,對于龐大的行為樹,性能較差。
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 實現(xiàn)為繼續(xù)當(dāng)前節(jié)點運行。
http://www.behaviac.com/concepts/
> 當(dāng)節(jié)點持續(xù)返回“運行”的時候,BT樹的內(nèi)部“知道”該節(jié)點是在持續(xù)“運行”的,從而在后續(xù)的執(zhí)行過程中“直接”繼續(xù)執(zhí)行該節(jié)點,而不需要從頭開始執(zhí)行,直到該運行狀態(tài)的節(jié)點返回“成功”或“失敗”,從而繼續(xù)后續(xù)的節(jié)點。
但是為了處理事件打斷當(dāng)前運行,需要復(fù)雜的實現(xiàn)。
> 如果發(fā)生了其他“重要”的事情需要處理怎么辦?
> 在behaviac里至少有多種辦法。
具體為:
* 前置節(jié)點
* 并行節(jié)點
* 監(jiān)測節(jié)點
* 事件子樹