Socket
Socket
Sign inDemoInstall

behaviortree-sexp

Package Overview
Dependencies
208
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    behaviortree-sexp

A S-expression parser for behaviortree behaviour trees.


Version published
Maintainers
1
Created

Readme

Source

js-standard-style

behaviortree-sexp

Parses S-expressions to create ready-to-go behaviourtree behaviour trees.

background

This module's purpose may not be obvious if you aren't already familiar with both Behaviour Trees and the behaviourtree module.

Behaviour trees are a flexible tool for, amongst other things, video game AI. For some reading on the subject, try Tamas Jano's introduction.

In particular, this module allows you to specify behaviour trees as ubiquitous S-expressions, which are then transformed into BehaviorTree objects fully compatible with behaviourtree.

example

var btree = require('behaviortree')
var btree_sexp = require('behaviortree_sexp')

var expr = '(sequence (beep) (beep))'

btree.register('beep', new btree.Task({
  run: function(obj) {
    console.log('beep')
    this.success()
  }
}))

var tree = btsexp(expr)

tree.step()

outputs

beep
beep

built-in nodes

succeed

Always returns success.

(succeed)

invert

Makes its successful node fail and its failed node succeed.

(invert (succeed))

sequence

Processes nodes in sequence. Succeeds only if all nodes succeed. Equivalent to logical AND.

(sequence (succeed) (invert succeed) (succeed))

This will only run the first two nodes.

selector

Processes nodes in sequence. Succeeds and returns immediately as soon as one node succeeds. Equivalent to logical OR.

(selector (invert succeed) (succeed) (succeed))

This will only run the first two nodes.

random

Chooses a node at random.

(random (beep) (boop))

This will run exactly one of beep or boop.

your own!

You can register your own nodes via btree.register(name, task) which will then be available automatically in your S-expressions. See the above example.

contribute

Please do! File an issue or pull request. Stay consistent with the standard.

license

MIT

FAQs

Last updated on 26 Apr 2015

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc