Grail (C++)  1.4.0
A multi-platform, modular, universal engine for embedding advanced AI in games.
DomainTranslator.hh
1 // Copyright QED Software 2023.
2 
3 #ifndef GRAIL_DOMAIN_TRANSLATOR_H
4 #define GRAIL_DOMAIN_TRANSLATOR_H
5 
6 #include "IPlannerObject.hh"
7 #include "ObjectIndexBinding.hh"
8 #include "../GrailCore/Behavior.hh"
9 #include "../GrailCore/Plan.hh"
10 
11 namespace grail
12 {
13 namespace planner
14 {
15  class Goal;
16 
21  {
22  public:
26  DomainTranslator(bool isDomainReusable = true);
27  DomainTranslator(const DomainTranslator&) = default;
29 
30  virtual ~DomainTranslator() = default;
31 
32  DomainTranslator& operator =(const DomainTranslator&) = default;
33  DomainTranslator& operator =(DomainTranslator&&) = default;
34 
41  std::unique_ptr<WorldState> GetWorldState(AIEntity& entity, const class Goal& goal, MemoryPool* memory);
42 
45 
52  virtual Plan TranslatePlan(const AIEntity& entity,
53  const Planner::AbstractPlan& plan,
54  const Goal& goal) const = 0;
55 
60  void ResetMemoryPool(MemoryPool& memory);
61 
62  protected:
65  virtual std::vector<IPlannerObject*> GeneratePlannerObjects(AIEntity& entity,
66  const Goal& goal,
67  MemoryPool* memory) = 0;
68 
70  virtual std::vector<WorldObjectType> CreateObjectTypes(const AIEntity& entity,
71  const Goal& goal,
72  MemoryPool* memory) = 0;
73 
76  virtual void AddActionTemplates(const AIEntity& entity,
77  const std::shared_ptr<Domain>& domain,
78  const Goal& goal) = 0;
79 
82  virtual void SetWorldStateParameters(const AIEntity& entity, WorldState& state, const Goal& goal) const;
83 
84  ObjectIndexBinding binding{};
85 
86  private:
87  bool isDomainReusable = false;
88  std::size_t domainSize = 0;
89  std::shared_ptr<Domain> domain = nullptr;
90  };
91 }
92 }
93 
94 #endif //GRAIL_DOMAIN_TRANSLATOR_H
grail::AIEntity
The AIEntity class - Defines a basic object which can execute behaviors.
Definition: AIEntity.hh:50
grail::planner::Planner::AbstractPlan
Represents a formulated plan as a sequence of actions and a cost.
Definition: Planner.hh:70
grail::planner::WorldState
Definition: WorldState.hh:20
grail::planner::DomainTranslator
Definition: DomainTranslator.hh:20
grail::planner::DomainTranslator::TranslatePlan
virtual Plan TranslatePlan(const AIEntity &entity, const Planner::AbstractPlan &plan, const Goal &goal) const =0
grail::planner::DomainTranslator::GeneratePlannerObjects
virtual std::vector< IPlannerObject * > GeneratePlannerObjects(AIEntity &entity, const Goal &goal, MemoryPool *memory)=0
grail::planner::MemoryPool
The MemoryPool class - preallocated memory container for optimization issues.
Definition: MemoryPool.hh:79
grail::planner::ObjectIndexBinding
Definition: ObjectIndexBinding.hh:17
grail::Plan
A data structure used by PlannerReasoner to execute a sequence of behaviors.
Definition: Plan.hh:14
grail::planner::DomainTranslator::GetObjectIndexBinding
const ObjectIndexBinding & GetObjectIndexBinding() const
Definition: DomainTranslator.cpp:43
grail::planner::DomainTranslator::DomainTranslator
DomainTranslator(bool isDomainReusable=true)
Definition: DomainTranslator.cpp:10
grail::planner::DomainTranslator::ResetMemoryPool
void ResetMemoryPool(MemoryPool &memory)
ResetMemoryPool - Resets memory pool's memory cell pointer. If domain is reusable,...
Definition: DomainTranslator.cpp:48
grail::planner::DomainTranslator::GetWorldState
std::unique_ptr< WorldState > GetWorldState(AIEntity &entity, const class Goal &goal, MemoryPool *memory)
Definition: DomainTranslator.cpp:15
grail::planner::Goal
Definition: Goal.hh:19
grail::planner::DomainTranslator::CreateObjectTypes
virtual std::vector< WorldObjectType > CreateObjectTypes(const AIEntity &entity, const Goal &goal, MemoryPool *memory)=0
grail::planner::DomainTranslator::AddActionTemplates
virtual void AddActionTemplates(const AIEntity &entity, const std::shared_ptr< Domain > &domain, const Goal &goal)=0
grail::planner::DomainTranslator::SetWorldStateParameters
virtual void SetWorldStateParameters(const AIEntity &entity, WorldState &state, const Goal &goal) const
Definition: DomainTranslator.cpp:53