behavior3 / behavior3js

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

about Tick._openNodes #31

Open jcmiao opened 7 years ago

jcmiao commented 7 years ago

When I define parallel nodes, tick._openNodes and lastOpenNodes have some problems (my english is poor)

var start = 0;
var i;
for (i = 0; i < Math.min(lastOpenNodes.length, currOpenNodes.length); i++) {
  start = i + 1;
  if (lastOpenNodes[i] !== currOpenNodes[i]) {
    break;
  }
}

There are problems with this comparison

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/49365994-about-tick-_opennodes?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).
jcmiao commented 7 years ago

i use a map to save current opennodes as bellow: for i, v := range lastOpenNodes { if !map.find(key(v)) { v._close(tick) } }

jcmiao commented 7 years ago

It's going to make the node that I opened this time will be closed. Perhaps because of the parallel node I joined, the tree has multiple running branches, which makes the last time and current opennodes compare