import { BehaviorTree, Sequence, Selector, Task, SUCCESS, FAILURE, RUNNING } from 'behaviortree'
let count = 0;
const blackboard = {};
BehaviorTree.register('000', new Task({
run: function (blackboard ) {
console.log('000')
if (count <= 3) {
return FAILURE
} else {
return SUCCESS
}
}
}))
BehaviorTree.register('111', new Task({
run: function (blackboard ) {
console.log('111')
return RUNNING
}
}))
const tree = new Selector({nodes: [
'000',
'111',
]})
const bTree = new BehaviorTree({
tree: tree,
blackboard: blackboard
})
function step() {
bTree.step()
console.log('-----------------------------')
count++;
if (count < 10) setTimeout(step, 1000);
}
step();
Hello, I think the current
Selectorwill remember the last RUNNING node, and in next tick running directly start from it, ignoring any siblings in front of it, even the sibling at font will return SUCCESS now, right?Test codes:
Output:
I want to ask that, is there a non-remember
Selector, which check all children from first until fail one every tick?Expected output: