Code Monkey home page Code Monkey logo

go-behaviortree's People

Contributors

dependabot[bot] avatar joeycumines avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

go-behaviortree's Issues

Consider Printer with DOT

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.

Name Nodes

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.

Other Composite and Decorator Nodes

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.

project roadmap

@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.

Sequence should not tick previous children if a children returns Running

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?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.