-
Notifications
You must be signed in to change notification settings - Fork 264
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to handle Multiple Trees #8
Comments
For one of our projects we had to modify behavior3js and behavior3editor just slightly to achieve this. If you're interested I'll provide you with the modified projects. I just don't know if the modifications still work with the latest versions. |
@Talisca, thanks for the reply. Did you use something like that BehaviorCollection? Sure, I would like to see these modifications. |
First of all, sorry for my late response. I pushed my modifications long ago, but never got to the point to write a text. The repositories can be found in my profile. @renatopp Your mentioned problem of damaging states in the blackboard caused by multiple usage of trees is not handled in my pushed modification. I use the following solution in our project:
In our case we won't have a recursion anywhere (I just can't think of a case where this would be helpful). We use some tree's more then once in another tree. Here the saved states could be easily damaged without my modification above. Another solution......I could think of, is the usage of an id-stack which is used to get the actual id for a tree/node. In _execute, I would push the tree-id to this stack with an incremental number indicating the current iteration step, e. g.
Somewhere at the end of each _execute-call, the id is removed and iteration is decremented. Regarding recursionsI think there could be two favored behaviors.
The second part would be easily solved with the above idStack-solution. The first part expects the same id with every call. Could lead to an additional flag in the editor to determine which is desirable. I don't know. Singleton tree'sThere could be cases where we would like to use different properties for each sub-tree of the same kind. This essential information would be lost if we just use one instance of a tree. So this could come into play with the point above. I don't know. |
This thread discuss how to handle multiple trees in the editor and the client libraries.
Motivation
You can use multiple trees in some different ways:
Given that you may use the same subtree several times and the case where you use the trees recursively, I want to create a single object instance for each tree.
So, I'm thinking in something like that:
and then you use the trees as usual.
Editor
If we follow this behavior collection thing we:
Client
In the client libraries we can create an empty BehaviorTree for each tree in the JSON, and then create their nodes (we can't create nodes together with the trees because nodes can have reference some tree).
Moreover, we need to update how
BehaviorTree.tick
method works, maybe breaking it in several internal methods. To understand that, consider the following situation:The same would occur if the CombatTree were referred by SoldierTree and CommanderTree.
So, before calling the subtree, we need to change temporarily its ID.
I'm not sure if this issue is barely understandable by anyone but me. I've been thinking a lot about this feature lately, so the description may lack some more contextualization.
--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/27127836-how-to-handle-multiple-trees?utm_campaign=plugin&utm_content=tracker%2F18331319&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F18331319&utm_medium=issues&utm_source=github).The text was updated successfully, but these errors were encountered: