magicsea / behavior3go Goto Github PK
View Code? Open in Web Editor NEWgolang behavior tree,from https://github.com/behavior3
golang behavior tree,from https://github.com/behavior3
如果行为动作节点切换频繁是否会出现共享黑板内存数据读写安全问题
请问下,这个项目是遵循MIT License的吗?仓库里没有看到LICENSE的相关说明。
Repeater,RepeatUntilFailure,RepeatUntilSuccess支持-1无限循环的,但是在Initialize的时候,maxloop直接就panic了
子树包含running状态,同时复用了子树会导致两个子树的runing状态冲突。
我们想在项目中使用该行为树框架,由于涉及到授权问题,请问是否有打算添加一个license?
看代码逻辑RepeatUntilSuccess节点的MaxLoop如果为-1, 那么就是一直循环直到Success
但是RepeatUntilSuccess的初始化代理里有判断maxLoop不能小于1
这里应该不需要这样的判断吧?
func (this *RepeatUntilSuccess) Initialize(setting *BTNodeCfg) {
this.Decorator.Initialize(setting)
this.maxLoop = setting.GetPropertyAsInt("maxLoop")
if this.maxLoop < 1 {
panic("maxLoop parameter in MaxTime decorator is an obligatory parameter")
}
}
我想通过Blackboard 来保存失败的信息
type Memory struct {
_memory map[string]interface{}
}
func NewMemory() *Memory {
return &Memory{make(map[string]interface{})}
}
func (this *Memory) Get(key string) interface{} {
return this._memory[key]
}
func (this *Memory) Set(key string, val interface{}) {
this._memory[key] = val
}
需要的话, 我可以pr一个
之前运行过这个桌面版编辑器,没问题。后来不知道怎么操作,打开后一直显示”Starting Application ... Have Fun”卡住不动。直接打开网页版也是如此,想请教是什么原因?
选择了不是每次都从root开始执行行为树,每次都从running的节点开始出现下面的问题?
如何返回值是running,但是下一帧出现了更高的条件,但是running还没有结束,如何去打断这个running,让更高有优先级的去执行呢?
在行为树黑板中Set一个map,然后后面程序去修改map中的值,但是不往黑板中设置,然后接着在行为树中去Get黑板中的值,此时获取的map
是程序修改之后的值。
map
集合mp:=make(map[int]int)
map
集合赋值mp[0]=1
mp[1]=2
mp[2]=3
tick.Blackboard.Set(key.NowLockAddrs, mp, "", "")
map
集合中添加或者删除修改值。mp[3]=4
getValue := tick.Blackboard.Get(key.NowLockAddrs, event.BlackboardScopeScu, "")
mp := getValue.(map[int]int)
fmt.Println(mp)
[0:1,1:2,2:3,3:4]
修改完map
之后,没有将修改之后的值Set
到黑板中,但是在Get
黑板中该键对应的值的时候获取到修改后的map
。
对map集合和切片这种数据设置到黑板中之后,如果在从黑板中Get的数据之前,对该map进行增删改的操作,在从黑板中Get的值仍是在黑板中Set的值,而不是修改map中的值之后不在黑板中Set也能获取到map修改后的值。
A调用B1,B2,B1,B2因为是相同的节点名,会互相覆盖相同节点的黑板值。
计划在初始化时候,展开所有子树,同事改子树的所有节点ID,然后生成的A就是一个完全展开的A大树,运行时没有子树的概念
Tick的创建非常频繁,建议NewTick中使用对象池
func (this *BehaviorTree) Tick(target interface{}, blackboard *Blackboard) b3.Status {
if blackboard == nil {
panic("The blackboard parameter is obligatory and must be an instance of b3.Blackboard")
}
/* CREATE A TICK OBJECT */
var tick = NewTick() //每次tick即调用一次NewTick()
tick.debug = this.debug
tick.target = target
tick.Blackboard = blackboard
tick.tree = this
/* TICK NODE */
var state = this.root._execute(tick)
/* CLOSE NODES FROM LAST TICK, IF NEEDED */
var lastOpenNodes = blackboard._getTreeData(this.id).OpenNodes
var currOpenNodes []IBaseNode
currOpenNodes = append(currOpenNodes, tick._openNodes...)
// does not close if it is still open in this tick
var start = 0
for i := 0; i < b3.MinInt(len(lastOpenNodes), len(currOpenNodes)); i++ {
start = i + 1
if lastOpenNodes[i] != currOpenNodes[i] {
break
}
}
// close the nodes
for i := len(lastOpenNodes) - 1; i >= start; i-- {
lastOpenNodes[i]._close(tick)
}
/* POPULATE BLACKBOARD */
blackboard._getTreeData(this.id).OpenNodes = currOpenNodes
blackboard.SetTree("nodeCount", tick._nodeCount, this.id)
return state
}
func NewTick() *Tick {
tick := &Tick{} //此处建议用pool
tick.Initialize()
return tick
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.