Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

behavior-engine

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

behavior-engine

  • 1.0.1
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
2
Maintainers
1
Weekly downloads
 
Created
Source

Blueshell

Blueshell is a Behavior Tree implementation written in Typescript.

It is synchronous for performance - asynchronous operations can be handled by returning async operations to your framework for evaluation, these can then generate new events to drive the behavior tree.

Circle CI

Node Types

Actions (aka Tasks or Execution Nodes) 叶子节点

Action 行为节点
  • Handles the event normally and must return a result
  • 正常地处理事件,必定会返回一个值
Predicate 断言节点
  • Executes a provided synchronous function ((state, event) => boolean) and returns SUCCESS or FAILURE based upon the boolean result of such function.
  • 执行一个同步函数,基于这个函数的结果返回SUCCESS or FAILURE
SideEffect 副作用节点
  • Executes a provided synchronous function ((state, event) => void) and always returns SUCCESS.
  • 执行一个同步函数,必定返回SUCCESS
Success 成功节点
  • Immediately returns SUCCESS when activated.
  • 必定返回成功 SUCCESS

Composites (aka Control Flow Nodes) 复合节点

Selector 选择节点

(aka Priority or Fallback)

  • Sends an event to each child until one of them returns SUCCESS or RUNNING, then returns that value.
  • If we exhaust all the children, return FAILURE.
  1. 发送一个事件给所有子节点,直到某个节点返回 SUCCESSRUNNING,此节点返回这个值
  2. 如果子节点都没有发生,则返回 FAILURE
LatchedSelector 监督节点
  • Sends an event to each child until one of them returns SUCCESS or RUNNING, then returns that value.
  • If we exhaust all the children, return FAILURE.
  • If a child returns RUNNING, subsequent events start at that child.
  1. 发送一个事件给所有子节点,直到某个节点返回 SUCCESSRUNNING,此节点返回这个值
  2. 如果子节点都没有发生,则返回 FAILURE
  3. 如果一个节点返回 RUNNING,则会等待该节点的子节点返回。
Sequence 顺序节点
  • Sends an event to each child until one of the returns FAILURE, or RUNNING, then returns that value.
  • If all children return SUCCESS, return SUCCESS.
  1. 发送一个事件给所有子节点,直到某个节点返回 FAILURERUNNING,此节点返回这个值
  2. 如果所有的子节点返回 SUCCESS,才返回 SUCCESS
LatchedSequence 监督顺序节点
  • Sends an event to each child until one of the returns FAILURE, or RUNNING, then returns that value.
  • If all children return SUCCESS, return SUCCESS.
  • If a child returns RUNNING, subsequent events start at that child.
  1. 发送一个事件给所有子节点,直到某个节点返回 FAILURERUNNING,此节点返回这个值
  2. 如果所有的子节点返回 SUCCESS,才返回 SUCCESS
  3. 如果一个节点返回 RUNNING,则会等待该节点的子节点返回。
IfElse 分支节点
  • Accepts a conditional function a consequent node, and an optional alternative node.
  • If conditional(state, event) returns true, will return the result of activating the consequent node.
  • If conditional(state, event) returns false, will return the result of activating the alternative node, if one is provided.
  • If conditional(state, event) returns false, will return FAILURE if no alternative node is provided.

Decorators

Decorators intercept and can modify the event sent to or the result from the child.

Not 取反装饰
  • Returns 'FAILURE' when the child returns 'SUCCESS', and vice-versa
RepeatWhen 重复装饰
  • Repeats the child when an evaluation function returns true.
RepeatOnResult
  • Repeats the child if it returns the specified status.
ResultSwap 结果修改装饰
  • Allows you to swap one result of a child node for another.
  • For example, you can use this to mask FAILURE as SUCCESS.

Base Classes

Base
  • The base of all nodes.
Composite
  • The base class for all nodes which have children.
Decorator
  • The base class for decorators.
  • Can only have one child.

Publishing

  • The publisher can be registered with the tree which will log each transition.

Inspiration and Further Reading

The following are sources used when designing this library

Name

Blueshell is named for a Skroderider from the novel A Fire Upon the Deep by Vernor Vinge. Skroderiders are intelligent plants (trees) that use mechanical constructs to give them locomotion and short-term memory.

In other words, Blueshell is an intelligent tree. Or a tree with behavior. Get it?

Keywords

FAQs

Package last updated on 30 Jan 2022

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc