Grail (C++)  1.3.0
A multi-platform, modular, universal engine for embedding advanced AI in games.
PlannerSnapshots.h
1 // Copyright QED Software 2023.
2 
3 #ifndef GRAIL_PLANNER_SNAPSHOT_H
4 #define GRAIL_PLANNER_SNAPSHOT_H
5 
6 #include "Flatbuffers/PlannerWorldObjectSnapshot_generated.h"
7 #include "Flatbuffers/PlannerActionSnapshot_generated.h"
8 #include "Flatbuffers/PlannerIterationSnapshot_generated.h"
9 #include "Flatbuffers/PlannerReasonerSnapshot_generated.h"
10 
11 #include <limits>
12 #include <map>
13 #include <string>
14 #include <utility>
15 #include <vector>
16 
17 namespace grail
18 {
19  namespace planner
20  {
21  class WorldState;
22  class Action;
23  class ParametrizedObject;
24  }
25 
26 namespace data
27 {
31  {
32  std::string typeName;
33  unsigned int objectId = 0;
34 
36  std::map<std::string, std::string> objectData{};
37  };
38 
39  flatbuffers::Offset<generated::PlannerWorldObjectSnapshot> Pack(flatbuffers::FlatBufferBuilder& builder,
40  const PlannerWorldObjectSnapshot& snapshot);
41  PlannerWorldObjectSnapshot Unpack(const generated::PlannerWorldObjectSnapshot& snapshot);
42 
46  {
47  std::string name{};
48  std::vector<std::string> parametrization{};
49  std::vector<PlannerWorldObjectSnapshot> resultingWorldState{};
50 
52  const planner::WorldState& worldState,
53  const planner::WorldState& previousWorldState);
54  PlannerActionSnapshot() = default;
55 
56  private:
57  void AddParametrizedObjectSnapshot(const planner::ParametrizedObject& parametrizedObject,
58  unsigned int objectId,
59  const std::string& objectName);
60  };
61 
62  flatbuffers::Offset<generated::PlannerActionSnapshot> Pack(flatbuffers::FlatBufferBuilder& builder,
63  const PlannerActionSnapshot& snapshot);
64  PlannerActionSnapshot Unpack(const generated::PlannerActionSnapshot& snapshot);
65 
69  {
71  std::size_t iterationNumber = 0;
72 
74  std::vector<PlannerActionSnapshot> planActions = {};
75 
76  bool goalReached = false;
77 
79  double score = 0;
80  double totalCost = std::numeric_limits<double>::max();
81  PlannerIterationSnapshot(std::size_t keyIterationIndex);
82  PlannerIterationSnapshot() = default;
83  };
84 
85  flatbuffers::Offset<generated::PlannerIterationSnapshot> Pack(flatbuffers::FlatBufferBuilder& builder,
86  const PlannerIterationSnapshot& snapshot);
87  PlannerIterationSnapshot Unpack(const generated::PlannerIterationSnapshot& snapshot);
88 
91 
93  {
94  std::vector<PlannerIterationSnapshot> iterations = {};
95 
96  float absoluteTime = 0;
97  float relativeTime = 0;
98  std::size_t entityId = 0;
99  };
100 
101  flatbuffers::Offset<generated::PlannerReasonerSnapshot> Pack(flatbuffers::FlatBufferBuilder& builder,
102  const PlannerReasonerSnapshot& snapshot);
103  PlannerReasonerSnapshot Unpack(const generated::PlannerReasonerSnapshot& snapshot);
104 }
105 }
106 
107 #endif
grail::planner::Action
Definition: Action.hh:12
grail::data::PlannerWorldObjectSnapshot
Definition: PlannerSnapshots.h:30
grail::planner::WorldState
A class representing planner world state.
Definition: WorldState.hh:16
grail::data::PlannerIterationSnapshot
Definition: PlannerSnapshots.h:68
grail::data::PlannerIterationSnapshot::iterationNumber
std::size_t iterationNumber
The object contains info about iteration with number = IterationNumber.
Definition: PlannerSnapshots.h:71
grail::data::PlannerReasonerSnapshot
Definition: PlannerSnapshots.h:92
grail::data::PlannerIterationSnapshot::score
double score
Heuristic score of the plan.
Definition: PlannerSnapshots.h:79
grail::data::PlannerWorldObjectSnapshot::objectData
std::map< std::string, std::string > objectData
Internal state of the WorldObject.
Definition: PlannerSnapshots.h:36
grail::planner::ParametrizedObject
Definition: ParametrizedObject.hh:27
grail::data::PlannerIterationSnapshot::planActions
std::vector< PlannerActionSnapshot > planActions
In the serialized iteration, the plan consists of planActions.
Definition: PlannerSnapshots.h:74
grail::data::PlannerActionSnapshot
Definition: PlannerSnapshots.h:45