Calamari / BehaviorTree.js

An JavaScript implementation of Behavior Trees.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Bad usage examples

dsetzer opened this issue · comments

Just want to have this clarified, this second snippet in the screenshot has no relation to the first snippet..

image

Is it trying to say this:

// Register a task:
BehaviorTree.register('testtask', myTask)
// Or register a sequence or priority:
BehaviorTree.register('test sequence', mySequence)

Which you now can simply refer to in your nodes, like:

import { Selector } from 'behaviortree'
const mySelector = new Selector({
  nodes: ['testtask', 'test sequence']
})

Or am I misunderstanding something?

Heyho @dsetzer.

You are right, that the examples are weirdly disjunct and don't really have a relation to each other, although I that the text might implicate it. You assumption is totally correct 👍, and I should update the examples accordingly.

The code examples are really great, the only other place that threw me off was in the example repo

https://github.com/Calamari/BehaviorTree.js-Examples/blob/cb5a15d5871505247a9b3e3cffab3295cea0d98c/es6/example.js#L19

Took me a moment to figure out how the Task defined at the top played into there because it's only referenced by a 'bark' right in between two inline definitions, it's very easy to miss if you're first reading up on this and aren't aware that Tasks can be registered and reused.

Anyway, thanks for confirming that!

Thanks for mentioning those shortcomings in the documents/examples. I'll optimize them for clarity then.