Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualEnder1618

Posted 25 September 2012 - 09:36 PM

So I am back to trying to understand how to use behavior trees for my AI decision making. So right now I am looking at BTs from the perspective of Alex's presentation on second generation behavior trees on AiGameDev. Although i am not going to implement a second generation tree just yet. From my understanding a second gen tree implementation is just an optimization of a first gen tree, where the node layout is identical just traversal is optimized.

So lets start simple with a first gen tree, from what I understand the tree is ticked from the root every think cycle. Sequences and selectors maintain a memory of the current child they left off on since the last tick, and when hitting that sequence or selector again we just continue with the evaluation of that child subtree until it succeeds or fails. After something like a sequence or selector has succeeded or failed the current child node indicator is reset to point at the first child again.

So a tree like this is problematic:
selector
--sequence
----Cond(Health low)
----SubTree(Flee)
--sequence
----Cond(Has target)
----SubTree(Attack)
--Subtree(Idle)
Here the conditions would be checked only once when entering the sequence, so we could not react to changes unless the subtree failed (e.g. attack). For example if we entered the first sequence, checked the condition (which at the time was true), the entered the Flee subtree, that condition would not be checked again until we either succeeded or failed that subtree (which would only have the condition checked once we re-entered the parent sequence later on).

Another way to approach this would be something like this?:
selector
--parallel
----[Not]Cond(Health low)
----[Not]Cond(Has Target)
----SubTree(Idle)
--parallel
----Cond(Health low)
----[Not]Cond(Has Target)
----SubTree(Flee)
--parallel
----[Not]Cond(Health low)
----Cond(Has Target)
----SubTree(Attack)

This seems horribly convoluted, and would get even more complicated for more subtrees i might need to bail out of in this subtree selection.

I heard something about ActiveSelectors being able to always take the highest priority subtree that continually checked conditions will allow, but I am a bit confused on how this wold be implemented (sequence and selectors seem pretty straight forward in their implementations).

Anyone have any insights?

#2Ender1618

Posted 25 September 2012 - 08:01 PM

So I am back to trying to understand how to use behavior trees for my AI decision making. So right now I am looking at BTs from the perspective of Alex's presentation on second generation behavior trees on AiGameDev. Although i am not going to implement a second generation tree just yet. From my understanding a second gen tree implementation is just an optimization of a first gen tree, where the node layout is identical just traversal is optimized.

So lets start simple with a first gen tree, from what I understand the tree is ticked from the root every think cycle. Sequences and selectors maintain a memory of the current child they left off on since the last tick, and when hitting that sequence or selector again we just continue with the evaluation of that child subtree until it succeeds or fails. After something like a sequence or selector has succeeded or failed the current child node indicator is reset to point at the first child again.

So a tree like this is problematic:
selector
--sequence
----Cond(Health low)
----SubTree(Flee)
--sequence
----Cond(Has target)
----SubTree(Attack)
--Subtree(Idle)
Here the conditions would be checked only once when entering the sequence, so we could not react to changes unless the subtree failed (e.g. attack).

Another way to approach this would be something like this?:
selector
--parallel
----[Not]Cond(Health low)
----[Not]Cond(Has Target)
----SubTree(Idle)
--parallel
----Cond(Health low)
----[Not]Cond(Has Target)
----SubTree(Flee)
--parallel
----[Not]Cond(Health low)
----Cond(Has Target)
----SubTree(Attack)

This seems horribly convoluted, and would get even more complicated for more subtrees i might need to bail out of in this subtree selection.

I heard something about ActiveSelectors being able to always take the highest priority subtree that continually checked conditions will allow, but I am a bit confused on how this wold be implemented (sequence and selectors seem pretty straight forward in their implementations).

Anyone have any insights?

#1Ender1618

Posted 25 September 2012 - 07:56 PM

So I am back to trying to understand how to use behavior trees for my AI decision making. So right now I am looking at BTs from the perspective of Alex's presentation on second generation behavior trees on AiGameDev. Although i am not going to implement a second generation tree just yet. From my understanding a second gen tree implementation is just an optimization of a first gen tree, where the node layout is identical just traversal is optimized.

So lets start simple with a first gen tree, from what I understand the tree is ticked from the root every think cycle. Sequences and selectors maintain a memory of the current child they left off on since the last tick, and when hitting that sequence or selector again we just continue with the evaluation of that child subtree until it succeeds or fails.

So a tree like this is problematic:
selector
--sequence
----Cond(Health low)
----SubTree(Flee)
--sequence
----Cond(Has target)
----SubTree(Attack)
--Subtree(Idle)
Here the conditions would be checked only once when entering the sequence, so we could not react to changes unless the subtree failed (e.g. attack).

Another way to approach this would be something like this?:
selector
--parallel
----[Not]Cond(Health low)
----[Not]Cond(Has Target)
----SubTree(Idle)
--parallel
----Cond(Health low)
----[Not]Cond(Has Target)
----SubTree(Flee)
--parallel
----[Not]Cond(Health low)
----Cond(Has Target)
----SubTree(Attack)

This seems horribly convoluted, and would get even more complicated for more subtrees i might need to bail out of in this subtree selection.

I heard something about ActiveSelectors being able to always take the highest priority subtree that continually checked conditions will allow, but I am a bit confused on how this wold be implemented (sequence and selectors seem pretty straight forward in their implementations).

Anyone have any insights?

PARTNERS