Behaviour tree composites

This commit is contained in:
2024-01-09 20:53:21 +01:00
parent d7feba04db
commit e4cc00d3a7
2 changed files with 184 additions and 79 deletions

View File

@@ -8,7 +8,7 @@ BzAIBTNode *printBT = NULL;
BzAIBTStatus printAction(void *data) {
bzLogInfo("Hello, world!");
return BZ_AIBT_FAIL;
return BZ_AIBT_SUCCESS;
}
bool init(int *game) {
@@ -20,12 +20,16 @@ bool init(int *game) {
});
// for 1..5:
// delay 1s
// print "Hello, world!"
// seq
// delay 1s
// print "Hello, world!"
printBT = bzAIBTMakeRoot(nodePool);
BzAIBTNode *node = bzAIBTDecorRepeat(nodePool, printBT, 5);
node = bzAIBTDecorDelay(nodePool, node, 1.0f);
bzAIBTAction(nodePool, node, printAction);
BzAIBTNode *seq = bzAIBTCompSequence(nodePool, node, false);
bzAIBTDecorDelay(nodePool, seq, 1.0f);
bzAIBTAction(nodePool, seq, printAction);
BzAIBTState state = bzAIBTCreateState(&(BzAIBTStateDesc) {
.root = printBT,
@@ -39,6 +43,7 @@ bool init(int *game) {
while (status == BZ_AIBT_RUNNING) {
status = bzAIBTExecute(&state, 0.2f);
count++;
assert(status != BZ_AIBT_ERROR);
}
bzLogInfo("Iter: %d", count);