1 #ifndef GRAIL_PLANNER_REASONER_H
2 #define GRAIL_PLANNER_REASONER_H
4 #include "../GrailSystem/Reasoner.hh"
5 #include "../GrailSystem/Behavior.hh"
6 #include "../GrailSystem/Plan.hh"
7 #include "../GrailData/GrailDebugInfo/PlannerSnapshots.h"
8 #include "GoalSelector.hh"
14 using PlannerCallback = std::function<void(
const planning::Plan&,
const planning::Goal&)>;
18 class DomainTranslator;
27 std::size_t maxIterations = 1000;
28 int maxPlanLength = -1;
29 std::size_t iterationsPerFrame = 10;
30 double maxPlanCost = -1;
31 bool usePartialPlans =
true;
36 std::shared_ptr<planning::GoalSelector> goalSelector,
37 std::unique_ptr<planning::DomainTranslator> actionTranslator,
40 void SetNewGoal(std::unique_ptr<planning::Goal> newGoal,
AIEntity& entity)
override;
45 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);
57 void SetSnapshotProduction(
bool shouldProduce);
58 bool IsComputing()
const;
61 std::unique_ptr<ISnapshotGenerator> CreateSnapshotGenerator(std::size_t)
override;
62 void ClearCurrentDebugSnapshot();
64 void SetDebugSnapshotFirstIteration(std::size_t iterationNumber);
65 void SetDebugSnapshotLastIteration(std::size_t iterationNumber);
66 std::size_t GetDebugSnapshotFirstIteration()
const;
67 std::size_t GetDebugSnapshotLastIteration()
const;
72 std::shared_ptr<planning::GoalSelector> goalSelector;
73 std::unique_ptr<planning::DomainTranslator> domainTranslator;
76 std::size_t iterationsPerFrame = 0;
77 bool usePartialPlans =
false;
79 std::unique_ptr<planning::Goal> chosenGoal =
nullptr;
80 std::unique_ptr<Behavior> fallbackBehavior =
nullptr;
82 PlannerCallback onPlanningSucceeded;
83 PlannerCallback onPartialPlanFound;
85 std::function<void()> onPlanExecuted;
88 bool produceSnapshot =
false;
91 std::size_t debugSnapshotFirstIteration = 0;
92 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:22
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:119
void SetupNewPlanner(std::unique_ptr< planning::DomainTranslator > domainTranslator, const Config &config)
Definition: PlannerReasoner.cpp:108
void SelectBehavior(AIEntity &entity) override
selectBehavior - Runs reasoner's selection algorithm and assigns chosen behavior to provided entity.
Definition: PlannerReasoner.cpp:32
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:25
Definition: PlannerSnapshots.h:64