118#include <type_traits>
121namespace aitoolkit::utility {
127 template <
typename T>
135 virtual float score(
const T& blackboard)
const = 0;
140 virtual void apply(T& blackboard)
const = 0;
147 template <
typename T>
150 template <
typename A,
typename T>
157 template <
typename T, action_trait<T> ...Actions>
159 auto actions_list = std::vector<action_ptr<T>>{};
160 actions_list.reserve(
sizeof...(Actions));
161 (actions_list.push_back(std::make_unique<Actions>(std::move(actions))), ...);
170 template <
typename T>
181 void run(T& blackboard)
const {
182 if (m_actions.empty()) {
186 auto best_score = std::numeric_limits<float>::min();
187 auto best_action = m_actions.front().get();
189 for (
auto&
action : m_actions) {
191 if (score > best_score) {
193 best_action =
action.get();
197 best_action->
apply(blackboard);
201 std::vector<action_ptr<T>> m_actions;
std::unique_ptr< action< T > > action_ptr
Heap allocated pointer to an action.
Definition utility.hpp:148
std::vector< action_ptr< T > > action_list(Actions &&... actions)
Helper function to create a list of actions.
Definition utility.hpp:158