https://github.com/taiyu-len/continuation-behavior-tree
https://github.com/taiyu-len/continuation-behavior-tree
behavior-tree
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/taiyu-len/continuation-behavior-tree
- Owner: taiyu-len
- Created: 2018-11-28T06:17:52.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2020-02-27T05:36:18.000Z (almost 6 years ago)
- Last Synced: 2024-12-27T12:28:01.117Z (about 1 year ago)
- Topics: behavior-tree
- Language: C++
- Homepage:
- Size: 111 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
An WIP implementation of behavior trees using continuations designed to work
with asio
the `behavior` is a smart pointer wrapping an object satisfying one of these
requirements.
- is invocable as `status()`
- used for leaf nodes that only `continues::up` the tree
```c++
behavior x = []{ do_stuff(); return status::success; };
```
- is invocable as `void(continuation)`
- used for leaf nodes that `continues::elsewhere`, that is it moves the
continuation to be called later, for async processing
```c++
behavior x = [](continuation c)
{
timer t(some_time);
t.async_wait([](...){ do_stuff(); c(); });
};
```
- is invocable as `continues(continuation)`
- used for nodes which `continues::down` the tree, as well as either of the
above usages
```c++
node::operator(continuation r) -> continues
{
resume_parent = std::move(r);
resume_this = [this](status s) -> continues
{
// random example
switch (state()) {
case 0: return continues::down(child, resume_this);
case 1: return continues::up(std::move(resume_parent), Success);
case 2: post(std::move(resume_parent));
return continues::elsewhere();
}
}
return continues::down(child, resume_this);
}
```
Unlike regular behavoir trees, there is no `Running` state due to the
continuations, since we simply continue the tree by calling them once we finish
a task.