2
\$\begingroup\$

Example tree (Source): Example behaviour tree

As far as I understood, a sequencer iterates over the children until one failed or all are successful. If one children returns "running", the sequencer will start to process from that child on the next tick.

Let's say "Do I have food?" takes longer than one tick because the AI has to walk to the fridge. When "Am I Hungry" was successful, it won't be processed anymore. Now while walking to the fridge, the hunger magically disappears. How do I prevent the tree from processing the other nodes even though I am not hungry anymore? Should every following node check the condition again? That doesn't seem to fit the idea of a behaviour tree.

How do I implement a condition that has to stay true while following nodes are processed?

\$\endgroup\$
2

1 Answer 1

1
\$\begingroup\$

Found an answer here.

I thought a behaviour tree should start at the last running node to start computation time but that lead to the problem stated in the article.

Treating Running States

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.

The major drawback of starting the tick at the node that returned the running state is that this node can take too much time running an action and, thus, avoiding the execution of most important behaviors. For instance, suppose a robot performing an action to follow a certain path; in the half way the robot finds a hole, but it cannot avoid it because the tree is running the action of path following.

Therefore, the best option is always start over the tree, and if a most-important behavior wants to run, the previous node stops.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .