Skip to content

Idered/behavior-tree

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Behavior Tree Toolkit

  • 🌲 @btree/core - Framework agnostic behavior trees implementation
  • âš› @btree/react - Hooks and docs how to use BT with React

Quick start

Check docs to learn the API.

npm install @btree/core
import {nodes, tick} from '@btree/core'

const state = {
  isLoggedIn: false
}

const tree = nodes.root<typeof state>('App behavior', () =>
  nodes.selector([
    nodes.sequence([
      nodes.conditional((state) => state.isLoggedIn)
      nodes.action('Redirect to dashboard', () => {
        navigate('/dashboard')
      }),
    ]),
    nodes.sequence([
      nodes.action('Redirect to login page', () => {
        navigate('/login')
      }),
    ]),
  ])
)

tick(tree, state)

Authors

About

🌲 Manage React state with Behavior Trees

Topics

Resources

License

Stars

Watchers

Forks

Contributors 2

  •  
  •