joeycumines / go-behaviortree Goto Github PK
View Code? Open in Web Editor NEWPackage behaviortree provides a simple and powerful Go implementation of behavior trees without fluff.
License: Apache License 2.0
Package behaviortree provides a simple and powerful Go implementation of behavior trees without fluff.
License: Apache License 2.0
Is your feature request related to a problem? Please describe.
I was wondering why did you choose the current format of printing the tree. It's not that readable IMO and I think having one done with DOT would improve much more the output.
At least for me when I'm printing the Node Tree I want to see the general overview, as the one it's everywhere documented (nodes and edges connected with names). With DOT that would be easily done and would solve this need.
Describe the solution you'd like
I know I can write my own printer by overwitting the bht.DefaultPrinter
, but I was thinking the DOT one would be really useful for the actual output of the Tree. For example for me I want it also in DOT so I can generate a PNG and add it to the documentation and/or compare it with the one I sketched before.
So this one is tricky, the current one I see it prints a lot of things that with DOT would not be possible (like the Meta and such) but I was thinking there could be 2 printers one detailed and the other one with DOT that would give the general view of the tree.
If not, there is no problem, again, I can just overwirte the bht.DefaultPrinter
and move one hehe.
Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
Additional context
Add any other context or screenshots about the feature request here.
Is your feature request related to a problem? Please describe.
In any example I see of Behavior Trees, either graphic of code the Nodes always have names as it helps to describe what they are doing, and if the tree is a bit big, without names it's not that easy. I end up having to add comments just to know what each node is about on the construction of the tree.
Describe the solution you'd like
To not brake the API bht.New()
and bht.NewNode()
I would add an extension to those 2 with a bht.NewWithName()
and bht.NewNodeWithName
where the name string
would be the first parameter so then it would make it easier to read on the code.
Now, the question is where is this name string
stored? As Node
is just a func () (Tick, []Node)
so it cannot store anything. Reading the code I found the bht.Frame
which is basically used for printing (from the code):
// This packages captures details about the caller of it's New and NewNode functions, embedding them into the
// nodes themselves, for tree printing / tracing purposes.
So basically adding there the Name string
would be the best place as then you can also add it to the printing of the Nodes as then the output will be much more clear.
Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
Additional context
Add any other context or screenshots about the feature request here.
Is your feature request related to a problem? Please describe.
I'm new to BT but one thing I've seen is that there are much more Composite nodes than the Sequence
and Selector
, for example Random Selectors / Sequences
.
And there are also the Decorators
:
Inverter
: Simply put they will invert or negate the result of their child node.Repeater
: A repeater will reprocess its child node each time its child returns a result. These are often used at the very base of the tree, to make the tree to run continuously. Repeaters may optionally run their children a set number of times before returning to their parent.Succeeder
: A succeeder will always return success, irrespective of what the child node actually returned.For what I read there much more but those look like the main ones also
Describe the solution you'd like
To consider the option of adding them
Describe alternatives you've considered
As long as you are ok on adding them I could take a look into doing it myself :)
Additional context
Another GO lib that has some of the Composites and Deocrators: https://github.com/askft/go-behave?tab=readme-ov-file#composite-nodes
A blog also mentioning some of those https://www.gamedeveloper.com/programming/behavior-trees-for-ai-how-they-work
As I said before, anyone can add anything but looks like those are common.
@joeycumines
Thanks for giving us go-behaviortree. IMHO this is the best implementation.
Do you plan to continue with this project?
I have some enhancements and was wonder if I should fork or submit PR.
Hi, I have recently started using this library and I wanted to thank you for the amazing work.
I have the following BT. The logic I am trying to implement is making the ship extract resources and sell those not wanted until full. The extract resources action has a cooldown so its sibling node first checks if the cooldown is active and returns running if so:
return bt.New(bt.Sequence,
Sell(ship, sellExceptions...),
bt.New(bt.Sequence,
bt.New(func(children []bt.Node) (bt.Status, error) {
if time.Now().Before(ship.Cooldown.Expiration) {
return bt.Running, nil
}
if ship.Cargo.Units == ship.Cargo.Capacity {
return bt.Failure, nil
}
return bt.Success, nil
}),
Extract(ship),
),
)
From what I understand about Behavior Trees, I expected the outer sequence node to directly Tick its second child (that is the inner Sequence node), since it returned a Running Status. Is this the expected behavior in your implementation? If so, how can I implement the behavior I described?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.