|
Grail (C++)
1.4.0
A multi-platform, modular, universal engine for embedding advanced AI in games.
|
3 #ifndef GRAIL_PLANNER_REASONER_H
4 #define GRAIL_PLANNER_REASONER_H
6 #include "../GoalSelector.hh"
7 #include "../../GrailCore/Behavior.hh"
8 #include "../../GrailCore/Plan.hh"
9 #include "../../GrailCore/Reasoner.hh"
10 #include "../../GrailData/DebugInfo/PlannerSnapshots.h"
16 using PlannerCallback = std::function<void(
const Plan&,
const planner::Goal&)>;
17 class DomainTranslator;
62 std::shared_ptr<planner::GoalSelector> goalSelector,
63 std::unique_ptr<planner::DomainTranslator> domainTranslator,
66 virtual void SetNewGoal(std::unique_ptr<planner::Goal> newGoal,
AIEntity& entity)
override;
71 void SetupNewPlanner(std::unique_ptr<planner::DomainTranslator> domainTranslator,
const Config& config);
114 virtual std::unique_ptr<ISnapshotGenerator> CreateSnapshotGenerator(std::size_t)
override;
139 std::shared_ptr<planner::GoalSelector> goalSelector;
140 std::unique_ptr<planner::DomainTranslator> domainTranslator;
141 std::unique_ptr<MemoryPool> memory;
144 std::size_t iterationsPerFrame = 0;
145 bool usePartialPlans =
false;
147 std::unique_ptr<planner::Goal> chosenGoal =
nullptr;
148 std::unique_ptr<Behavior> fallbackBehavior =
nullptr;
150 PlannerCallback onPlanningSucceeded;
151 PlannerCallback onPartialPlanFound;
153 std::function<void()> onPlanExecuted;
155 bool produceSnapshot =
false;
158 std::size_t debugSnapshotFirstIteration = 0;
159 std::size_t debugSnapshotLastIteration = std::numeric_limits<std::size_t>::max();
164 #endif //GRAIL_PLANNER_REASONER_H
virtual void SetNewGoal(std::unique_ptr< planner::Goal > newGoal, AIEntity &entity) override
Sets a new current goal for the given entity.
Definition: PlannerReasoner.cpp:79
std::size_t GetDebugSnapshotFirstIteration() const
Gets the number of the iteration starting from which debug snapshots will be generated if run in debu...
Definition: PlannerReasoner.cpp:177
The AIEntity class - Defines a basic object which can execute behaviors.
Definition: AIEntity.hh:50
The Reasoner class - Entity's "brain", assigns them behaviors chosen by user-defined algorithms.
Definition: Reasoner.hh:21
void BindPartialPlanFoundCallback(PlannerCallback callback)
BindPartialPlanFoundCallback - Bind a function to call when no sufficient plan could be found,...
Definition: PlannerReasoner.cpp:131
std::size_t iterationsPerFrame
The number of iterations to perform per one update of the reasoner. The total number of iterations wi...
Definition: PlannerReasoner.hh:37
virtual const planner::Goal * GetCurrentGoal() const override
Definition: PlannerReasoner.cpp:121
bool IsComputing() const
Definition: PlannerReasoner.cpp:151
void BindPlanExecutedCallback(std::function< void()> callback)
BindPlanExecutedCallback - Bind a function to call when entity has successfully executed chosen plan.
Definition: PlannerReasoner.cpp:141
A reasoner which uses planners to find optimal sequences of behaviors based on goals.
Definition: PlannerReasoner.hh:20
void ClearCurrentDebugSnapshot()
Clears any debug data that have been accumulated during iterations so far.
Definition: PlannerReasoner.cpp:162
int maxPlanLength
The maximum number of actions (steps) a plan can take. Set -1 for unlimited plans.
Definition: PlannerReasoner.hh:34
Definition: GoalSelector.hh:16
void SetDebugSnapshotLastIteration(std::size_t iterationNumber)
Sets the number of the iteration up to which debug snapshots will be generated if run in debug mode.
Definition: PlannerReasoner.cpp:172
Definition: Planner.hh:39
void BindPlanningFailedCallback(std::function< void(const planner::Goal &)> callback)
BindPlanningFailedCallback - Bind a function to call when no sufficient plan was found....
Definition: PlannerReasoner.cpp:136
A data structure used by PlannerReasoner to execute a sequence of behaviors.
Definition: Plan.hh:14
Definition: PlannerSnapshots.h:92
void SetupNewPlanner(std::unique_ptr< planner::DomainTranslator > domainTranslator, const Config &config)
Definition: PlannerReasoner.cpp:104
void BindPlanningSucceededCallback(PlannerCallback callback)
BindPlanningSucceededCallback - Binds a function handle to call if a sufficient (all goal conditions ...
Definition: PlannerReasoner.cpp:126
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:116
std::size_t GetDebugSnapshotLastIteration() const
Gets the number of the iteration up to which debug snapshots will be generated if run in debug mode.
Definition: PlannerReasoner.cpp:182
virtual void StageBehavior(AIEntity &entity) override
selectBehavior - Runs reasoner's selection algorithm and assigns chosen behavior to provided entity.
Definition: PlannerReasoner.cpp:34
virtual void ClearCache() override
ClearCache - called when assigning this reasoner to an entity. Clears internally stored data,...
Definition: PlannerReasoner.cpp:187
void SetDebugSnapshotFirstIteration(std::size_t iterationNumber)
Sets the number of the iteration starting from which debug snapshots will be generated if run in debu...
Definition: PlannerReasoner.cpp:167
void SetSnapshotProduction(bool shouldProduce)
Enable or disable snapshot production for debugging.
Definition: PlannerReasoner.cpp:146
double maxPlanCost
An upper bound on the plan cost measured as the sum of costs of actions it consists of....
Definition: PlannerReasoner.hh:40
PlannerReasoner(std::unique_ptr< MemoryPool > memory)
Definition: PlannerReasoner.cpp:13
std::size_t maxIterations
The maximum number of iterations to find the best plan in a given state.
Definition: PlannerReasoner.hh:31
bool usePartialPlans
Definition: PlannerReasoner.hh:46
The Planner's run-time configuration parameters.
Definition: PlannerReasoner.hh:24