HOG2
CRAStar.h
Go to the documentation of this file.
1 /*
2  * $Id: craStar.h
3  * hog2
4  *
5  * Created by Nathan Sturtevant on 6/23/05.
6  * Modified by Nathan Sturtevant on 02/29/20.
7  *
8  * This file is part of HOG2. See https://github.com/nathansttt/hog2 for licensing information.
9  *
10  */
11 
12 #ifndef CRASTAR_H
13 #define CRASTAR_H
14 
15 #include "SearchAlgorithm.h"
16 #include "Heap.h"
17 #include "CorridorAStar.h"
18 
23 class craStar : public SearchAlgorithm {
24 
25 public:
26  // From HPA* original code - smoothwizard.h
27  typedef enum {
32  NE,
33  SE,
34  SW,
36 
37  typedef enum {
39  END,
41 
42 
43  craStar();
44  virtual ~craStar() {}
45  virtual path *GetPath(GraphAbstraction *aMap, node *from, node *to, reservationProvider *rp = 0);
46  virtual const char *GetName()
47  { return algName; }
48  void setPartialPathLimit(int limit)
49  { partialLimit = limit; sprintf(algName,"CRA*(%d)", partialLimit); }
51 
55  void setSmoothing(bool smooth) {smoothing = smooth;}
56 
65  void setSmoothType(SmoothType s) { smType = s; }
66 
73  void setAbstractLevel(int level) { absLevel = level; }
74 
75 protected:
76  void setupSearch(GraphAbstraction *aMap,
77  std::vector<node *> &fromChain, node *from,
78  std::vector<node *> &toChain, node *to);
79 
80  void findGoalNode(GraphAbstraction* aMap,node* n, std::vector<node *> &toChain);
82  std::vector<node *> &fromChain,
83  std::vector<node *> &toChain,
85 
86 
87  path *trimPath(path *lastPath, node *origDest);
89  std::vector<node *> &fromChain,
90  std::vector<node *> &toChain,
92  path* doRefinement(GraphAbstraction *aMap, path* absPath,
93  std::vector<node*> &fromChain,
94  std::vector<node*> &toChain);
95 
96  node* getNextNode(GraphAbstraction *aMap, node* currentLow, path* returnPath, path* apath, Graph* g, int abstractLevel);
97 
101  char algName[30];
102 
104 
105  std::vector<node*> lookup;
106  path* nextPathNode(GraphAbstraction* m,node* n, int dir);
107  node* getNextNode(MapAbstraction* m,int x, int y, int dir);
108  bool nextInLookup(int last, int curr, std::vector<node*> lookup);
109  int backTwoNodes(int i, std::vector<node*> lookup);
110 
111  void findMinMax(path* p);
112 
114  bool smoothing;
115  int absLevel;
116 
117  int minx;
118  int maxx;
119  int miny;
120  int maxy;
121 };
122 
123 
124 #endif
craStar::TWO_BACK
@ TWO_BACK
Definition: CRAStar.h:40
craStar::SOUTH
@ SOUTH
Definition: CRAStar.h:30
GraphAbstraction
A generic class for basic operations on Graph abstractions.
Definition: GraphAbstraction.h:63
craStar::craStar
craStar()
Definition: CRAStar.cpp:22
craStar::trimPath
path * trimPath(path *lastPath, node *origDest)
Definition: CRAStar.cpp:499
craStar::~craStar
virtual ~craStar()
Definition: CRAStar.h:44
craStar::setSmoothType
void setSmoothType(SmoothType s)
Set the smoothing type.Default is BEGIN.
Definition: CRAStar.h:65
Heap.h
craStar::minx
int minx
Definition: CRAStar.h:117
craStar
The pra* search algorithm which does partial pathfinding using abstraction.
Definition: CRAStar.h:23
craStar::doRefinement
path * doRefinement(GraphAbstraction *aMap, path *absPath, std::vector< node * > &fromChain, std::vector< node * > &toChain)
Do a quick refinement of an abstract path.
Definition: CRAStar.cpp:204
SearchAlgorithm.h
craStar::getPartialPathLimit
int getPartialPathLimit()
Definition: CRAStar.h:50
craStar::algName
char algName[30]
Definition: CRAStar.h:101
craStar::smType
SmoothType smType
Definition: CRAStar.h:113
corridorAStar
Corridor AStar builds a a* path between two nodes, restricting itself to a particular corridor,...
Definition: CorridorAStar.h:25
craStar::NORTH
@ NORTH
Definition: CRAStar.h:28
craStar::Direction
Direction
Definition: CRAStar.h:27
craStar::BEGIN
@ BEGIN
Definition: CRAStar.h:38
craStar::cAStar
corridorAStar cAStar
Definition: CRAStar.h:100
craStar::smoothing
bool smoothing
Definition: CRAStar.h:114
Graph
A generic Graph class.
Definition: Graph.h:66
craStar::miny
int miny
Definition: CRAStar.h:119
craStar::setAbstractLevel
void setAbstractLevel(int level)
set the abstract level
Definition: CRAStar.h:73
craStar::expandSearchRadius
bool expandSearchRadius
Definition: CRAStar.h:99
craStar::setSmoothing
void setSmoothing(bool smooth)
Set whether the path will be smoothed or not.
Definition: CRAStar.h:55
craStar::setupSearch
void setupSearch(GraphAbstraction *aMap, std::vector< node * > &fromChain, node *from, std::vector< node * > &toChain, node *to)
Definition: CRAStar.cpp:120
craStar::WEST
@ WEST
Definition: CRAStar.h:31
craStar::GetName
virtual const char * GetName()
Definition: CRAStar.h:46
craStar::buildNextAbstractPath
path * buildNextAbstractPath(GraphAbstraction *, path *lastPath, std::vector< node * > &fromChain, std::vector< node * > &toChain, reservationProvider *)
Definition: CRAStar.cpp:421
craStar::maxy
int maxy
Definition: CRAStar.h:120
craStar::maxx
int maxx
Definition: CRAStar.h:118
craStar::absLevel
int absLevel
Definition: CRAStar.h:115
craStar::setPartialPathLimit
void setPartialPathLimit(int limit)
Definition: CRAStar.h:48
craStar::buildAbstractPath
path * buildAbstractPath(GraphAbstraction *aMap, std::vector< node * > &fromChain, std::vector< node * > &toChain, reservationProvider *rp)
Build an abstract path for quick refinement.
Definition: CRAStar.cpp:174
craStar::NW
@ NW
Definition: CRAStar.h:35
craStar::lookup
std::vector< node * > lookup
Definition: CRAStar.h:105
craStar::backTwoNodes
int backTwoNodes(int i, std::vector< node * > lookup)
Find the index of the node two nodes back in the path.
Definition: CRAStar.cpp:680
craStar::partialLimit
int partialLimit
Definition: CRAStar.h:98
craStar::findMinMax
void findMinMax(path *p)
Find the box that bounds the path for more efficient path smoothing.
Definition: CRAStar.cpp:810
craStar::smoothPath
path * smoothPath(GraphAbstraction *m, path *p)
copied from hpaStar.cpp
Definition: CRAStar.cpp:532
craStar::SmoothType
SmoothType
Definition: CRAStar.h:37
CorridorAStar.h
craStar::findGoalNode
void findGoalNode(GraphAbstraction *aMap, node *n, std::vector< node * > &toChain)
GIven an abstract level parent node n, find a new goal that is a 0-level child of n as well as the pa...
Definition: CRAStar.cpp:106
craStar::SW
@ SW
Definition: CRAStar.h:34
craStar::nextInLookup
bool nextInLookup(int last, int curr, std::vector< node * > lookup)
find out whether last is the next 'real' index in the lookup table after curr.
Definition: CRAStar.cpp:703
craStar::nextPathNode
path * nextPathNode(GraphAbstraction *m, node *n, int dir)
shoot a ray in direction dir and see if you hit the path Return the better path if you find it; 0 if ...
Definition: CRAStar.cpp:723
reservationProvider
Definition: ReservationProvider.h:33
SearchAlgorithm
A generic algorithm which can be used for pathfinding.
Definition: SearchAlgorithm.h:25
craStar::NE
@ NE
Definition: CRAStar.h:32
craStar::EAST
@ EAST
Definition: CRAStar.h:29
craStar::GetPath
virtual path * GetPath(GraphAbstraction *aMap, node *from, node *to, reservationProvider *rp=0)
Definition: CRAStar.cpp:34
path
A linked list of nodes which form a continuous path.
Definition: Path.h:20
craStar::END
@ END
Definition: CRAStar.h:39
craStar::SE
@ SE
Definition: CRAStar.h:33
node
Nodes to be stored within a Graph.
Definition: Graph.h:170
craStar::getNextNode
node * getNextNode(GraphAbstraction *aMap, node *currentLow, path *returnPath, path *apath, Graph *g, int abstractLevel)
Find the next node of the refined path.
Definition: CRAStar.cpp:311