Grail (C++)  1.4.0
A multi-platform, modular, universal engine for embedding advanced AI in games.
Action.hh
1 // Copyright QED Software 2023.
2 
3 #ifndef GRAIL_ACTION_H
4 #define GRAIL_ACTION_H
5 
6 #include "ActionTemplate.hh"
7 
8 namespace grail
9 {
10 namespace planner
11 {
16  class Action
17  {
18  public:
24  Action(const ActionTemplate& actionTemplate, std::vector<unsigned int>&& argumentIndices);
25  Action(Action&& other) = default;
26  ~Action() = default;
27 
33  bool IsLegal(const WorldState& worldState) const;
34 
40  double GetCost(const WorldState& worldState) const;
41 
46  const std::vector<unsigned int>& GetArgumentIndices() const;
47 
52  void ApplyToState(WorldState& worldState) const;
53 
57  const std::string& GetName() const;
58 
62  int GetType() const;
63  Action& operator=(Action&& other) = default;
64 
65  private:
66  const ActionTemplate* actionTemplate;
67  std::vector<unsigned int> argumentIndices{};
68  static thread_local std::vector<WorldObject*> effectFunctionArguments;
69  static thread_local std::vector<const WorldObject*> preconditionFunctionArguments;
70  };
71 }
72 }
73 
74 #endif //GRAIL_ACTION_H
grail::planner::Action::GetArgumentIndices
const std::vector< unsigned int > & GetArgumentIndices() const
Definition: Action.cpp:38
grail::planner::Action::GetType
int GetType() const
Definition: Action.cpp:60
grail::planner::Action
Definition: Action.hh:16
grail::planner::WorldState
Definition: WorldState.hh:20
grail::planner::Action::GetCost
double GetCost(const WorldState &worldState) const
Definition: Action.cpp:28
grail::planner::ActionTemplate
Definition: ActionTemplate.hh:34
grail::planner::Action::IsLegal
bool IsLegal(const WorldState &worldState) const
Definition: Action.cpp:18
grail::planner::Action::ApplyToState
void ApplyToState(WorldState &worldState) const
Definition: Action.cpp:43
grail::planner::Action::Action
Action(const ActionTemplate &actionTemplate, std::vector< unsigned int > &&argumentIndices)
Creates a new Action object based on the template.
Definition: Action.cpp:13
grail::planner::Action::GetName
const std::string & GetName() const
Definition: Action.cpp:55