HOG2
Map2DSectorAbstractionEnvironment.h
Go to the documentation of this file.
1 //
2 // Map2DSectorAbstractionEnvironment.h
3 // hog2 mac native demos
4 //
5 // Created by Nathan Sturtevant on 5/23/18.
6 // Copyright © 2018 NS Software. All rights reserved.
7 //
8 
9 #ifndef Map2DSectorAbstractionEnvironment_h
10 #define Map2DSectorAbstractionEnvironment_h
11 
12 #include <stdio.h>
13 #include "Map2DEnvironment.h"
15 
17 {
18  int sector;
19  int region;
20 };
21 
22 struct abstractMove {
23  int direction;
24  int region;
25 };
26 
27 bool operator==(const abstractGridState &, const abstractGridState &);
28 
29 class Map2DSectorAbstraction : public SearchEnvironment<abstractGridState, abstractMove> {
30 public:
31  Map2DSectorAbstraction(Map *m, int sectorSize);
33  void GetSuccessors(const abstractGridState &nodeID, std::vector<abstractGridState> &neighbors) const;
34  void GetActions(const abstractGridState &nodeID, std::vector<abstractMove> &actions) const;
35 
36  virtual void ApplyAction(abstractGridState &s, abstractMove a) const;
37 
38  xyLoc GetState(const abstractGridState &loc) const;
40 
41  bool InvertAction(abstractMove &a) const
42  { return false; }
43 
45  virtual double HCost(const abstractGridState &node1, const abstractGridState &node2) const;
46 
47  virtual double GCost(const abstractGridState &node1, const abstractGridState &node2) const;
48  virtual double GCost(const abstractGridState &node, const abstractMove &act) const;
49  virtual bool GoalTest(const abstractGridState &node, const abstractGridState &goal) const;
50 
51  virtual uint64_t GetStateHash(const abstractGridState &node) const;
52 
53  virtual uint64_t GetActionHash(abstractMove act) const;
54 
55  virtual void OpenGLDraw() const {};
56  virtual void OpenGLDraw(const abstractGridState&) const {};
58  virtual void OpenGLDraw(const abstractGridState&, const abstractGridState&, float) const {}
59  virtual void OpenGLDraw(const abstractGridState&, const abstractMove&) const {};
60  virtual void GLLabelabstractGridState(const abstractGridState&, const char *) const {}
61  virtual void GLDrawLine(const abstractGridState &x, const abstractGridState &y) const {}
62 
63  virtual void Draw(Graphics::Display &display) const;
64  virtual void Draw(Graphics::Display &display, const abstractGridState&) const;
65  virtual void DrawLine(Graphics::Display &display, const abstractGridState &x, const abstractGridState &y, float width = 1.0) const;
66 
67 private:
68  Map *map;
71  mutable std::vector<tempEdgeData> actions;
72  mutable std::vector<abstractGridState> nbr;
73 };
74 
75 #endif /* Map2DSectorAbstractionEnvironment_h */
Map2DSectorAbstraction::me
MapEnvironment * me
Definition: Map2DSectorAbstractionEnvironment.h:69
Map2DSectorAbstraction::actions
std::vector< tempEdgeData > actions
Definition: Map2DSectorAbstractionEnvironment.h:71
Map2DSectorAbstraction::GCost
virtual double GCost(const abstractGridState &node1, const abstractGridState &node2) const
Definition: Map2DSectorAbstractionEnvironment.cpp:88
Map2DSectorAbstraction::GetAbstractState
abstractGridState GetAbstractState(const xyLoc &loc) const
Definition: Map2DSectorAbstractionEnvironment.cpp:66
abstractMove::direction
int direction
Definition: Map2DSectorAbstractionEnvironment.h:23
Map2DSectorAbstraction::DrawLine
virtual void DrawLine(Graphics::Display &display, const abstractGridState &x, const abstractGridState &y, float width=1.0) const
Definition: Map2DSectorAbstractionEnvironment.cpp:158
Map2DSectorAbstraction::msa
MinimalSectorAbstraction * msa
Definition: Map2DSectorAbstractionEnvironment.h:70
Map2DSectorAbstraction::GetActionHash
virtual uint64_t GetActionHash(abstractMove act) const
Definition: Map2DSectorAbstractionEnvironment.cpp:110
Map2DSectorAbstraction::GoalTest
virtual bool GoalTest(const abstractGridState &node, const abstractGridState &goal) const
Definition: Map2DSectorAbstractionEnvironment.cpp:98
xyLoc
Definition: Map2DEnvironment.h:37
width
int width
Definition: SFML_HOG.cpp:54
MinimalSectorAbstraction
MinimalSectorAbstraction.
Definition: MinimalSectorAbstraction.h:92
abstractGridState::sector
int sector
Definition: Map2DSectorAbstractionEnvironment.h:18
Map2DEnvironment.h
Map2DSectorAbstraction::Draw
virtual void Draw(Graphics::Display &display) const
Definition: Map2DSectorAbstractionEnvironment.cpp:116
MinimalSectorAbstraction.h
Map2DSectorAbstraction::OpenGLDraw
virtual void OpenGLDraw(const abstractGridState &) const
Definition: Map2DSectorAbstractionEnvironment.h:56
MapEnvironment
Definition: Map2DEnvironment.h:133
loc
Definition: MapGenerators.cpp:296
Map2DSectorAbstraction::GLLabelabstractGridState
virtual void GLLabelabstractGridState(const abstractGridState &, const char *) const
Definition: Map2DSectorAbstractionEnvironment.h:60
Graphics::Display
Definition: Graphics.h:146
Map2DSectorAbstraction::Map2DSectorAbstraction
Map2DSectorAbstraction(Map *m, int sectorSize)
Definition: Map2DSectorAbstractionEnvironment.cpp:16
abstractMove
Definition: Map2DSectorAbstractionEnvironment.h:22
Map2DSectorAbstraction::~Map2DSectorAbstraction
~Map2DSectorAbstraction()
Definition: Map2DSectorAbstractionEnvironment.cpp:23
abstractGridState
Definition: Map2DSectorAbstractionEnvironment.h:16
Map2DSectorAbstraction::GetStateHash
virtual uint64_t GetStateHash(const abstractGridState &node) const
Definition: Map2DSectorAbstractionEnvironment.cpp:104
abstractMove::region
int region
Definition: Map2DSectorAbstractionEnvironment.h:24
Map2DSectorAbstraction::ApplyAction
virtual void ApplyAction(abstractGridState &s, abstractMove a) const
Definition: Map2DSectorAbstractionEnvironment.cpp:53
Map2DSectorAbstraction::OpenGLDraw
virtual void OpenGLDraw(const abstractGridState &, const abstractGridState &, float) const
Draw the transition at some percentage 0...1 between two abstractGridStates.
Definition: Map2DSectorAbstractionEnvironment.h:58
Map2DSectorAbstraction::GetState
xyLoc GetState(const abstractGridState &loc) const
Definition: Map2DSectorAbstractionEnvironment.cpp:59
abstractGridState::region
int region
Definition: Map2DSectorAbstractionEnvironment.h:19
operator==
bool operator==(const abstractGridState &, const abstractGridState &)
Definition: Map2DSectorAbstractionEnvironment.cpp:11
Map2DSectorAbstraction::InvertAction
bool InvertAction(abstractMove &a) const
Definition: Map2DSectorAbstractionEnvironment.h:41
Map2DSectorAbstraction::OpenGLDraw
virtual void OpenGLDraw() const
Definition: Map2DSectorAbstractionEnvironment.h:55
Map2DSectorAbstraction::OpenGLDraw
virtual void OpenGLDraw(const abstractGridState &, const abstractMove &) const
Definition: Map2DSectorAbstractionEnvironment.h:59
Map2DSectorAbstraction::map
Map * map
Definition: Map2DSectorAbstractionEnvironment.h:68
Map2DSectorAbstraction::nbr
std::vector< abstractGridState > nbr
Definition: Map2DSectorAbstractionEnvironment.h:72
Map2DSectorAbstraction::GetActions
void GetActions(const abstractGridState &nodeID, std::vector< abstractMove > &actions) const
Definition: Map2DSectorAbstractionEnvironment.cpp:42
Map2DSectorAbstraction::GLDrawLine
virtual void GLDrawLine(const abstractGridState &x, const abstractGridState &y) const
Definition: Map2DSectorAbstractionEnvironment.h:61
Map2DSectorAbstraction
Definition: Map2DSectorAbstractionEnvironment.h:29
Map2DSectorAbstraction::HCost
virtual double HCost(const abstractGridState &node1, const abstractGridState &node2) const
Heuristic value between two arbitrary nodes.
Definition: Map2DSectorAbstractionEnvironment.cpp:75
SearchEnvironment
Definition: SearchEnvironment.h:30
Map2DSectorAbstraction::GetSuccessors
void GetSuccessors(const abstractGridState &nodeID, std::vector< abstractGridState > &neighbors) const
Definition: Map2DSectorAbstractionEnvironment.cpp:29
node
Nodes to be stored within a Graph.
Definition: Graph.h:170
Map
A tile-based representation of the world.
Definition: Map.h:142