godot-addons/godot-behavior-tree-plugin

Multitick actions

DagobertDev opened this issue · 15 comments

How are action that take multiple ticks/frames (e.g. movement) supposed to be implemented? Running the whole tree for many actors each frame isnt performant enough.

I've actually a little more about behavior trees (while looking for Java implementations).

It seems a better implementation would be to track the current node so that you skip parsing the entire tree every tick. I also didnt understand what the blackboard was intended for previously.

This library needs some more love I think

Sorry to say this, but without that feature this is a broken plugin. I think it should be removed from the asset store, because I am sure many like myself were looking for that feature in particular. I am not sure how to fix your code looking at it, because the documentation is not very good and the variable names are often cryptic.
Sorry if that sounds mean, I don't really mean it that way, I just don't think people want the wild goose chase.
With that in mind I may poke at your code some more, or simply write one from scratch that supports multi-tick operations.

Looking closely the error in in your logic for _execute() in the bt_base.gd, only that specific node knows that it is busy and open, because of the way you have hidden the memory of blackboard down to the level of the specific executing leaf/action node. If "isOpen" was exposed in the root memory for blackboard and had a pointer to the last executing Node then I think you could fix this.

  1. This is a fork that I tried to cleanup and understand myself
  2. This is an MIT open-source project
  3. Feel free to submit a PR, happy to merge
  4. Feel free to fork it yourself if you want to totally change it
  5. Not sure what you're referring to with cryptic variable names. I reviewed multiple gd files and I don't see anything cryptic, the code is fairly small. Any specifics?

It's not like there are many Godot / GDScript options available. One should probably understand behavior trees and how they work before trying to use. I didn't realize myself how this needs to be optimized until I started poking around implementations in Java.

1 Understood from looking at the commits.
2 ✓
3 I tried but like I said it appears to be a deep problem, one of architecture, the code was not created with multi tick in mind.
4 Thank you.
5 This is always a taste/personal preference thing. But in my opinion everything in this code is referred to as a tick, and with so many tick things it gets confusing to sort out.
6 True. True. Makes sense. Sorry I was too harsh.
7 I am making a system for myself, if it works well I will share it with all.

@brandonlamb I come bearing gifts, will you please give me some early feedback? I would like to know if you feel this is a good implementation and if I should continue to expand it out to include the other Behavior Tree Types.

A few notes about this implementation, it was designed with iteration in mind. In a deeper tree it will only travel a few nodes down, but composite trees will automatically open and and execute their children as this is a fairly inexpensive operation. Action Nodes can wait with ERR_BUSY and the rest of the tree is capable of state across multiple frames. The previous context stored in blackboard has been integrated into the root of the behavior tree to overall simplify the structures. This code includes rudimentary Integration testing, the test code is capable of much more and the Behavior Trees can handle a deeper trees than what is run in the test scene. To run the tests, just run the "TestRunnerScene.tscn" in the tests folder.
Oh I forgot to mention the Root actually is setup to automatically process it's self. It does have a export variable for limiting how often the AI runs.
I am sorry for being rude earlier.

I was planning to try this plugin but you are saying it's not possible to use it for movement?

Its possible to do movement and anything else thats expected from a behavior tree with this plugin, but there is room for improvement in the implementation @AnderRasoVazquez.

Thanks for clarifying =) Now I have something to play with during this quarantine... Greetings from Spain.

@brandonlamb @DagobertDev I have a solution for this that i'm using in my own project. I've mentioned it in #28 - I can submit a PR if there's interest.

Dang, somehow i totally missed seeing updates to this, I'm coming back from a long hiatus myself and trying to do some updates to some of the addons in this org. I've updated the FSM and a new FSM with stack (pushdown automaton), so today I was wanting to do a total look over this behavior tree addon based on the new learnings I've had over the past year.

I'll create a PR so we can look at the changed files

@brandonlamb that's awesome, I'm interested in the pushdown FSM, I was going to implement it myself after this week's Godot Wild jam. I'll submit the PR to fix this issue once the jam is over. It's getting lots of testing in the jam and on my side project.

Yea I remember reading on pushdown automaton way back when, but didnt really understand it at the time. I created an issue on the FSM repo to also add links to other FSM implementations that I've stumbled upon for Godot (there are like 5)

@brandonlamb I misunderstood this issue so the solution I'm referring to isn't correct.