HOG2
GraphEnvironment.h
Go to the documentation of this file.
1 /*
2  * GraphEnvironment.h
3  * hog2
4  *
5  * Created by Nathan Sturtevant on 5/29/07.
6  * Copyright 2007 Nathan Sturtevant, University of Alberta. All rights reserved.
7  *
8  */
9 
10 #ifndef GRAPHENVIRONMENT_H
11 #define GRAPHENVIRONMENT_H
12 
13 
14 #include "SearchEnvironment.h"
15 #include "UnitSimulation.h"
16 #include "Graph.h"
17 //#include "GraphAbstraction.h"
18 #include "GLUtil.h"
19 
20 #include <iostream>
21 #include <stdint.h>
22 #include <unordered_map>
23 #include <functional>
24 
25 #ifndef UINT32_MAX
26 #define UINT32_MAX 4294967295U
27 #endif
28 #ifndef UINT16_MAX
29 #define UINT16_MAX 65535
30 #endif
31 
32 typedef unsigned long graphState;
33 
34 class graphMove {
35 public:
37  graphMove(uint32_t f, uint32_t t) :from(f), to(t) {}
38  uint32_t from, to;
39 };
40 
41 
42 static bool operator==(const graphMove &l1, const graphMove &l2)
43 {
44  return (l1.from == l2.from)&&(l1.to==l2.to);
45 }
46 
47 namespace GraphSearchConstants
48 {
49  enum {
50  kHCost = 0, // this is relative to a single goal
55  kMapX = 9,
56  kMapY = 10,
58  };
59 
60  const double kStraightEdgeCost = 1.0;
61  const double kDiagonalEdgeCost = ROOT_TWO;
62 
63  Graph *GetEightConnectedGraph(Map *m, bool directed = true);
64  Graph *GetFourConnectedGraph(Map *m, bool directed = true);
65  Graph *GetGraph(Map *m);
67  void AddNodesToGraph(Map *m, Graph *g);
68  void AddEdges(Map *m, Graph *g, int x, int y,
69  bool directed = true,
70  double straigtEdgeCost = 1.0,
71  double diagEdgeCost = ROOT_TWO,
72  int straightEdgeProb = 100,
73  int diagEdgeProb = 100);
74 }
75 
76 // pure virtual class
78 public:
79  virtual ~GraphHeuristic() { }
80  virtual Graph *GetGraph() = 0;
81  virtual double HCost(const graphState &state1, const graphState &state2) const = 0;
82  // if one is better as the start or goal state, this can swap for you.
83  virtual void ChooseStartGoal(graphState &/*start*/, graphState &/*goal*/) {}
84  virtual void OpenGLDraw() const {}
85 private:
86 };
87 
89 public:
92  virtual Graph *GetGraph() { return g; }
93  void AddHeuristic(GraphHeuristic *h) { heuristics.push_back(h); }
94  virtual double HCost(const graphState &state1, const graphState &state2) const
95  {
96  double cost = 0;
97  for (unsigned int x = 0; x < heuristics.size(); x++)
98  cost = max(cost, heuristics[x]->HCost(state1, state2));
99  return cost;
100  }
101 private:
102  std::vector<GraphHeuristic*> heuristics;
104 };
105 
106 // this class uses the label on a graph for a heuristic
107 // but the heuristic is only available for a single goal node
109 public:
111  { g = graph; goal = target; }
112  Graph *GetGraph() { return g; }
113  double HCost(const graphState &state1, const graphState &state2) const
114  {
115  if (state2 == goal)
117  return 0;
118  }
119 private:
122 };
123 
125 public:
127  :m(map), g(graph) {}
128  Graph *GetGraph() { return g; }
129  double HCost(const graphState &state1, const graphState &state2) const
130  {
131  int x1 = g->GetNode(state1)->GetLabelL(GraphSearchConstants::kMapX);
132  int y1 = g->GetNode(state1)->GetLabelL(GraphSearchConstants::kMapY);
133  int x2 = g->GetNode(state2)->GetLabelL(GraphSearchConstants::kMapX);
134  int y2 = g->GetNode(state2)->GetLabelL(GraphSearchConstants::kMapY);
135 
136  double a = ((x1>x2)?(x1-x2):(x2-x1));
137  double b = ((y1>y2)?(y1-y2):(y2-y1));
138  return (a>b)?(b*ROOT_TWO+a-b):(a*ROOT_TWO+b-a);
139  }
140 private:
141  Map *m;
143 };
144 
145 /*
146 class GraphAbstractionHeuristic : public GraphHeuristic {
147 public:
148  GraphAbstractionHeuristic(MapAbstraction *mabs, int lev)
149  :mAbs(mabs), level(lev) { }
150  Graph *GetGraph() { return mAbs->GetAbstractGraph(level); }
151  double HCost(const graphState &state1, const graphState &state2) const
152  {
153  return mAbs->h(mAbs->GetAbstractGraph(level)->GetNode(state1),
154  mAbs->GetAbstractGraph(level)->GetNode(state2));
155  }
156 private:
157  MapAbstraction *mAbs;
158  int level;
159 };
160 */
162 public:
163  GraphMapPerfectHeuristic(Map *map, Graph *graph):m(map), g(graph)
164  {
165  prob = 0.5;
166  fillProbTable();
167  }
168  Graph *GetGraph() { return g; }
169  void SetProbability(double p) { prob = p; }
170  double HCost(const graphState &state1, const graphState &state2) const
171  { // warning: in this implementation HCost(s1,s2) != HCost(s2,s1)
172 
173  if (probTable[int(state1)]) {
174  int x1 = g->GetNode(state1)->GetLabelL(GraphSearchConstants::kMapX);
175  int y1 = g->GetNode(state1)->GetLabelL(GraphSearchConstants::kMapY);
176  int x2 = g->GetNode(state2)->GetLabelL(GraphSearchConstants::kMapX);
177  int y2 = g->GetNode(state2)->GetLabelL(GraphSearchConstants::kMapY);
178  return GetOctileDistance(x1-x2, y1-y2);
179  }
180  else
181  return 0;
182  }
184  {
185  delete probTable;
186  }
187  double prob;
188 private:
189  double GetOctileDistance(double dx, double dy) const
190  {
191  dx = fabs(dx);
192  dy = fabs(dy);
193 
194  if (dx > dy)
195  return dx-dy + sqrt(2)*dy;
196  else
197  return dy-dx + sqrt(2)*dx;
198  }
200  {
201  int size = m->GetMapWidth() * m->GetMapHeight();
202  probTable = (bool*)malloc( size );
203  for (int i=0;i<size;i++) {
204 #pragma message("drand was removed here. New code hasn't been tested.")
205  if ((random()%10000)/10000.0 < prob)
206  probTable[i] = 1;
207  else
208  probTable[i] = 0;
209  }
210  }
211  Map *m;
213  bool* probTable;
214 };
215 
220 };
221 
223 public:
226  virtual double HCost(const graphState &state1, const graphState &state2) const;
227  void AddHeuristic(node *n = 0);
228  int GetNumHeuristics() { return heuristics.size(); }
230  Graph *GetGraph() { return g; }
231  void ChooseStartGoal(graphState &start, graphState &goal);
232  virtual void OpenGLDraw() const;
233 protected:
234  void GetOptimalDistances(node *n, std::vector<double> &values);
235  void AddHeuristic(std::vector<double> &values, graphState location);
236  node *FindFarNode(node *n);
237  node *FindAvoidNode(node *n);
238  node *FindBestChild(int best, std::vector<double> &dist,
239  std::vector<double> &weight);
240  void ComputeSizes(node *n, std::vector<double> &dist,
241  std::vector<double> &weight, std::vector<double> &sizes);
242 
245  std::vector<std::vector<double> > heuristics;
246  std::vector<graphState> locations;
247 
248  // for avoid node computation
249  std::vector<double> dist;
250  std::vector<double> weight;
251  std::vector<double> sizes;
252 };
253 
255 {
256  kIgnore = 0, // don't combine with database
257  kRandom = 1, // combine random selection of databases
258  kMax = 2, // take max of all heuristics
259  kGridMax = 3, // 0 on non-grid points
260  kCompressed = 4 // simulates compression down to O(N) memory
261 };
262 
263 
265 public:
267  double HCost(const graphState &state1, const graphState &state2) const;
269  { hmode = mode; if (compressed) hmode = kCompressed; }
271  void SetNumUsedHeuristics(int count)
274  { return numHeuristics; }
275  void Compress();
276  virtual void OpenGLDraw() const;
277 
279  { displayHeuristic = (displayHeuristic+1)%(heuristics.size()+1); }
280 private:
281  void FillInCache(std::vector<double> &vals,
282  std::vector<double> &errors,
283  graphState state2) const;
288  Map *m;
289 };
290 
291 class GraphEnvironment : public SearchEnvironment<graphState, graphMove> {
292 public:
295  virtual ~GraphEnvironment();
296  virtual void GetSuccessors(const graphState &stateID, std::vector<graphState> &neighbors) const;
297  virtual int GetNumSuccessors(const graphState &stateID) const;
298  virtual void GetActions(const graphState &stateID, std::vector<graphMove> &actions) const;
299  virtual graphMove GetAction(const graphState &s1, const graphState &s2) const;
300  virtual void ApplyAction(graphState &s, graphMove a) const;
301  virtual bool InvertAction(graphMove &a) const;
302 
303  void SetDirected(bool b) { directed = b; }
304 
306  virtual double HCost(const graphState &state1, const graphState &state2) const;
307  virtual double GCost(const graphState &state1, const graphState &state2) const;
308  virtual double GCost(const graphState &state1, const graphMove &state2) const;
309  virtual bool GoalTest(const graphState &state, const graphState &goal) const;
310  virtual uint64_t GetMaxHash() const { return g->GetNumNodes(); }
311  virtual uint64_t GetStateHash(const graphState &state) const;
312  virtual void GetStateFromHash(uint64_t parent, graphState &s) const;
313  virtual uint64_t GetActionHash(graphMove act) const;
314  virtual void OpenGLDraw() const;
315  virtual void OpenGLDraw(const graphState &s) const;
316  virtual void OpenGLDraw(const graphState &s, const graphMove &gm) const;
317  virtual void OpenGLDraw(const graphState &s, const graphState&, float) const { OpenGLDraw(s); }
318  virtual void GLDrawLine(const graphState &x, const graphState &y) const;
319  virtual void GLLabelState(const graphState&, const char *) const;
320 
321  std::string SVGHeader() const;
322  std::string SVGDraw() const;
323  std::string SVGDraw(const graphState &s) const;
324  std::string SVGLabelState(const graphState &s, const char *) const;
325 
326  virtual void Draw(Graphics::Display &disp) const;
327  void DrawLERP(Graphics::Display &disp, Graph *a, Graph *b, float mix) const;
328  void DrawLERP(Graphics::Display &disp, Graph *a, Graph *b, float mix, std::function<float(float, float, float)> l1, std::function<float(float, float, float)> l2) const;
329  void DrawLERP(Graphics::Display &disp, Graph *a, Graph *b, graphState sa, graphState sb, float mix,
330  std::function<float(float, float, float)> l1,
331  std::function<float(float, float, float)> l2) const;
332 
333  virtual void Draw(Graphics::Display &disp, const graphState &l) const;
334  virtual void DrawStateLabel(Graphics::Display &disp, const graphState &l1, const char *txt) const;
335  virtual void DrawLine(Graphics::Display &disp, const graphState &x, const graphState &y, double width = 1.0) const;
336  virtual void DrawLine(Graphics::Display &disp, float x1, float y1, float x2, float y2, double width = 1.0) const;
337  Graphics::point GetLocation(const graphState &s) const;
338  Graph *GetGraph() { return g; };
339 
340  virtual void StoreGoal(graphState &) {}
341  virtual void ClearGoal() {}
342  virtual bool IsGoalStored() const {return false;}
343 
344  virtual double HCost(const graphState &) const {
345  fprintf(stderr, "ERROR: Single State HCost not implemented for GraphEnvironment\n");
346  exit(1); return -1.0;}
347 
348  virtual bool GoalTest(const graphState &) const {
349  fprintf(stderr, "ERROR: Single State Goal Test not implemented for GraphEnvironment\n");
350  exit(1); return false;
351  }
352  void SetIntegerEdgeCosts(bool val) { integerEdgeCosts = val; }
353  void SetDrawEdgeCosts(bool val) { drawEdgeCosts = val; }
354  void SetDrawNodeLabels(bool val) { drawNodeLabels = val; }
355  void SetNodeScale(double v) { nodeScale = v; }
356  double GetNodeScale() { return nodeScale; }
357 protected:
358  bool directed;
359  Map *m;
365  double nodeScale;
366 };
367 /*
368 class AbstractionGraphEnvironment: public GraphEnvironment {
369  public:
370  AbstractionGraphEnvironment( GraphAbstraction *gabs, unsigned int level, GraphHeuristic *gh );
371  ~AbstractionGraphEnvironment();
372 
373  virtual void OpenGLDraw() const;
374  virtual void OpenGLDraw(const graphState &s) const { GraphEnvironment::OpenGLDraw(s); }
375  virtual void OpenGLDraw(const graphState &s, const graphMove &gm) const { GraphEnvironment::OpenGLDraw(s, gm); }
376  virtual void OpenGLDraw(const graphState &s, const graphState&, float) const { OpenGLDraw(s); }
377 
378  double Scale() { return graphscale; };
379 
380 protected:
381  GraphAbstraction *gabs;
382  double graphscale;
383 };
384 */
386 
387 #endif
GraphHeuristicContainer::GetGraph
virtual Graph * GetGraph()
Definition: GraphEnvironment.h:92
GraphSearchConstants::kTemporaryLabel
@ kTemporaryLabel
Definition: GraphEnvironment.h:54
GraphMapHeuristic::GetGraph
Graph * GetGraph()
Definition: GraphEnvironment.h:128
Graphics::point
Definition: Graphics.h:32
GraphHeuristicContainer::AddHeuristic
void AddHeuristic(GraphHeuristic *h)
Definition: GraphEnvironment.h:93
GraphMapPerfectHeuristic::GetOctileDistance
double GetOctileDistance(double dx, double dy) const
Definition: GraphEnvironment.h:189
kMax
@ kMax
Definition: GraphEnvironment.h:258
kFarPlacement
@ kFarPlacement
Definition: GraphEnvironment.h:217
GraphMapInconsistentHeuristic::SetMode
void SetMode(tHeuristicCombination mode)
Definition: GraphEnvironment.h:268
GraphMapPerfectHeuristic::prob
double prob
Definition: GraphEnvironment.h:187
GraphDistanceHeuristic::AddHeuristic
void AddHeuristic(node *n=0)
Definition: GraphEnvironment.cpp:1564
GraphEnvironment::nodeScale
double nodeScale
Definition: GraphEnvironment.h:365
GraphLabelHeuristic::g
Graph * g
Definition: GraphEnvironment.h:121
GraphEnvironment::GetLocation
Graphics::point GetLocation(const graphState &s) const
Definition: GraphEnvironment.cpp:826
GraphHeuristicContainer::heuristics
std::vector< GraphHeuristic * > heuristics
Definition: GraphEnvironment.h:102
UnitSimulation.h
Graph.h
GraphDistanceHeuristic::heuristics
std::vector< std::vector< double > > heuristics
Definition: GraphEnvironment.h:245
graphMove
Definition: GraphEnvironment.h:34
GraphEnvironment::OpenGLDraw
virtual void OpenGLDraw() const
Definition: GraphEnvironment.cpp:206
GraphLabelHeuristic::HCost
double HCost(const graphState &state1, const graphState &state2) const
Definition: GraphEnvironment.h:113
GraphMapPerfectHeuristic::GraphMapPerfectHeuristic
GraphMapPerfectHeuristic(Map *map, Graph *graph)
Definition: GraphEnvironment.h:163
GraphMapPerfectHeuristic::SetProbability
void SetProbability(double p)
Definition: GraphEnvironment.h:169
UINT32_MAX
#define UINT32_MAX
Definition: GraphEnvironment.h:26
graphState
unsigned long graphState
Definition: GraphEnvironment.h:32
GraphSearchConstants::AddNodesToGraph
void AddNodesToGraph(Map *m, Graph *g)
Definition: GraphEnvironment.cpp:884
GraphSearchConstants
Definition: GraphEnvironment.cpp:838
graphMove::graphMove
graphMove(uint32_t f, uint32_t t)
Definition: GraphEnvironment.h:37
GraphDistanceHeuristic::dist
std::vector< double > dist
Definition: GraphEnvironment.h:249
GraphDistanceHeuristic::GetNumHeuristics
int GetNumHeuristics()
Definition: GraphEnvironment.h:228
GraphMapHeuristic::g
Graph * g
Definition: GraphEnvironment.h:142
GraphMapPerfectHeuristic::fillProbTable
void fillProbTable()
Definition: GraphEnvironment.h:199
GraphHeuristicContainer::HCost
virtual double HCost(const graphState &state1, const graphState &state2) const
Definition: GraphEnvironment.h:94
GraphSearchConstants::GetEightConnectedGraph
Graph * GetEightConnectedGraph(Map *m, bool directed)
Definition: GraphEnvironment.cpp:854
GraphEnvironment::m
Map * m
Definition: GraphEnvironment.h:359
graphMove::graphMove
graphMove()
Definition: GraphEnvironment.h:36
GraphDistanceHeuristic::sizes
std::vector< double > sizes
Definition: GraphEnvironment.h:251
GraphDistanceHeuristic::ComputeSizes
void ComputeSizes(node *n, std::vector< double > &dist, std::vector< double > &weight, std::vector< double > &sizes)
Definition: GraphEnvironment.cpp:1695
GraphDistanceHeuristic::g
Graph * g
Definition: GraphEnvironment.h:244
GraphSimulation
UnitSimulation< graphState, graphMove, GraphEnvironment > GraphSimulation
Definition: GraphEnvironment.h:385
graphMove::from
uint32_t from
Definition: GraphEnvironment.h:38
GraphMapInconsistentHeuristic::IncreaseDisplayHeuristic
void IncreaseDisplayHeuristic()
Definition: GraphEnvironment.h:278
GraphDistanceHeuristic
Definition: GraphEnvironment.h:222
GraphLabelHeuristic::goal
graphState goal
Definition: GraphEnvironment.h:120
kGridMax
@ kGridMax
Definition: GraphEnvironment.h:259
GraphEnvironment::GetSuccessors
virtual void GetSuccessors(const graphState &stateID, std::vector< graphState > &neighbors) const
Definition: GraphEnvironment.cpp:75
GraphHeuristic::OpenGLDraw
virtual void OpenGLDraw() const
Definition: GraphEnvironment.h:84
GraphLabelHeuristic::GraphLabelHeuristic
GraphLabelHeuristic(Graph *graph, graphState target)
Definition: GraphEnvironment.h:110
GraphEnvironment::~GraphEnvironment
virtual ~GraphEnvironment()
Definition: GraphEnvironment.cpp:52
width
int width
Definition: SFML_HOG.cpp:54
GraphMapInconsistentHeuristic
Definition: GraphEnvironment.h:264
GraphMapInconsistentHeuristic::hmode
tHeuristicCombination hmode
Definition: GraphEnvironment.h:284
GraphMapInconsistentHeuristic::GraphMapInconsistentHeuristic
GraphMapInconsistentHeuristic(Map *map, Graph *graph)
Definition: GraphEnvironment.cpp:1167
GraphSearchConstants::kMapY
@ kMapY
Definition: GraphEnvironment.h:56
GraphMapInconsistentHeuristic::SetNumUsedHeuristics
void SetNumUsedHeuristics(int count)
Definition: GraphEnvironment.h:271
GraphSearchConstants::kXCoordinate
@ kXCoordinate
Definition: GraphEnvironment.h:51
GraphEnvironment::SetNodeScale
void SetNodeScale(double v)
Definition: GraphEnvironment.h:355
Graph
A generic Graph class.
Definition: Graph.h:66
GraphMapInconsistentHeuristic::GetMode
tHeuristicCombination GetMode()
Definition: GraphEnvironment.h:270
GraphEnvironment::DrawLERP
void DrawLERP(Graphics::Display &disp, Graph *a, Graph *b, float mix) const
Definition: GraphEnvironment.cpp:559
Graph::GetNode
node * GetNode(unsigned long num)
Definition: Graph.cpp:152
GraphEnvironment::GoalTest
virtual bool GoalTest(const graphState &state, const graphState &goal) const
Definition: GraphEnvironment.cpp:182
GraphEnvironment::DrawStateLabel
virtual void DrawStateLabel(Graphics::Display &disp, const graphState &l1, const char *txt) const
Definition: GraphEnvironment.cpp:780
GraphEnvironment::g
Graph * g
Definition: GraphEnvironment.h:360
GraphEnvironment::OpenGLDraw
virtual void OpenGLDraw(const graphState &s, const graphState &, float) const
Draw the transition at some percentage 0...1 between two states.
Definition: GraphEnvironment.h:317
GraphLabelHeuristic
Definition: GraphEnvironment.h:108
GraphMapPerfectHeuristic::GetGraph
Graph * GetGraph()
Definition: GraphEnvironment.h:168
GraphEnvironment::GetStateHash
virtual uint64_t GetStateHash(const graphState &state) const
Definition: GraphEnvironment.cpp:187
GraphSearchConstants::kHCost
@ kHCost
Definition: GraphEnvironment.h:50
GraphEnvironment::IsGoalStored
virtual bool IsGoalStored() const
Definition: GraphEnvironment.h:342
GraphEnvironment::SetDirected
void SetDirected(bool b)
Definition: GraphEnvironment.h:303
GraphDistanceHeuristic::HCost
virtual double HCost(const graphState &state1, const graphState &state2) const
Definition: GraphEnvironment.cpp:1526
GraphEnvironment::GetOccupancyInfo
OccupancyInterface< graphState, graphMove > * GetOccupancyInfo()
Definition: GraphEnvironment.h:305
GraphLabelHeuristic::GetGraph
Graph * GetGraph()
Definition: GraphEnvironment.h:112
GraphEnvironment::drawEdgeCosts
bool drawEdgeCosts
Definition: GraphEnvironment.h:362
GraphHeuristic::GetGraph
virtual Graph * GetGraph()=0
GraphMapPerfectHeuristic::m
Map * m
Definition: GraphEnvironment.h:211
GraphDistanceHeuristic::FindAvoidNode
node * FindAvoidNode(node *n)
Definition: GraphEnvironment.cpp:1630
GraphEnvironment::InvertAction
virtual bool InvertAction(graphMove &a) const
Definition: GraphEnvironment.cpp:147
GraphMapPerfectHeuristic
Definition: GraphEnvironment.h:161
GraphMapHeuristic::m
Map * m
Definition: GraphEnvironment.h:141
GraphDistanceHeuristic::locations
std::vector< graphState > locations
Definition: GraphEnvironment.h:246
GraphEnvironment::ApplyAction
virtual void ApplyAction(graphState &s, graphMove a) const
Definition: GraphEnvironment.cpp:141
graphMove::to
uint32_t to
Definition: GraphEnvironment.h:38
GraphMapInconsistentHeuristic::GetNumUsedHeuristics
int GetNumUsedHeuristics()
Definition: GraphEnvironment.h:273
kAvoidPlacement
@ kAvoidPlacement
Definition: GraphEnvironment.h:219
GraphEnvironment::directed
bool directed
Definition: GraphEnvironment.h:358
Graphics::Display
Definition: Graphics.h:146
kRandom
@ kRandom
Definition: GraphEnvironment.h:257
GraphMapInconsistentHeuristic::HCost
double HCost(const graphState &state1, const graphState &state2) const
Definition: GraphEnvironment.cpp:1199
GraphEnvironment::GetMaxHash
virtual uint64_t GetMaxHash() const
Definition: GraphEnvironment.h:310
ROOT_TWO
static const double ROOT_TWO
Definition: GLUtil.h:61
GraphEnvironment::GetStateFromHash
virtual void GetStateFromHash(uint64_t parent, graphState &s) const
Definition: GraphEnvironment.cpp:192
GraphSearchConstants::GetFourConnectedGraph
Graph * GetFourConnectedGraph(Map *m, bool directed)
Definition: GraphEnvironment.cpp:869
Map::GetMapWidth
long GetMapWidth() const
return the width of the map
Definition: Map.h:163
kCompressed
@ kCompressed
Definition: GraphEnvironment.h:260
GraphMapPerfectHeuristic::~GraphMapPerfectHeuristic
~GraphMapPerfectHeuristic()
Definition: GraphEnvironment.h:183
GraphHeuristicContainer::~GraphHeuristicContainer
~GraphHeuristicContainer()
Definition: GraphEnvironment.h:91
GraphEnvironment::Draw
virtual void Draw(Graphics::Display &disp) const
Definition: GraphEnvironment.cpp:643
GraphEnvironment::GCost
virtual double GCost(const graphState &state1, const graphState &state2) const
Definition: GraphEnvironment.cpp:173
GraphEnvironment::integerEdgeCosts
bool integerEdgeCosts
Definition: GraphEnvironment.h:363
GraphEnvironment::DrawLine
virtual void DrawLine(Graphics::Display &disp, const graphState &x, const graphState &y, double width=1.0) const
Definition: GraphEnvironment.cpp:797
GraphEnvironment::SVGLabelState
std::string SVGLabelState(const graphState &s, const char *) const
Definition: GraphEnvironment.cpp:458
GraphDistanceHeuristic::ChooseStartGoal
void ChooseStartGoal(graphState &start, graphState &goal)
Definition: GraphEnvironment.cpp:1540
GraphHeuristicContainer
Definition: GraphEnvironment.h:88
GraphDistanceHeuristic::SetPlacement
void SetPlacement(placementScheme s)
Definition: GraphEnvironment.h:229
tHeuristicCombination
tHeuristicCombination
Definition: GraphEnvironment.h:254
GraphHeuristic::ChooseStartGoal
virtual void ChooseStartGoal(graphState &, graphState &)
Definition: GraphEnvironment.h:83
GraphMapPerfectHeuristic::probTable
bool * probTable
Definition: GraphEnvironment.h:213
GraphEnvironment::SetDrawEdgeCosts
void SetDrawEdgeCosts(bool val)
Definition: GraphEnvironment.h:353
GraphEnvironment::GetNumSuccessors
virtual int GetNumSuccessors(const graphState &stateID) const
Definition: GraphEnvironment.cpp:59
GraphSearchConstants::kYCoordinate
@ kYCoordinate
Definition: GraphEnvironment.h:52
GraphMapPerfectHeuristic::HCost
double HCost(const graphState &state1, const graphState &state2) const
Definition: GraphEnvironment.h:170
GraphDistanceHeuristic::GetOptimalDistances
void GetOptimalDistances(node *n, std::vector< double > &values)
Definition: GraphEnvironment.cpp:1587
max
#define max(a, b)
Definition: MinimalSectorAbstraction.cpp:40
GraphMapInconsistentHeuristic::compressed
bool compressed
Definition: GraphEnvironment.h:287
GraphEnvironment::HCost
virtual double HCost(const graphState &state1, const graphState &state2) const
Heuristic value between two arbitrary nodes.
Definition: GraphEnvironment.cpp:157
Graph::GetNumNodes
int GetNumNodes()
Definition: Graph.cpp:403
GraphMapHeuristic::HCost
double HCost(const graphState &state1, const graphState &state2) const
Definition: GraphEnvironment.h:129
GLUtil.h
GraphMapPerfectHeuristic::g
Graph * g
Definition: GraphEnvironment.h:212
GraphSearchConstants::kFirstData
@ kFirstData
Definition: GraphEnvironment.h:57
GraphDistanceHeuristic::weight
std::vector< double > weight
Definition: GraphEnvironment.h:250
GraphSearchConstants::AddEdges
void AddEdges(Map *m, Graph *g, int x, int y, bool directed, double straigtEdgeCost, double diagEdgeCost, int straightEdgeProb, int diagEdgeProb)
AddEdges(map, Graph, x, y)
Definition: GraphEnvironment.cpp:960
GraphDistanceHeuristic::FindBestChild
node * FindBestChild(int best, std::vector< double > &dist, std::vector< double > &weight)
Definition: GraphEnvironment.cpp:1743
GraphEnvironment::GLDrawLine
virtual void GLDrawLine(const graphState &x, const graphState &y) const
Definition: GraphEnvironment.cpp:419
GraphEnvironment::GetNodeScale
double GetNodeScale()
Definition: GraphEnvironment.h:356
GraphMapInconsistentHeuristic::FillInCache
void FillInCache(std::vector< double > &vals, std::vector< double > &errors, graphState state2) const
Definition: GraphEnvironment.cpp:1312
UnitSimulation
The basic simulation class for the world.
Definition: UnitSimulation.h:85
node::GetLabelF
double GetLabelF(unsigned int index) const
Definition: Graph.h:215
GraphHeuristic::~GraphHeuristic
virtual ~GraphHeuristic()
Definition: GraphEnvironment.h:79
GraphEnvironment::h
GraphHeuristic * h
Definition: GraphEnvironment.h:361
kRandomPlacement
@ kRandomPlacement
Definition: GraphEnvironment.h:218
GraphEnvironment::GetActionHash
virtual uint64_t GetActionHash(graphMove act) const
Definition: GraphEnvironment.cpp:198
GraphDistanceHeuristic::placement
placementScheme placement
Definition: GraphEnvironment.h:243
GraphSearchConstants::kMapX
@ kMapX
Definition: GraphEnvironment.h:55
Map::GetMapHeight
long GetMapHeight() const
return the height of the map
Definition: Map.h:165
GraphDistanceHeuristic::GraphDistanceHeuristic
GraphDistanceHeuristic(Graph *graph)
Definition: GraphEnvironment.h:224
GraphSearchConstants::GetUndirectedGraph
Graph * GetUndirectedGraph(Map *m)
GetMapGraph(map)
Definition: GraphEnvironment.cpp:848
GraphEnvironment::SVGDraw
std::string SVGDraw() const
Definition: GraphEnvironment.cpp:484
GraphEnvironment::GoalTest
virtual bool GoalTest(const graphState &) const
Goal Test if the goal is stored.
Definition: GraphEnvironment.h:348
GraphMapHeuristic
Definition: GraphEnvironment.h:124
GraphEnvironment::GetAction
virtual graphMove GetAction(const graphState &s1, const graphState &s2) const
Definition: GraphEnvironment.cpp:136
placementScheme
placementScheme
Definition: GraphEnvironment.h:216
GraphMapInconsistentHeuristic::Compress
void Compress()
Definition: GraphEnvironment.cpp:1296
GraphEnvironment::GLLabelState
virtual void GLLabelState(const graphState &, const char *) const
Definition: GraphEnvironment.cpp:398
GraphEnvironment::SetDrawNodeLabels
void SetDrawNodeLabels(bool val)
Definition: GraphEnvironment.h:354
GraphEnvironment::ClearGoal
virtual void ClearGoal()
Clears the goal from memory.
Definition: GraphEnvironment.h:341
GraphDistanceHeuristic::FindFarNode
node * FindFarNode(node *n)
Definition: GraphEnvironment.cpp:1778
GraphDistanceHeuristic::GetGraph
Graph * GetGraph()
Definition: GraphEnvironment.h:230
GraphEnvironment::GetActions
virtual void GetActions(const graphState &stateID, std::vector< graphMove > &actions) const
Definition: GraphEnvironment.cpp:105
GraphSearchConstants::kStraightEdgeCost
const double kStraightEdgeCost
Definition: GraphEnvironment.h:60
GraphSearchConstants::GetGraph
Graph * GetGraph(Map *m)
Definition: GraphEnvironment.cpp:851
GraphEnvironment::drawNodeLabels
bool drawNodeLabels
Definition: GraphEnvironment.h:364
node::GetLabelL
long GetLabelL(unsigned int index) const
Definition: Graph.h:220
GraphMapHeuristic::GraphMapHeuristic
GraphMapHeuristic(Map *map, Graph *graph)
Definition: GraphEnvironment.h:126
GraphHeuristic::HCost
virtual double HCost(const graphState &state1, const graphState &state2) const =0
GraphHeuristicContainer::GraphHeuristicContainer
GraphHeuristicContainer(Graph *gg)
Definition: GraphEnvironment.h:90
GraphEnvironment::HCost
virtual double HCost(const graphState &) const
Heuristic value between node and the stored goal.
Definition: GraphEnvironment.h:344
GraphEnvironment::SetIntegerEdgeCosts
void SetIntegerEdgeCosts(bool val)
Definition: GraphEnvironment.h:352
GraphEnvironment::StoreGoal
virtual void StoreGoal(graphState &)
Stores the goal for use by single-state HCost.
Definition: GraphEnvironment.h:340
GraphSearchConstants::kZCoordinate
@ kZCoordinate
Definition: GraphEnvironment.h:53
GraphDistanceHeuristic::~GraphDistanceHeuristic
~GraphDistanceHeuristic()
Definition: GraphEnvironment.h:225
GraphMapInconsistentHeuristic::numHeuristics
int numHeuristics
Definition: GraphEnvironment.h:285
GraphHeuristicContainer::g
Graph * g
Definition: GraphEnvironment.h:103
operator==
static bool operator==(const graphMove &l1, const graphMove &l2)
Definition: GraphEnvironment.h:42
GraphEnvironment::SVGHeader
std::string SVGHeader() const
Definition: GraphEnvironment.cpp:447
GraphEnvironment::GraphEnvironment
GraphEnvironment(Graph *g, GraphHeuristic *gh=0)
Definition: GraphEnvironment.cpp:22
GraphDistanceHeuristic::OpenGLDraw
virtual void OpenGLDraw() const
Definition: GraphEnvironment.cpp:1477
GraphSearchConstants::kDiagonalEdgeCost
const double kDiagonalEdgeCost
Definition: GraphEnvironment.h:61
SearchEnvironment
Definition: SearchEnvironment.h:30
GraphMapInconsistentHeuristic::m
Map * m
Definition: GraphEnvironment.h:288
GraphEnvironment
Definition: GraphEnvironment.h:291
node
Nodes to be stored within a Graph.
Definition: Graph.h:170
Map
A tile-based representation of the world.
Definition: Map.h:142
SearchEnvironment.h
kIgnore
@ kIgnore
Definition: GraphEnvironment.h:256
GraphMapInconsistentHeuristic::OpenGLDraw
virtual void OpenGLDraw() const
Definition: GraphEnvironment.cpp:1414
GraphHeuristic
Definition: GraphEnvironment.h:77
OccupancyInterface< graphState, graphMove >
GraphMapInconsistentHeuristic::displayHeuristic
int displayHeuristic
Definition: GraphEnvironment.h:286
GraphEnvironment::GetGraph
Graph * GetGraph()
Definition: GraphEnvironment.h:338