Skip to content
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

Add a moderately simple behavior tree example #17

Open
mgi388 opened this issue Jan 20, 2025 · 4 comments
Open

Add a moderately simple behavior tree example #17

mgi388 opened this issue Jan 20, 2025 · 4 comments
Labels
A-Control-Flow Control flow systems like behavior trees C-Docs An addition or correction to our documentation C-Examples An addition or correction to our examples
Milestone

Comments

@mgi388
Copy link

mgi388 commented Jan 20, 2025

I really want to give beet a go for BTs but the example and the docs don’t really tell me enough to know what it’s doing. My BT knowledge is definitely new, that’s for sure, but I was able to get further with bevior_tree than beet.

An example like the one in bevior_tree would be great if you’re interested in adding one?

Alternatively, maybe you already have some more than basic code using beet that you can refer to?

@mrchantey
Copy link
Owner

Thanks for the feedback yeah the examples could use some work to describe whats happening and a lot of them are kind of jumping the gun on scene based workflows so the files are spread out.

At a glance the bevior_tree example looks most similar to seek_3d which has a seek/arrive sequence.

  • Source code for the tree: here
  • Command: cargo run --example seek_3d

Also in case you missed it this quick start is an attempt to describe the internals, I'd appreciate hearing if you think some part of that could also use more clarification.

@mgi388
Copy link
Author

mgi388 commented Jan 20, 2025

Ah cool, I will check out the seek_3d code in detail. I did open that and saw this:

beet/examples/seek_3d.rs

Lines 10 to 14 in 01f4c6a

bevyhub::core::scenes::ui_terminal,
bevyhub::core::scenes::lighting_3d,
bevyhub::core::scenes::ground_3d,
beet_examples::scenes::flow::beet_debug,
beet_examples::scenes::spatial::seek_3d,

And was a bit "turned off" so I don't think I actually looked further on this example...

I am vaguely aware that you're working on some scene stuff, so its not up to me to say how you should design your examples, but as a user going to beet, the first thing I do is go to the examples folder and open up some of them. When I see the scene and helper systems indirection, it makes it harder to understand what the example is doing (because the example.rs is 100% now just an entry point). The scene indirection specifically also makes it harder to understand and it's not going to be relevant to every user. Not sure the best solution there, but you could consider keeping the scene-based ones in a separate folder and keep the root ones "pure" for the crate they are example-ifying. Re the calling out to helpers, that's a tricky one. I know https://github.com/vleue/vleue_navigator/blob/3e2c68c590eda67bb98cf325e1854ec51627362c/examples/demo.rs#L56-L69 does it too, and it's a balance between the crate author wanting to reuse helpers (which users can also take and reuse), vs describing how stuff works inline.

Re the quick start. I did go through it originally (I think) a couple of months ago though but maybe it's changed. One initial reaction when going through it the first time (and from the example in the repo), is that for some reason "log on run" just doesn't click with me. I get that ultimately the log statement just represents doing something, but if there was any more to use something closer to in-game logic, I'd opt for that.

Experience report from bevior_tree:

  • I opened it and ran the example.
  • I looked in one file and started reading the code for it—all the code for it is in the one place.
  • I copied the example to chase2.rs and started modifying it / playing with it.
  • I fiddled with returning pending, or success or failure, or changing to a selector rather than sequence, etc.
  • I continued doing that until I got up to chase4.rs and it was great for experimenting and also learning what the crate can do.

Based on that experience, the most obvious thing I'd get value from (personally) is an example all in one file, even if it's the seek_3d one—and running it now, I can see that it does look (more than) moderately simple which is good.

@mrchantey
Copy link
Owner

consider keeping the scene-based ones in a separate folder and keep the root ones "pure" for the crate they are example-ifying.

That makes a lot of sense, pretty much all the helper stuff is rendering related, ill look into seperating into examples/logic/.. and examples/rendering/...

Re the quick start... if there was any more to use something closer to in-game logic, I'd opt for that.

Great feedback it sounds like the quick start should be closer to a walk through of your experience getting started with bevior_tree, and the current one could be renamed to the Action macro or something.

@mrchantey
Copy link
Owner

Ive added two examples:

  • Vanilla Bevy is a minimal demonstration of how beet works without using the library.
  • Malenia is a moderate example that uses both behavior trees and utility ai

I'll keep this issue open until I get around to updating the quickstart.

@mrchantey mrchantey added A-Control-Flow Control flow systems like behavior trees C-Examples An addition or correction to our examples C-Docs An addition or correction to our documentation labels Feb 1, 2025
@mrchantey mrchantey added this to the 0.0.5 milestone Feb 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Control-Flow Control flow systems like behavior trees C-Docs An addition or correction to our documentation C-Examples An addition or correction to our examples
Projects
None yet
Development

No branches or pull requests

2 participants