(C++)  1.0.0
A multi-platform, modular, universal engine for embedding advanced AI in games.
WorldState.hh
1 #ifndef GRAIL_WORLD_STATE_H
2 #define GRAIL_WORLD_STATE_H
3 
4 #include "WorldObject.hh"
5 #include "../Domain.hh"
6 #include <vector>
7 #include <sstream>
8 
9 namespace grail
10 {
11  namespace planning
12  {
15  {
16  public:
17  WorldState(MemoryPool& memory);
18  WorldState(const std::shared_ptr<Domain>& domain, const std::vector<WorldObject>& worldObjects, MemoryPool& memory);
19  WorldState(const WorldState& other);
20  WorldState(WorldState&& other) = default;
21  virtual ~WorldState() = default;
22 
23  WorldState& operator=(const WorldState& other);
24  WorldState& operator=(WorldState&& other) = default;
25 
26  bool operator==(const WorldState& other) const;
27 
28  std::vector<class Action> GetLegalActions() const;
29  std::vector<std::vector<unsigned int>> GenerateParameterLists(const std::vector<std::vector<unsigned int>>& precedingParameterLists, unsigned int searchedTypeIndex) const;
30 
31  const WorldObject* GetObjectByIndex(unsigned int index) const;
32  WorldObject* GetObjectByIndex(unsigned int index);
33  const std::map<unsigned int, WorldObject>& GetObjectMap() const;
34  std::shared_ptr<Domain> GetDomain() const;
35 
36  WorldObject& AddObject(const std::string& typeName);
37 
40  void RemoveObject(unsigned int objectIndex);
41  void AddQueuedObjects();
42  void RemoveQueuedObjects();
43 
45  std::vector<const WorldObject*> GetObjectsOfType(const std::string& typeName) const;
46 
48  std::vector<WorldObject*> GetObjectsOfType(const std::string& typeName);
49 
51  int CountObjectsOfType(const std::string& typeName) const;
52 
53  private:
54  std::shared_ptr<Domain> domain = nullptr;
55  std::map<unsigned int, WorldObject> objects{};
56  std::vector<WorldObject> objectsToAdd{};
57  std::vector<unsigned int> indicesToRemove{};
58  unsigned int nextIndex = 0;
59  };
60  }
61 }
62 #endif //GRAIL_WORLD_STATE_H
The MemoryPool class - preallocated memory container for optimization issues.
Definition: MemoryPool.hh:74
Definition: ParametrizedObject.h:21
Definition: WorldObject.hh:14
A class representing planner world state.
Definition: WorldState.hh:15
std::vector< const WorldObject * > GetObjectsOfType(const std::string &typeName) const
Definition: WorldState.cpp:108
int CountObjectsOfType(const std::string &typeName) const
Definition: WorldState.cpp:136
void RemoveObject(unsigned int objectIndex)
Definition: WorldState.cpp:84