Behavior Trees Library in Kotlin, with variables and expressions support.
dependencies {
implementation 'io.github.kirinhorse:kotlin-behaviors:0.0.3'
}
//@formatter:off
val root = KBTFactory.SEQ(
mutableListOf(
KBTFactory.print("Tree start ===>>>"),
KBTFactory.delay(1000),
KBTFactory.repeat(2,
KBTFactory.SEQ(mutableListOf(
KBTFactory.print("Some actions execute"),
KBTFactory.delay(500)
))
),
KBTFactory.print("Tree end <<<===")
)
)
//@formatter:on
val config = BehaviorTreeConfig(VariantsConfig(mutableMapOf()), root)
val tree = BehaviorTree(config)
runBlocking { tree.start() }
#NODE_START
SEQ{
print(text=Tree Start ===>>>)
delay(duration=1000)
repeat(times=2){
SEQ{
print(text=Some actions execute)
delay(duration=500)
}
}
print(text=Tree end <<<===)
}
#NODE_END
val script = readFile() //load text above
val tree = BTFactory.createTree(script)
runBlocking { tree.start() }