Grail (C++)
1.4.0
A multi-platform, modular, universal engine for embedding advanced AI in games.
|
A reasoner which uses planners to find optimal sequences of behaviors based on goals. More...
#include <PlannerReasoner.hh>
Classes | |
struct | Config |
The Planner's run-time configuration parameters. More... | |
Public Member Functions | |
PlannerReasoner (std::unique_ptr< MemoryPool > memory) | |
PlannerReasoner (std::unique_ptr< MemoryPool > memory, std::shared_ptr< planner::GoalSelector > goalSelector, std::unique_ptr< planner::DomainTranslator > domainTranslator, const Config &config) | |
virtual void | StageBehavior (AIEntity &entity) override |
selectBehavior - Runs reasoner's selection algorithm and assigns chosen behavior to provided entity. More... | |
virtual void | SetNewGoal (std::unique_ptr< planner::Goal > newGoal, AIEntity &entity) override |
Sets a new current goal for the given entity. | |
void | SetupNewPlanner (std::unique_ptr< planner::DomainTranslator > domainTranslator, const Config &config) |
void | SetFallbackBehavior (std::unique_ptr< Behavior > behavior) |
Sets the behavior that should be performed during plan computation or if no valid plan is found. | |
virtual const planner::Goal * | GetCurrentGoal () const override |
void | BindPlanningSucceededCallback (PlannerCallback callback) |
BindPlanningSucceededCallback - Binds a function handle to call if a sufficient (all goal conditions and plan restrictions met) plan is found. Found plan will be passed as function argument. More... | |
void | BindPartialPlanFoundCallback (PlannerCallback callback) |
BindPartialPlanFoundCallback - Bind a function to call when no sufficient plan could be found, but some plan was formulated, this delegate will be called instead of onPlanningFailed. usePartialPlans needs to be true for this execute Plan with highest score will be passed as a function argument. More... | |
void | BindPlanningFailedCallback (std::function< void(const planner::Goal &)> callback) |
BindPlanningFailedCallback - Bind a function to call when no sufficient plan was found. If reasoner uses partial plans this will only be called if no plan was formulated at all. More... | |
void | BindPlanExecutedCallback (std::function< void()> callback) |
BindPlanExecutedCallback - Bind a function to call when entity has successfully executed chosen plan. More... | |
void | SetSnapshotProduction (bool shouldProduce) |
Enable or disable snapshot production for debugging. | |
bool | IsComputing () const |
data::PlannerReasonerSnapshot | ProduceDebugSnapshot () |
virtual std::unique_ptr< ISnapshotGenerator > | CreateSnapshotGenerator (std::size_t) override |
void | ClearCurrentDebugSnapshot () |
Clears any debug data that have been accumulated during iterations so far. | |
void | SetDebugSnapshotFirstIteration (std::size_t iterationNumber) |
Sets the number of the iteration starting from which debug snapshots will be generated if run in debug mode. | |
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. | |
std::size_t | GetDebugSnapshotFirstIteration () const |
Gets the number of the iteration starting from which debug snapshots will be generated if run in debug mode. | |
std::size_t | GetDebugSnapshotLastIteration () const |
Gets the number of the iteration up to which debug snapshots will be generated if run in debug mode. | |
Public Member Functions inherited from grail::Reasoner | |
Reasoner (const Reasoner &)=default | |
Reasoner (Reasoner &&)=default | |
Reasoner & | operator= (const Reasoner &)=default |
Reasoner & | operator= (Reasoner &&)=default |
virtual std::unique_ptr< ISnapshotGenerator > | CreateSnapshotGenerator (size_t) |
Protected Member Functions | |
virtual void | ClearCache () override |
ClearCache - called when assigning this reasoner to an entity. Clears internally stored data, which may be invalidated when assigned to a different entity. | |
A reasoner which uses planners to find optimal sequences of behaviors based on goals.
grail::planner::PlannerReasoner::PlannerReasoner | ( | std::unique_ptr< MemoryPool > | memory | ) |
Constructs a new PlannerReasoner instance.
memory | - pool object used for memory optimization. |
grail::planner::PlannerReasoner::PlannerReasoner | ( | std::unique_ptr< MemoryPool > | memory, |
std::shared_ptr< planner::GoalSelector > | goalSelector, | ||
std::unique_ptr< planner::DomainTranslator > | domainTranslator, | ||
const Config & | config | ||
) |
Constructs a new PlannerReasoner instance based on the provided arguments.
\memory - pool object used for memory optimization. \goalSelector - implementation that allows to choose subsequent goals for planning (at start and whenever a new goal is required) \domainTranslator - a translation layer between the abstract plan space and the game objects. See DomainTranslator. \config - the run-time configuration parameters for the planner
void grail::planner::PlannerReasoner::BindPartialPlanFoundCallback | ( | PlannerCallback | callback | ) |
BindPartialPlanFoundCallback - Bind a function to call when no sufficient plan could be found, but some plan was formulated, this delegate will be called instead of onPlanningFailed. usePartialPlans needs to be true for this execute Plan with highest score will be passed as a function argument.
callback | Function to call if a partial plan is found |
void grail::planner::PlannerReasoner::BindPlanExecutedCallback | ( | std::function< void()> | callback | ) |
BindPlanExecutedCallback - Bind a function to call when entity has successfully executed chosen plan.
callback | Function to call when plan goal is achieved |
void grail::planner::PlannerReasoner::BindPlanningFailedCallback | ( | std::function< void(const planner::Goal &)> | callback | ) |
BindPlanningFailedCallback - Bind a function to call when no sufficient plan was found. If reasoner uses partial plans this will only be called if no plan was formulated at all.
callback | function to call if planning failed |
void grail::planner::PlannerReasoner::BindPlanningSucceededCallback | ( | PlannerCallback | callback | ) |
BindPlanningSucceededCallback - Binds a function handle to call if a sufficient (all goal conditions and plan restrictions met) plan is found. Found plan will be passed as function argument.
callback | Function to call if a suitable plan is found |
|
overridevirtual |
Implements grail::planner::IGoalAcceptor.
bool grail::planner::PlannerReasoner::IsComputing | ( | ) | const |
void grail::planner::PlannerReasoner::SetupNewPlanner | ( | std::unique_ptr< planner::DomainTranslator > | domainTranslator, |
const Config & | config | ||
) |
Resets the planner domain. based on data provided by the new domain translator . This method can be used if you want the agent to start planning an entirely different set of actions and disregard the previously defined domain.
|
overridevirtual |
selectBehavior - Runs reasoner's selection algorithm and assigns chosen behavior to provided entity.
entity |
Implements grail::Reasoner.