npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

async-behavior-tree

v0.7.2

Published

Behavior Tree library focusing on async functions

Downloads

6

Readme

Build Status npm version

AsyncBehaviorTree

My attempt to bring Behavior Trees to js with support for a visual editor. This project was reverse engineered around the open source tool Groot. This Groot tool was designed to output trees for BehaviorTree.CPP. Note that this library is meant as a js port of BehaviorTree without being a direct port. Many features supported by BehaviorTree.CPP are not supported by this library. (I didn't look at the source code of BehaviorTree.CPP at all when developing this library).

Example

This is a screenshot of Groot with a logfile that was written to disk during one of the unit tests.

Basics

Create an xml tree file with Groot. Bind to a "Blackboard" object during instantiation of the class in js. Execute the tree.

Blackboard

The blackboard stores both variables and functions. If the functions are async they are executed as such. Access blackboard variables with ${} notation, similar to the notation in template literals https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals.

By default, functions expect a single argument which is a object with keys. The Groot tool allows the setting and retreiving of these keys.

Functions can be called with normal arguments. To do this name the inputs like _in_0 and _in_1 in the Groot Action notes.

Note Type Support

This app suports a subset of node that Groot supports. As of today I'm not sure how to make "reactive" node types work. For this reason I've skipped them.

Internals

exe is a member which has the tree. Each tree node can have a member called seq which is an array of children. Each tree node has a member called path which is a dot notation of numbers. path skips the root node, however in most (all?) trees the first node is a nesting type (sqeuence, fallback, invert) etc. Thus the first element of the path will always be 0.

Log Details

If a fallback has 2 failures and a success under it. The nodes will stay marked as such. Once the final fallback has completed. The log will "go back" and mark the nodes from "failure" to "idle". The success will be marked from "success" to "idle". This "dims" the entire subtree. Then the Fallback will be marked success. I don't copy this behavior very well atm.

Log Playback

Because the log file-format is so complex, I opted to wrap part of actual BehaviorTree.CPP in WASM, and then call the internals to get log files. This is optional as running WASM can be complicated. If you don't need logs you can skip reading this. See setFileLogger()

Rules