Quick technical question: When a node returns 0 (Running), does the Supervisor strictly adhere to the fixed tick interval (like the 100ms in the example), or is there any built-in exponential backoff? I'm wondering how it handles CPU load if you have hundreds of trees just waiting on I/O. Really clean architecture, great work!
Show HN: Go-Bt: Minimalist Behavior Trees for Go
11–15 of 15 posts
Re: Show HN: Go-Bt: Minimalist Behavior Trees for Go
#12I really like the approach to time-travel testing here. Injecting the clock directly into the BTContext is a very clean way to avoid flaky CI tests without having to mock global time interfaces. Quick technical question: When a node returns 0 (Running), does the Supervisor strictly adhere to the fixed tick interval (like the 100ms in the example), or is there any built-in exponential backoff? I'm wondering how it han…
Re: Show HN: Go-Bt: Minimalist Behavior Trees for Go
#13Earlier quoted context omitted.
Hey, thanks a lot for the comment. I'd love to see some code about the "express state machines as data". I always had a hard time with state machines, because every time I needed to add a new node, I had to reason about too many transitions, especially when the number of states was enormous. I like the BT structure because of the modularity, but it would be nice to see some other way to implement things - always a we…
To note, the approach in the article is basically the polar opposite from writing a data driven state machine. I default to the latter, but I think it’s worth exloring and understanding the former.
Re: Show HN: Go-Bt: Minimalist Behavior Trees for Go
#14Not a Go veteran, but I implememted a behavior tree in a little simulation game prototype. Looked very similar structurally but your version is nicer. As an aside: I don’t particularly like behavior trees. Not sure why, but they feel brute-force-y to me, and I find them much harder to reason about than state machines. Once you express state machines as data, they can become just as powerful and feel less fiddly. A di…
I don't think "channels without go routines" are possible. One thread can't send and simultaneously receive on a channel. I remember libraries that used go channels for control flow because the code looked better this way. They had to start a second thread to make it work which is very inefficient.
Better approaches are "functions" with internal state (generators) or the relatively new stdlib iter package.
Edit: the iter package internally uses compiler quirks to implement coroutines to be able to send and receive values on the same thread.
Re: Show HN: Go-Bt: Minimalist Behavior Trees for Go
#15The clock injection for testing temporal nodes is a really nice touch. Most BT libraries force you to actually wait or mock everything yourself. This would work well for orchestrating retries and fallback logic in microservices, not just game AI. Any plans for parallel composite nodes?
Hey, thanks a lot for the comment. I was thinking about the parallel composite nodes and I was wondering what would make good additions to the project. What do you think? I was going to start implementing something like RequireAny and RequireAll. I was also wondering about the "parallel" side of these nodes. Does it mean they tick all children nodes or does it mean that I spawn one goroutine for each child in a wait…