ecspresso
    Preparing search index...
    • Define a behavior tree with a typed blackboard.

      The blackboard value serves as both the type source and the default initial state cloned for each entity via createBehaviorTree.

      Type Parameters

      • BB extends object

      Parameters

      • id: string

        Unique identifier for this tree definition

      • config: { blackboard: BB; root: BehaviorTreeNode<BB> }

        { blackboard, root } — default blackboard + root node

      Returns BehaviorTreeDefinition<BB>

      Frozen BehaviorTreeDefinition

      const tree = defineBehaviorTree('patrol', {
      blackboard: { targetId: null as number | null, timer: 0 },
      root: selector([
      guard(ctx => ctx.blackboard.targetId !== null, action('chase', ...)),
      action('wander', ...),
      ]),
      });