ts-behavior-tree
A javascript/typescript behaviour tree library implementation of Fluent-Behaviour-Tree
View Documented

Table of Contents
Motivation
Although there is another js/ts library for fluent-behaviour-tree, but it uses async/promise
to accomplish.
So I rewrite based on the origin C# implement. 🎉
Feature
- Pure ES5
- Tiny (~5KB Minified)
- Full Documented
- Zero dependency
Installation
npm
npm install ts-behavior-tree
yarn
yarn add ts-behavior-tree
Scripts
This library is supported with multiple formats (UMD, ES5)
You can get release versions of these from releases page.
Usage
You can find examples from test/BehaviorTreeBuilder.test.ts.
Here is a simple usage
import { BehaviorTreeBuilder, BehaviorTreeStatus, TimeData } from 'ts-behavior-tree'
const node = new BehaviorTreeBuilder()
.Sequence('aa')
.Do('aa', () => BehaviorTreeStatus.Failure)
.End()
.Build()
console.log(node.Tick(new TimeData()) === BehaviorTreeStatus.Failure)
Development
Clone the repository
git clone git@github.com:robinxb/ts-behavior-tree.git
Use npm/yarn commands
npm t
: Run test suite
npm start
: Runs npm run build
in watch mode
npm run test:watch
: Run test suite in interactive watch mode
npm run test:prod
: Run linting and generate coverage
npm run build
: Generate bundles and typings, create docs
npm run lint
: Lints code
npm run commit
: Commit using conventional commit style (husky will tell you to use it if you haven't :wink:)
Variables
Const ErrInvNodeMoreThanOneChild
ErrInvNodeMoreThanOneChild: Error = new Error("Can't add more than a single child to InverterNode!")
Const ErrInvNodeMustHaveChild
ErrInvNodeMustHaveChild: Error = new Error(`InverterNode must have a child node!`)
Const ErrUnnestedTree
ErrUnnestedTree: Error = new Error("Can't create an unnested ActionNode, it must be a leaf node.")
Const ErrZeroNodes
ErrZeroNodes: Error = new Error("Can't create a behavior tree with zero nodes")
Const ErrorSpliceUnnested
ErrorSpliceUnnested: Error = new Error('Cannot splice an unnested sub-tree, there must be a parent-tree.')