1
\$\begingroup\$

Assume I have a behaviour tree like the following:

    [A]
   / | \
[B] [C] [D]
  • A = Selector (Priority node)
  • B = Perception task
  • C = Idle task
  • D = Walk to point task

The reason the tree looks like this is because B has priority over C and D since it should trigger alert procedures. In short, what I'm trying to model here is that the Agent sensors must have priority over behaviours.

Assume now the agent is in D and this node will continue returning running until the destination point is reached.

While D is running, something might happen (for instance, the NPC see or hear something) that should break the current operation as soon as possible but, D will go on regardless until it's done.

I know I could paste the sensors code on top of each tree leaf, like for example:

// kinda javaish pseudo code
void run() {
    // The node running method
    if (this.sensors.alert()) {
        return this.fail();
    }

    // Else, keep going.
    if (! this.reachedGoal()) {
        // do the walking
        return this.running();
    }

    return this.success();
}

But with that solution the "alert" behaviour is hard coded and out of the tree logic.

What solution do you suggest?

\$\endgroup\$
3
  • \$\begingroup\$ Are you using some library or framework for the implementation of the BT? Are you building your own BTs? \$\endgroup\$
    – Leo
    Commented Mar 6, 2018 at 15:29
  • \$\begingroup\$ I was using an external library. I think i ended up coding a custom composite node type with the purpose of intercepting each tick and running the appropriate sensors \$\endgroup\$
    – brazorf
    Commented Mar 7, 2018 at 9:30
  • \$\begingroup\$ I added a behavior-tree tag :) I agree, I found it strange too. \$\endgroup\$
    – SashaZd
    Commented Nov 11, 2019 at 19:26

0

You must log in to answer this question.

Browse other questions tagged .