Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
#pomelo-bt - behavior tree for node.js pomelo-bt是pomelo项目中AI模块所依赖的行为树模块,提供了基本的行为树实现。
##安装
npm install pomelo-bt
##行为树节点基类 ###节点基类 Node 所有行为树节点都从该类派生,构造函数接受一个blackboard实例作为参数。 每个节点都提供一个执行的入口doAction方法。doAction执行完完毕后,向父节点返回执行结果: RES_SUCCESS, RES_FAIL, RES_WAIT分别代表当前执行成功,失败和仍在执行中。 父节点根据子节点的返回值再做后续流程决策。
###组合节点基类 Composite 所有组合节点都从该类派生,内部可以维护多个孩子节点。提供addChild接口,添加孩子节点。
###装饰节点基类 Decorator 所有装饰节点都从该类派生,提供setChild接口,添加唯一的孩子节点。
##组合节点 ###Sequence 实现行为树sequence语义。 ####构造函数Sequenec(opts)
###Parallel 实现行为树parallel语义。 ####构造函数Parallel(opts)
###Selector 实现行为树selector语义。 ####构造函数Selector(opts)
##装饰节点 ###Loop 循环节点。 ####构造函数Loop(opts)
##条件节点 ###Condition 条件成立返回RES_SUCCESS, 反之返回RES_FAIL。 ####构造函数Condition(opts)
##其他节点 ###If 实现if语义,如果条件成立,则执行关联的孩子节点。 ####构造函数If(opts)
##用法
var util = require('util');
var bt = require('pomelo-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();
FAQs
pomelo-bt是pomelo项目中AI模块所依赖的行为树模块,提供了基本的行为树实现。
We found that pomelo-bt demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.