HOG2
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
DWG::DynamicWeightedGrid< sectorSize > Class Template Reference

#include <DynamicWeightedGrid.h>

Inheritance diagram for DWG::DynamicWeightedGrid< sectorSize >:
Inheritance graph
[legend]
Collaboration diagram for DWG::DynamicWeightedGrid< sectorSize >:
Collaboration graph
[legend]

Public Member Functions

 DynamicWeightedGrid (int width, int height)
 
 DynamicWeightedGrid (const char *map, int minRegionSize=80)
 
void SaveMap (const char *filename)
 
int GetWidth () const
 
int GetHeight () const
 
void SetTerrainType (const xyLoc &l, TerrainType t)
 
TerrainType GetTerrainType (const xyLoc &l) const
 
void GetSuccessors (const abstractState &nodeID, std::vector< abstractState > &neighbors) const
 
void GetActions (const abstractState &nodeID, std::vector< edge > &actions) const
 
void ApplyAction (abstractState &s, edge a) const
 
bool InvertAction (edge &a) const
 
edge GetAction (const abstractState &s1, const abstractState &s2) const
 
double HCost (const abstractState &node1, const abstractState &node2) const
 Heuristic value between two arbitrary nodes. More...
 
double GCost (const abstractState &node1, const abstractState &node2) const
 
double GCost (const abstractState &node, const edge &act) const
 
bool GoalTest (const abstractState &node, const abstractState &goal) const
 
uint64_t GetStateHash (const abstractState &node) const
 
uint64_t GetActionHash (edge act) const
 
void Draw (Graphics::Display &display) const
 
void Draw (Graphics::Display &display, const abstractState &) const
 
void OpenGLDraw () const
 
void OpenGLDraw (const abstractState &) const
 
void OpenGLDraw (const abstractState &, const edge &) const
 
void GLDrawLine (const abstractState &x, const abstractState &y) const
 
void GetPointFromCoordinate (point3d loc, int &px, int &py) const
 
void SetCosts (std::vector< double > &c)
 
void SetCost (TerrainType t, double cost)
 
std::vector< double > & GetCosts ()
 
abstractState GetState (const xyLoc &l)
 
xyLoc GetLocation (const abstractState &a)
 
uint64_t EstimateMemoryInBytes ()
 
int GetNumEdges ()
 
int GetNumRegions ()
 
void SetDrawAbstraction (bool draw)
 
bool GetDrawAbstraction ()
 
void ValidateEdges () const
 
void GetCoordinate (const xyLoc &l, float &x, float &y, float &r) const
 
- Public Member Functions inherited from SearchEnvironment< abstractState, edge >
virtual ~SearchEnvironment ()
 
virtual void GetSuccessors (const abstractState &nodeID, std::vector< abstractState > &neighbors) const=0
 
virtual void GetActions (const abstractState &nodeID, std::vector< edge > &actions) const=0
 
virtual int GetNumSuccessors (const abstractState &stateID) const
 
virtual edge GetAction (const abstractState &s1, const abstractState &s2) const
 
virtual void ApplyAction (abstractState &s, edge a) const=0
 
virtual void UndoAction (abstractState &s, edge a) const
 
virtual void GetNextState (const abstractState &s1, edge a, abstractState &s2) const
 
virtual bool InvertAction (edge &a) const=0
 
virtual void StoreGoal (abstractState &s)
 Stores the goal for use by single-state HCost. More...
 
virtual void ClearGoal ()
 Clears the goal from memory. More...
 
virtual bool IsGoalStored () const
 Returns true if the goal is stored and false otherwise. More...
 
virtual double HCost (const abstractState &node1, const abstractState &node2) const=0
 Heuristic value between two arbitrary nodes. More...
 
virtual double HCost (const abstractState &node1, const abstractState &node2, double parentHCost) const
 
virtual double HCost (const abstractState &node) const
 Heuristic value between node and the stored goal. More...
 
virtual double GCost (const abstractState &node1, const abstractState &node2) const=0
 
virtual double GCost (const abstractState &node, const edge &act) const=0
 
virtual bool GoalTest (const abstractState &node, const abstractState &goal) const=0
 
virtual bool GoalTest (const abstractState &node) const
 Goal Test if the goal is stored. More...
 
virtual uint64_t GetMaxHash () const
 
virtual uint64_t GetStateHash (const abstractState &node) const=0
 
virtual void GetStateFromHash (uint64_t parent, abstractState &s) const
 
virtual uint64_t GetActionHash (edge act) const=0
 
virtual double GetPathLength (std::vector< abstractState > &neighbors)
 
virtual double GetPathLength (const abstractState &start, std::vector< edge > &neighbors)
 
virtual OccupancyInterface< abstractState, edge > * GetOccupancyInfo ()
 
virtual void SetOccupancyInfo (OccupancyInterface< abstractState, edge > *)
 
virtual void OpenGLDraw () const
 
virtual void OpenGLDraw (const abstractState &) const
 
virtual void OpenGLDraw (const abstractState &, const abstractState &, float) const
 Draw the transition at some percentage 0...1 between two states. More...
 
virtual void OpenGLDraw (const abstractState &, const edge &) const
 
virtual void GLLabelState (const abstractState &, const char *) const
 
virtual void GLDrawLine (const abstractState &x, const abstractState &y) const
 
virtual void GLDrawPath (const std::vector< abstractState > &x) const
 
virtual void SetColor (const rgbColor &r) const
 
virtual void SetColor (GLfloat rr, GLfloat g, GLfloat b, GLfloat t=1.0) const
 
virtual void GetColor (GLfloat &rr, GLfloat &g, GLfloat &b, GLfloat &t) const
 
virtual rgbColor GetColor () const
 
virtual void Draw (Graphics::Display &display, const abstractState &) const
 
virtual void DrawLine (Graphics::Display &display, const abstractState &x, const abstractState &y, float width=1.0) const
 
- Public Member Functions inherited from Heuristic< abstractState >
 Heuristic ()
 
virtual ~Heuristic ()
 

Static Public Member Functions

static rgbColor GetTerrainColor (TerrainType t)
 

Private Member Functions

bool FindEdge (int fromSector, int fromRegion, int toSector, int toRegion) const
 
void DrawSector (Graphics::Display &display, int sector) const
 
void EliminateSmallRegions (int limit)
 
void BuildAbstraction ()
 
void GetRegions (int sector)
 
void GetEdges (int sector)
 
regionData BFS (SectorData< sectorSize > &d, int x, int y, int whichRegion)
 
void AddEdge (SectorData< sectorSize > &d, int s1, int r1, int s2, int r2)
 
int GetNumSectors () const
 
int GetNumXSectors () const
 
int GetNumYSectors () const
 
int GetRegion (const xyLoc &l)
 
int GetSector (const xyLoc &l) const
 
void GetSectorOffset (const xyLoc &l, int &x, int &y) const
 
void SetTerrainTypeNoRepair (const xyLoc &l, TerrainType t)
 

Private Attributes

std::vector< SectorData< sectorSize > > sectors
 
int mWidth
 
int mHeight
 
bool drawAbstraction
 
std::vector< double > costs
 

Additional Inherited Members

- Public Attributes inherited from Heuristic< abstractState >
std::vector< HeuristicTreeNodelookups
 
std::vector< Heuristic * > heuristics
 
uint64_t histogram [256]
 
- Protected Attributes inherited from SearchEnvironment< abstractState, edge >
bool bValidSearchGoal
 
abstractState searchGoal
 
rgbColor color
 
GLfloat transparency
 

Detailed Description

template<int sectorSize>
class DWG::DynamicWeightedGrid< sectorSize >

Definition at line 70 of file DynamicWeightedGrid.h.

Constructor & Destructor Documentation

◆ DynamicWeightedGrid() [1/2]

template<int sectorSize>
DWG::DynamicWeightedGrid< sectorSize >::DynamicWeightedGrid ( int  width,
int  height 
)

◆ DynamicWeightedGrid() [2/2]

template<int sectorSize>
DWG::DynamicWeightedGrid< sectorSize >::DynamicWeightedGrid ( const char *  map,
int  minRegionSize = 80 
)

Definition at line 282 of file DynamicWeightedGrid.h.

Member Function Documentation

◆ AddEdge()

template<int sectorSize>
void DWG::DynamicWeightedGrid< sectorSize >::AddEdge ( SectorData< sectorSize > &  d,
int  s1,
int  r1,
int  s2,
int  r2 
)
private

Definition at line 505 of file DynamicWeightedGrid.h.

References d.

◆ ApplyAction()

template<int sectorSize>
void DWG::DynamicWeightedGrid< sectorSize >::ApplyAction ( abstractState s,
edge  a 
) const

◆ BFS()

template<int sectorSize>
regionData DWG::DynamicWeightedGrid< sectorSize >::BFS ( SectorData< sectorSize > &  d,
int  x,
int  y,
int  whichRegion 
)
private

Definition at line 421 of file DynamicWeightedGrid.h.

References d, DWG::kNoRegion, xyLoc::x, and xyLoc::y.

◆ BuildAbstraction()

template<int sectorSize>
void DWG::DynamicWeightedGrid< sectorSize >::BuildAbstraction
private

◆ Draw() [1/2]

template<int sectorSize>
void DWG::DynamicWeightedGrid< sectorSize >::Draw ( Graphics::Display display) const
virtual

◆ Draw() [2/2]

template<int sectorSize>
void DWG::DynamicWeightedGrid< sectorSize >::Draw ( Graphics::Display display,
const abstractState absState 
) const

◆ DrawSector()

template<int sectorSize>
void DWG::DynamicWeightedGrid< sectorSize >::DrawSector ( Graphics::Display display,
int  sector 
) const
private

◆ EliminateSmallRegions()

template<int sectorSize>
void DWG::DynamicWeightedGrid< sectorSize >::EliminateSmallRegions ( int  limit)
private

Definition at line 552 of file DynamicWeightedGrid.h.

References xyLoc::x, and xyLoc::y.

◆ EstimateMemoryInBytes()

template<int sectorSize>
uint64_t DWG::DynamicWeightedGrid< sectorSize >::EstimateMemoryInBytes ( )
inline

◆ FindEdge()

template<int sectorSize>
bool DWG::DynamicWeightedGrid< sectorSize >::FindEdge ( int  fromSector,
int  fromRegion,
int  toSector,
int  toRegion 
) const
private

Definition at line 542 of file DynamicWeightedGrid.h.

◆ GCost() [1/2]

template<int sectorSize>
double DWG::DynamicWeightedGrid< sectorSize >::GCost ( const abstractState node,
const edge act 
) const

Definition at line 823 of file DynamicWeightedGrid.h.

◆ GCost() [2/2]

template<int sectorSize>
double DWG::DynamicWeightedGrid< sectorSize >::GCost ( const abstractState node1,
const abstractState node2 
) const

◆ GetAction()

template<int sectorSize>
edge DWG::DynamicWeightedGrid< sectorSize >::GetAction ( const abstractState s1,
const abstractState s2 
) const

Definition at line 786 of file DynamicWeightedGrid.h.

◆ GetActionHash()

template<int sectorSize>
uint64_t DWG::DynamicWeightedGrid< sectorSize >::GetActionHash ( edge  act) const

Definition at line 845 of file DynamicWeightedGrid.h.

◆ GetActions()

template<int sectorSize>
void DWG::DynamicWeightedGrid< sectorSize >::GetActions ( const abstractState nodeID,
std::vector< edge > &  actions 
) const

Definition at line 758 of file DynamicWeightedGrid.h.

References d, DWG::abstractState::region, and DWG::abstractState::sector.

◆ GetCoordinate()

template<int sectorSize>
void DWG::DynamicWeightedGrid< sectorSize >::GetCoordinate ( const xyLoc l,
float &  x,
float &  y,
float &  r 
) const

Definition at line 852 of file DynamicWeightedGrid.h.

References xyLoc::x, and xyLoc::y.

◆ GetCosts()

template<int sectorSize>
std::vector<double>& DWG::DynamicWeightedGrid< sectorSize >::GetCosts ( )
inline

◆ GetDrawAbstraction()

template<int sectorSize>
bool DWG::DynamicWeightedGrid< sectorSize >::GetDrawAbstraction ( )
inline

◆ GetEdges()

template<int sectorSize>
void DWG::DynamicWeightedGrid< sectorSize >::GetEdges ( int  sector)
private

Definition at line 467 of file DynamicWeightedGrid.h.

References d, xyLoc::x, and xyLoc::y.

◆ GetHeight()

template<int sectorSize>
int DWG::DynamicWeightedGrid< sectorSize >::GetHeight

Definition at line 341 of file DynamicWeightedGrid.h.

◆ GetLocation()

template<int sectorSize>
xyLoc DWG::DynamicWeightedGrid< sectorSize >::GetLocation ( const abstractState a)

◆ GetNumEdges()

template<int sectorSize>
int DWG::DynamicWeightedGrid< sectorSize >::GetNumEdges ( )
inline

◆ GetNumRegions()

template<int sectorSize>
int DWG::DynamicWeightedGrid< sectorSize >::GetNumRegions ( )
inline

◆ GetNumSectors()

template<int sectorSize>
int DWG::DynamicWeightedGrid< sectorSize >::GetNumSectors
private

◆ GetNumXSectors()

template<int sectorSize>
int DWG::DynamicWeightedGrid< sectorSize >::GetNumXSectors
private

Definition at line 696 of file DynamicWeightedGrid.h.

◆ GetNumYSectors()

template<int sectorSize>
int DWG::DynamicWeightedGrid< sectorSize >::GetNumYSectors
private

Definition at line 703 of file DynamicWeightedGrid.h.

◆ GetPointFromCoordinate()

template<int sectorSize>
void DWG::DynamicWeightedGrid< sectorSize >::GetPointFromCoordinate ( point3d  loc,
int &  px,
int &  py 
) const

Definition at line 875 of file DynamicWeightedGrid.h.

References loc::x, and loc::y.

◆ GetRegion()

template<int sectorSize>
int DWG::DynamicWeightedGrid< sectorSize >::GetRegion ( const xyLoc l)
private

Definition at line 710 of file DynamicWeightedGrid.h.

◆ GetRegions()

template<int sectorSize>
void DWG::DynamicWeightedGrid< sectorSize >::GetRegions ( int  sector)
private

Definition at line 390 of file DynamicWeightedGrid.h.

References d, and DWG::kNoRegion.

◆ GetSector()

template<int sectorSize>
int DWG::DynamicWeightedGrid< sectorSize >::GetSector ( const xyLoc l) const
private

Definition at line 718 of file DynamicWeightedGrid.h.

References xyLoc::x, and xyLoc::y.

◆ GetSectorOffset()

template<int sectorSize>
void DWG::DynamicWeightedGrid< sectorSize >::GetSectorOffset ( const xyLoc l,
int &  x,
int &  y 
) const
private

Definition at line 726 of file DynamicWeightedGrid.h.

References xyLoc::x, and xyLoc::y.

◆ GetState()

template<int sectorSize>
abstractState DWG::DynamicWeightedGrid< sectorSize >::GetState ( const xyLoc l)

◆ GetStateHash()

template<int sectorSize>
uint64_t DWG::DynamicWeightedGrid< sectorSize >::GetStateHash ( const abstractState node) const

Definition at line 837 of file DynamicWeightedGrid.h.

◆ GetSuccessors()

template<int sectorSize>
void DWG::DynamicWeightedGrid< sectorSize >::GetSuccessors ( const abstractState nodeID,
std::vector< abstractState > &  neighbors 
) const

Definition at line 745 of file DynamicWeightedGrid.h.

References d, DWG::abstractState::region, and DWG::abstractState::sector.

◆ GetTerrainColor()

template<int sectorSize>
static rgbColor DWG::DynamicWeightedGrid< sectorSize >::GetTerrainColor ( TerrainType  t)
inlinestatic

◆ GetTerrainType()

template<int sectorSize>
TerrainType DWG::DynamicWeightedGrid< sectorSize >::GetTerrainType ( const xyLoc l) const

Definition at line 367 of file DynamicWeightedGrid.h.

◆ GetWidth()

template<int sectorSize>
int DWG::DynamicWeightedGrid< sectorSize >::GetWidth

Definition at line 337 of file DynamicWeightedGrid.h.

◆ GLDrawLine()

template<int sectorSize>
void DWG::DynamicWeightedGrid< sectorSize >::GLDrawLine ( const abstractState x,
const abstractState y 
) const
inline

Definition at line 99 of file DynamicWeightedGrid.h.

◆ GoalTest()

template<int sectorSize>
bool DWG::DynamicWeightedGrid< sectorSize >::GoalTest ( const abstractState node,
const abstractState goal 
) const

Definition at line 831 of file DynamicWeightedGrid.h.

◆ HCost()

template<int sectorSize>
double DWG::DynamicWeightedGrid< sectorSize >::HCost ( const abstractState node1,
const abstractState node2 
) const

Heuristic value between two arbitrary nodes.

Definition at line 793 of file DynamicWeightedGrid.h.

References DWG::abstractState::region, DWG::abstractState::sector, xyLoc::x, and xyLoc::y.

◆ InvertAction()

template<int sectorSize>
bool DWG::DynamicWeightedGrid< sectorSize >::InvertAction ( edge a) const

◆ OpenGLDraw() [1/3]

template<int sectorSize>
void DWG::DynamicWeightedGrid< sectorSize >::OpenGLDraw ( ) const
inline

Definition at line 96 of file DynamicWeightedGrid.h.

◆ OpenGLDraw() [2/3]

template<int sectorSize>
void DWG::DynamicWeightedGrid< sectorSize >::OpenGLDraw ( const abstractState ) const
inline

Definition at line 97 of file DynamicWeightedGrid.h.

◆ OpenGLDraw() [3/3]

template<int sectorSize>
void DWG::DynamicWeightedGrid< sectorSize >::OpenGLDraw ( const abstractState ,
const edge  
) const
inline

Definition at line 98 of file DynamicWeightedGrid.h.

◆ SaveMap()

template<int sectorSize>
void DWG::DynamicWeightedGrid< sectorSize >::SaveMap ( const char *  filename)

Definition at line 316 of file DynamicWeightedGrid.h.

◆ SetCost()

template<int sectorSize>
void DWG::DynamicWeightedGrid< sectorSize >::SetCost ( TerrainType  t,
double  cost 
)
inline

Definition at line 107 of file DynamicWeightedGrid.h.

◆ SetCosts()

template<int sectorSize>
void DWG::DynamicWeightedGrid< sectorSize >::SetCosts ( std::vector< double > &  c)
inline

◆ SetDrawAbstraction()

template<int sectorSize>
void DWG::DynamicWeightedGrid< sectorSize >::SetDrawAbstraction ( bool  draw)
inline

◆ SetTerrainType()

template<int sectorSize>
void DWG::DynamicWeightedGrid< sectorSize >::SetTerrainType ( const xyLoc l,
TerrainType  t 
)

Definition at line 345 of file DynamicWeightedGrid.h.

◆ SetTerrainTypeNoRepair()

template<int sectorSize>
void DWG::DynamicWeightedGrid< sectorSize >::SetTerrainTypeNoRepair ( const xyLoc l,
TerrainType  t 
)
private

◆ ValidateEdges()

template<int sectorSize>
void DWG::DynamicWeightedGrid< sectorSize >::ValidateEdges

Definition at line 517 of file DynamicWeightedGrid.h.

References fequal().

Referenced by DWG::DynamicWeightedGrid< sectorSize >::SetCosts().

Member Data Documentation

◆ costs

template<int sectorSize>
std::vector<double> DWG::DynamicWeightedGrid< sectorSize >::costs
private

◆ drawAbstraction

template<int sectorSize>
bool DWG::DynamicWeightedGrid< sectorSize >::drawAbstraction
private

◆ mHeight

template<int sectorSize>
int DWG::DynamicWeightedGrid< sectorSize >::mHeight
private

◆ mWidth

template<int sectorSize>
int DWG::DynamicWeightedGrid< sectorSize >::mWidth
private

◆ sectors

template<int sectorSize>
std::vector<SectorData<sectorSize> > DWG::DynamicWeightedGrid< sectorSize >::sectors
private

The documentation for this class was generated from the following file: