behavior3 / behavior3js

Behavior3 client library for Javascript (Behavior Trees for Javascript)
MIT License
405 stars 105 forks source link

decorator limiter would not limiter the time between two tick from tree #25

Open linhaiwei123 opened 7 years ago

linhaiwei123 commented 7 years ago

the tree is as below image

and i do enter the limiter but when i tick the tree in the update again the time of the limiter would reset to zero again.

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/43195168-decorator-limiter-would-not-limiter-the-time-between-two-tick-from-tree?utm_campaign=plugin&utm_content=tracker%2F18331363&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F18331363&utm_medium=issues&utm_source=github).
linhaiwei123 commented 7 years ago

i found the bug here. in limiter we should return the b3.RUNNING instead of b3.SUCCESS or b3.FAILURE cause the b3.SUCCESS or b3.FAILURE would exit the running state and reset the time in open when we tick again

linhaiwei123 commented 7 years ago

yep i found that return b3.RUNNING in limiter still not work well. the only way to fix it is to check whether the key i is set or not. and set it in the first time we enter the open callback

danielepolencic commented 7 years ago

@linhaiwei123 would you be able to submit a PR with the failing test or a simple way to reproduce the bug?

wqhk commented 7 years ago

open: function(tick) { tick.blackboard.set('i', 0, tick.tree.id, this.id); }, The Decorator of Limiter will reset "i" to zero when child status == b3.SUCCESS || status == b3.FAILURE。 +1 ,reset 0, +1 ,reset 0……

danielepolencic commented 7 years ago

@wqhk would you be able to submit a PR with a failing test?

wqhk commented 7 years ago

@danielepolencic I submit a PR. Learn BT this week, maybe misunderstand the usage of Limiter =。=