137#include <type_traits>
140namespace aitoolkit::bt {
163 m_children = std::move(other.m_children);
166 virtual ~node() =
default;
171 std::vector<std::unique_ptr<node<T>>> m_children;
181 template <
typename N,
class T>
188 template <
typename T, node_trait<T> ...Children>
189 std::vector<node_ptr<T>>
node_list(Children&&... children) {
190 auto nodes = std::vector<node_ptr<T>>{};
191 nodes.reserve(
sizeof...(children));
192 (nodes.push_back(std::make_unique<Children>(std::move(children))), ...);
205 this->m_children = std::move(children);
209 for (
auto& child : this->m_children) {
210 auto state = child->evaluate(blackboard);
229 this->m_children = std::move(children);
233 for (
auto& child : this->m_children) {
234 auto state = child->evaluate(blackboard);
252 template <node_trait<T> N>
254 this->m_children.reserve(1);
255 this->m_children.push_back(std::make_unique<N>(std::move(child)));
259 if (this->m_children.size() != 1) {
263 auto& child = this->m_children.front();
264 auto state = child->evaluate(blackboard);
283 using callback_type = std::function<bool(
const T&)>;
286 check(callback_type fn) : m_fn(fn) {}
289 if (m_fn(blackboard)) {
311 task(callback_type fn) : m_fn(fn) {}
314 return m_fn(blackboard);
std::unique_ptr< node< T > > node_ptr
Heap-allocated pointer to node.
Definition behtree.hpp:179
execution_state
Represent the state of a node.
Definition behtree.hpp:146
std::vector< node_ptr< T > > node_list(Children &&... children)
Helper function to create a list of nodes.
Definition behtree.hpp:189