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

pome-bt

v0.0.1

Published

pome-bt is a Behavior-Tree module for pome project to implement AI. More information about Behavior-Tree please refer other articles from Internet, such as [Understanding Behavior Trees](http://aigamedev.com/open/article/bt-overview/).

Downloads

6

Readme

#pome-bt - behavior tree for node.js

pome-bt is a Behavior-Tree module for pome project to implement AI. More information about Behavior-Tree please refer other articles from Internet, such as Understanding Behavior Trees.

  • Tags: node.js

##Installation

npm install pome-bt

##Behavior tree nodes

###Node The base class of all the behavior tree node classes. Its constructor receives a blackboard instance as parameter.

Each node class provides a doAction method to fire the behavior of current node instance. All the children should implement their own doAction. And the doAction method sould report a result code to the parent when it return. The result code is one of below:

  • RES_SUCCESS: the behavior finished successfully.
  • RES_FAIL: the behavior fails.
  • RES_WAIT: the behavior is running and should be continued in next tick. The parent node makes its decision based on the result code.

###Composite The base class of all the composite nodes. A composite node has arbitrary child nodes and it has a addChild method to add child node.

###Decorator The base class of all the decorator nodes. A decorator node has the ability to decorate the result for its child node. A decorator node has only one child node and has a setChild method to set the child node.

Followings are some behavior node types provided in pome-bt.

##Composite nodes ###Sequence Implementation of sequence semantics. ####Sequence(opts)

  • opts.blackboard - blackboard instance for the behavior node.

###Parallel Implementation of parallel semantics. ####Parallel(opts)

  • opts.blackboard - blackboard instance for the behavior node.
  • opts.policy - Failure strategy for Parallel node: Parallel.POLICY_FAIL_ON_ONE(default) return RES_FAIL if one child node fail, Parallel.POLICY_FAIL_ON_ALL return RES_FAIL only on all the child nodes fail.

###Selector Implementation of selector semantics. ####Selector(opts)

  • opts.blackboard - blackboard instance for the behavior node.

###Decorator nodes ###Loop Implementation of loop semantics. ####Loop(opts)

  • opts.blackboard - blackboard instance for the behavior node.
  • opts.child - child node for the decorator node。
  • opts.loopCond(blackboard) - loop condition function. return true to continue the loop and false to break the loop.

###Condition Return RES_SUCESS if the condition is true otherwise return RES_FAIL. ####Condition(opts)

  • opts.blackboard - blackboard instance for the behavior node.
  • opts.cond(blackboard) - condition function, return true or false.

##Other nodes ###If Implementation of loop semantics. If the condition is true, then fire the child node. ####If(opts)

  • opts.blackboard - blackboard instance for the behavior node.
  • opts.action - child node.
  • opts.cond(blackboard) - condition function, return true or false.

##Usage

var util = require('util');
var bt = require('pome-bt');
var Sequence = bt.Sequence;
var Node = bt.Node;

// define some action nodes
var HelloNode = function(blackboard) {
  Node.call(this, blackboard);
};
util.inherits(HelloNode, Node);

HelloNode.prototype.doAction = function() {
  console.log('Hello ');
  return bt.RES_SUCCESS;
};


var WorldNode = function(blackboard) {
  Node.call(this, blackboard);
};
util.inherits(WorldNode, Node);

WorldNode.prototype.doAction = function() {
  console.log('World');
  return bt.RES_SUCCESS;
};

var blackboard = {};

// composite your behavior tree
var seq = new Sequence({blackboard: blackboard});
var hello = new HelloNode(blackboard);
var world = new WorldNode(blackboard);

seq.addChild(hello);
seq.addChild(world);

// run the behavior tree
seq.doAction();