1 #ifndef GRAIL_PLANNER_REASONER_H
2 #define GRAIL_PLANNER_REASONER_H
4 #include "../../GrailCore/Reasoner.hh"
5 #include "../GoalSelector.hh"
6 #include "../../GrailCore/Behavior.hh"
7 #include "../../GrailCore/Plan.hh"
8 #include "../../GrailData/DebugInfo/PlannerSnapshots.h"
12 using PlannerCallback = std::function<void(
const planning::Plan&,
const planning::Goal&)>;
16 class DomainTranslator;
25 std::size_t maxIterations = 1000;
26 int maxPlanLength = -1;
27 std::size_t iterationsPerFrame = 10;
28 double maxPlanCost = -1;
29 bool usePartialPlans =
true;
34 std::shared_ptr<planning::GoalSelector> goalSelector,
35 std::unique_ptr<planning::DomainTranslator> domainTranslator,
38 void SetNewGoal(std::unique_ptr<planning::Goal> newGoal,
AIEntity& entity)
override;
43 void SetupNewPlanner(std::unique_ptr<planning::DomainTranslator> domainTranslator,
const Config& config);
51 void BindPlanningSucceededCallback(PlannerCallback callback);
52 void BindPartialPlanFoundCallback(PlannerCallback callback);
53 void BindPlanningFailedCallback(std::function<
void(
const planning::Goal&)> callback);
54 void BindPlanExecutedCallback(std::function<
void()> callback);
58 void SetSnapshotProduction(
bool shouldProduce);
59 bool IsComputing()
const;
62 std::unique_ptr<ISnapshotGenerator> CreateSnapshotGenerator(std::size_t)
override;
63 void ClearCurrentDebugSnapshot();
65 void SetDebugSnapshotFirstIteration(std::size_t iterationNumber);
66 void SetDebugSnapshotLastIteration(std::size_t iterationNumber);
67 std::size_t GetDebugSnapshotFirstIteration()
const;
68 std::size_t GetDebugSnapshotLastIteration()
const;
73 std::shared_ptr<planning::GoalSelector> goalSelector;
74 std::unique_ptr<planning::DomainTranslator> domainTranslator;
77 std::size_t iterationsPerFrame = 0;
78 bool usePartialPlans =
false;
80 std::unique_ptr<planning::Goal> chosenGoal =
nullptr;
81 std::unique_ptr<Behavior> fallbackBehavior =
nullptr;
83 PlannerCallback onPlanningSucceeded;
84 PlannerCallback onPartialPlanFound;
86 std::function<void()> onPlanExecuted;
90 bool produceSnapshot =
false;
93 std::size_t debugSnapshotFirstIteration = 0;
94 std::size_t debugSnapshotLastIteration = std::numeric_limits<std::size_t>::max();
The AIEntity class - Defines a basic object which can execute behaviors.
Definition: AIEntity.hh:39
The MemoryPool class - preallocated memory container for optimization issues.
Definition: MemoryPool.hh:74
A reasoner which uses planners to find optimal sequences of behaviors based on goals.
Definition: PlannerReasoner.hh:20
void SetFallbackBehavior(std::unique_ptr< Behavior > behavior)
Sets the behavior that should be performed during plan computation or if no valid plan is found.
Definition: PlannerReasoner.cpp:120
void SetupNewPlanner(std::unique_ptr< planning::DomainTranslator > domainTranslator, const Config &config)
Definition: PlannerReasoner.cpp:109
void SelectBehavior(AIEntity &entity) override
selectBehavior - Runs reasoner's selection algorithm and assigns chosen behavior to provided entity.
Definition: PlannerReasoner.cpp:31
The Reasoner class - Entity's "brain", assigns them behaviors chosen by user-defined algorithms.
Definition: Reasoner.hh:20
Represents a planner goal, used by PlannerReasoner.
Definition: Goal.hh:15
Definition: GoalSelector.hh:12
A data structure used by PlannerReasoner to execute a sequence of behaviors.
Definition: Plan.hh:16
The main class responsible for finding paths in plan space.
Definition: Planner.hh:23
Definition: PlannerReasoner.hh:23
Definition: PlannerSnapshots.h:70