HOG2
Classes | Public Member Functions | Public Attributes | Protected Types | Protected Member Functions | Protected Attributes | List of all members
Map2DHeading Class Reference

#include <Map2DHeading.h>

Inheritance diagram for Map2DHeading:
Inheritance graph
[legend]
Collaboration diagram for Map2DHeading:
Collaboration graph
[legend]

Classes

struct  hdData
 

Public Member Functions

 Map2DHeading (Map *m)
 
virtual ~Map2DHeading ()
 
virtual void GetSuccessors (const xyhLoc &nodeID, std::vector< xyhLoc > &neighbors) const
 
void GetActions (const xyhLoc &nodeID, std::vector< xyhAct > &actions) const
 
xyhAct GetAction (const xyhLoc &s1, const xyhLoc &s2) const
 
virtual void ApplyAction (xyhLoc &s, xyhAct dir) const
 
virtual bool InvertAction (xyhAct &a) const
 
virtual double HCost (const xyhLoc &) const
 Heuristic value between node and the stored goal. More...
 
virtual double HCost (const xyhLoc &node1, const xyhLoc &node2) const
 Heuristic value between two arbitrary nodes. More...
 
virtual double GCost (const xyhLoc &node1, const xyhLoc &node2) const
 
virtual double GCost (const xyhLoc &node1, const xyhAct &act) const
 
bool GoalTest (const xyhLoc &node, const xyhLoc &goal) const
 
bool GoalTest (const xyhLoc &) const
 Goal Test if the goal is stored. More...
 
uint64_t GetStateHash (const xyhLoc &node) const
 
void GetStateFromHash (uint64_t hash, xyhLoc &node) const
 
uint64_t GetActionHash (xyhAct act) const
 
virtual void OpenGLDraw () const
 
virtual void OpenGLDraw (const xyhLoc &l) const
 
virtual void OpenGLDraw (const xyhLoc &l1, const xyhLoc &l2, float v) const
 Draw the transition at some percentage 0...1 between two states. More...
 
virtual void OpenGLDraw (const xyhLoc &, const xyhAct &) const
 
virtual void GLLabelState (const xyhLoc &, const char *) const
 
virtual void GLDrawLine (const xyhLoc &x, const xyhLoc &y) const
 
MapGetMap () const
 
virtual void GetNextState (const xyhLoc &currents, xyhAct dir, xyhLoc &news) const
 
void StoreGoal (xyhLoc &)
 Stores the goal for use by single-state HCost. More...
 
void ClearGoal ()
 Clears the goal from memory. More...
 
bool IsGoalStored () const
 
void SetDiagonalCost (double val)
 
double GetDiagonalCost ()
 
bool FourConnected ()
 
bool EightConnected ()
 
void SetFourConnected ()
 
void SetEightConnected ()
 
void SetCost (const xyhLoc &, double seen, double dist)
 
void ClearCost (const xyhLoc &)
 
void ClearAllCosts ()
 
- Public Member Functions inherited from SearchEnvironment< xyhLoc, xyhAct >
virtual ~SearchEnvironment ()
 
virtual int GetNumSuccessors (const xyhLoc &stateID) const
 
virtual void UndoAction (xyhLoc &s, xyhAct a) const
 
virtual bool IsGoalStored () const
 Returns true if the goal is stored and false otherwise. More...
 
virtual double HCost (const xyhLoc &node1, const xyhLoc &node2, double parentHCost) const
 
virtual uint64_t GetMaxHash () const
 
virtual double GetPathLength (std::vector< xyhLoc > &neighbors)
 
virtual double GetPathLength (const xyhLoc &start, std::vector< xyhAct > &neighbors)
 
virtual OccupancyInterface< xyhLoc, xyhAct > * GetOccupancyInfo ()
 
virtual void SetOccupancyInfo (OccupancyInterface< xyhLoc, xyhAct > *)
 
virtual void OpenGLDraw () const
 
virtual void GLDrawPath (const std::vector< xyhLoc > &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
 
virtual void Draw (Graphics::Display &display, const xyhLoc &) const
 
virtual void DrawLine (Graphics::Display &display, const xyhLoc &x, const xyhLoc &y, float width=1.0) const
 
- Public Member Functions inherited from Heuristic< xyhLoc >
 Heuristic ()
 
virtual ~Heuristic ()
 

Public Attributes

bool drawWeights
 
- Public Attributes inherited from Heuristic< xyhLoc >
std::vector< HeuristicTreeNodelookups
 
std::vector< Heuristic * > heuristics
 
uint64_t histogram [256]
 

Protected Types

typedef std::unordered_map< uint64_t, hdData, Hash64CostTable
 

Protected Member Functions

double GetCost (const xyhLoc &a, const xyhLoc &b, double P, double d) const
 
bool LegalState (const xyhLoc &s)
 
void BuildAngleTables ()
 
float mySin (int dir) const
 
float myCos (int dir) const
 

Protected Attributes

Mapmap
 
double DIAGONAL_COST
 
bool fourConnected
 
std::vector< float > cosTable
 
std::vector< float > sinTable
 
CostTable costs
 
- Protected Attributes inherited from SearchEnvironment< xyhLoc, xyhAct >
bool bValidSearchGoal
 
xyhLoc searchGoal
 
rgbColor color
 
GLfloat transparency
 

Detailed Description

Definition at line 46 of file Map2DHeading.h.

Member Typedef Documentation

◆ CostTable

typedef std::unordered_map<uint64_t, hdData, Hash64> Map2DHeading::CostTable
protected

Definition at line 113 of file Map2DHeading.h.

Constructor & Destructor Documentation

◆ Map2DHeading()

Map2DHeading::Map2DHeading ( Map m)

Definition at line 15 of file Map2DHeading.cpp.

References BuildAngleTables(), DIAGONAL_COST, drawWeights, and map.

◆ ~Map2DHeading()

Map2DHeading::~Map2DHeading ( )
virtual

Definition at line 23 of file Map2DHeading.cpp.

Member Function Documentation

◆ ApplyAction()

void Map2DHeading::ApplyAction ( xyhLoc s,
xyhAct  dir 
) const
virtual

◆ BuildAngleTables()

void Map2DHeading::BuildAngleTables ( )
protected

Definition at line 364 of file Map2DHeading.cpp.

References cosTable, sinTable, and TWOPI.

Referenced by Map2DHeading().

◆ ClearAllCosts()

void Map2DHeading::ClearAllCosts ( )

Definition at line 397 of file Map2DHeading.cpp.

◆ ClearCost()

void Map2DHeading::ClearCost ( const xyhLoc l)

Definition at line 392 of file Map2DHeading.cpp.

References GetStateHash().

◆ ClearGoal()

void Map2DHeading::ClearGoal ( )
inlinevirtual

Clears the goal from memory.

Reimplemented from SearchEnvironment< xyhLoc, xyhAct >.

Definition at line 89 of file Map2DHeading.h.

◆ EightConnected()

bool Map2DHeading::EightConnected ( )
inline

Definition at line 94 of file Map2DHeading.h.

References fourConnected.

◆ FourConnected()

bool Map2DHeading::FourConnected ( )
inline

Definition at line 93 of file Map2DHeading.h.

References fourConnected.

◆ GCost() [1/2]

double Map2DHeading::GCost ( const xyhLoc node1,
const xyhAct act 
) const
virtual

◆ GCost() [2/2]

double Map2DHeading::GCost ( const xyhLoc node1,
const xyhLoc node2 
) const
virtual

◆ GetAction()

xyhAct Map2DHeading::GetAction ( const xyhLoc s1,
const xyhLoc s2 
) const
virtual

Reimplemented from SearchEnvironment< xyhLoc, xyhAct >.

Definition at line 63 of file Map2DHeading.cpp.

References xyhLoc::h, xyhAct::newHeading, and xyhAct::oldHeading.

◆ GetActionHash()

uint64_t Map2DHeading::GetActionHash ( xyhAct  act) const
virtual

Implements SearchEnvironment< xyhLoc, xyhAct >.

Definition at line 223 of file Map2DHeading.cpp.

References xyhAct::newHeading, and xyhAct::oldHeading.

◆ GetActions()

void Map2DHeading::GetActions ( const xyhLoc nodeID,
std::vector< xyhAct > &  actions 
) const
virtual

◆ GetCost()

double Map2DHeading::GetCost ( const xyhLoc a,
const xyhLoc b,
double  P,
double  d 
) const
protected

Definition at line 109 of file Map2DHeading.cpp.

References xyhLoc::h, max, min(), xyhLoc::x, and xyhLoc::y.

Referenced by GCost().

◆ GetDiagonalCost()

double Map2DHeading::GetDiagonalCost ( )
inline

Definition at line 92 of file Map2DHeading.h.

References DIAGONAL_COST.

◆ GetMap()

Map* Map2DHeading::GetMap ( ) const
inline

Definition at line 84 of file Map2DHeading.h.

References map.

◆ GetNextState()

void Map2DHeading::GetNextState ( const xyhLoc currents,
xyhAct  dir,
xyhLoc news 
) const
virtual

Reimplemented from SearchEnvironment< xyhLoc, xyhAct >.

Definition at line 358 of file Map2DHeading.cpp.

References ApplyAction().

Referenced by GetActions().

◆ GetStateFromHash()

void Map2DHeading::GetStateFromHash ( uint64_t  hash,
xyhLoc node 
) const
virtual

Reimplemented from SearchEnvironment< xyhLoc, xyhAct >.

Definition at line 214 of file Map2DHeading.cpp.

Referenced by GCost(), and OpenGLDraw().

◆ GetStateHash()

uint64_t Map2DHeading::GetStateHash ( const xyhLoc node) const
virtual

Implements SearchEnvironment< xyhLoc, xyhAct >.

Definition at line 205 of file Map2DHeading.cpp.

Referenced by ClearCost(), and SetCost().

◆ GetSuccessors()

void Map2DHeading::GetSuccessors ( const xyhLoc nodeID,
std::vector< xyhLoc > &  neighbors 
) const
virtual

◆ GLDrawLine()

void Map2DHeading::GLDrawLine ( const xyhLoc x,
const xyhLoc y 
) const
virtual

Reimplemented from SearchEnvironment< xyhLoc, xyhAct >.

Definition at line 352 of file Map2DHeading.cpp.

◆ GLLabelState()

void Map2DHeading::GLLabelState ( const xyhLoc ,
const char *   
) const
virtual

Reimplemented from SearchEnvironment< xyhLoc, xyhAct >.

Definition at line 347 of file Map2DHeading.cpp.

◆ GoalTest() [1/2]

bool Map2DHeading::GoalTest ( const xyhLoc node) const
inlinevirtual

Goal Test if the goal is stored.

Reimplemented from SearchEnvironment< xyhLoc, xyhAct >.

Definition at line 69 of file Map2DHeading.h.

◆ GoalTest() [2/2]

bool Map2DHeading::GoalTest ( const xyhLoc node,
const xyhLoc goal 
) const
virtual

Implements SearchEnvironment< xyhLoc, xyhAct >.

Definition at line 200 of file Map2DHeading.cpp.

◆ HCost() [1/2]

virtual double Map2DHeading::HCost ( const xyhLoc node) const
inlinevirtual

Heuristic value between node and the stored goal.

Asserts that the goal is stored

Reimplemented from SearchEnvironment< xyhLoc, xyhAct >.

Definition at line 61 of file Map2DHeading.h.

◆ HCost() [2/2]

double Map2DHeading::HCost ( const xyhLoc node1,
const xyhLoc node2 
) const
virtual

Heuristic value between two arbitrary nodes.

Implements SearchEnvironment< xyhLoc, xyhAct >.

Definition at line 97 of file Map2DHeading.cpp.

References DIAGONAL_COST, xyhLoc::h, xyhLoc::x, and xyhLoc::y.

◆ InvertAction()

bool Map2DHeading::InvertAction ( xyhAct a) const
virtual

Implements SearchEnvironment< xyhLoc, xyhAct >.

Definition at line 92 of file Map2DHeading.cpp.

◆ IsGoalStored()

bool Map2DHeading::IsGoalStored ( ) const
inline

Definition at line 90 of file Map2DHeading.h.

◆ LegalState()

bool Map2DHeading::LegalState ( const xyhLoc s)
protected

Definition at line 193 of file Map2DHeading.cpp.

References Map::GetTerrainType(), kGround, map, xyhLoc::x, and xyhLoc::y.

◆ myCos()

float Map2DHeading::myCos ( int  dir) const
protected

Definition at line 381 of file Map2DHeading.cpp.

References cosTable.

Referenced by OpenGLDraw().

◆ mySin()

float Map2DHeading::mySin ( int  dir) const
protected

Definition at line 376 of file Map2DHeading.cpp.

References sinTable.

Referenced by OpenGLDraw().

◆ OpenGLDraw() [1/4]

void Map2DHeading::OpenGLDraw ( ) const
virtual

◆ OpenGLDraw() [2/4]

void Map2DHeading::OpenGLDraw ( const xyhLoc ,
const xyhAct  
) const
virtual

Reimplemented from SearchEnvironment< xyhLoc, xyhAct >.

Definition at line 342 of file Map2DHeading.cpp.

◆ OpenGLDraw() [3/4]

void Map2DHeading::OpenGLDraw ( const xyhLoc l) const
virtual

◆ OpenGLDraw() [4/4]

void Map2DHeading::OpenGLDraw ( const xyhLoc ,
const xyhLoc ,
float   
) const
virtual

Draw the transition at some percentage 0...1 between two states.

Reimplemented from SearchEnvironment< xyhLoc, xyhAct >.

Definition at line 283 of file Map2DHeading.cpp.

References SearchEnvironment< xyhLoc, xyhAct >::GetColor(), Map::GetOpenGLCoord(), xyhLoc::h, if(), map, recVec::normalise(), TWOPI, xyhLoc::x, recVec::x, xyhLoc::y, recVec::y, and recVec::z.

◆ SetCost()

void Map2DHeading::SetCost ( const xyhLoc l,
double  seen,
double  dist 
)

Definition at line 386 of file Map2DHeading.cpp.

References d, and GetStateHash().

◆ SetDiagonalCost()

void Map2DHeading::SetDiagonalCost ( double  val)
inline

Definition at line 91 of file Map2DHeading.h.

References DIAGONAL_COST.

◆ SetEightConnected()

void Map2DHeading::SetEightConnected ( )
inline

Definition at line 96 of file Map2DHeading.h.

References fourConnected.

◆ SetFourConnected()

void Map2DHeading::SetFourConnected ( )
inline

Definition at line 95 of file Map2DHeading.h.

References fourConnected.

◆ StoreGoal()

void Map2DHeading::StoreGoal ( xyhLoc s)
inlinevirtual

Stores the goal for use by single-state HCost.

Reimplemented from SearchEnvironment< xyhLoc, xyhAct >.

Definition at line 88 of file Map2DHeading.h.

Member Data Documentation

◆ cosTable

std::vector<float> Map2DHeading::cosTable
protected

Definition at line 106 of file Map2DHeading.h.

Referenced by BuildAngleTables(), and myCos().

◆ costs

CostTable Map2DHeading::costs
protected

Definition at line 114 of file Map2DHeading.h.

◆ DIAGONAL_COST

double Map2DHeading::DIAGONAL_COST
protected

Definition at line 104 of file Map2DHeading.h.

Referenced by GCost(), GetDiagonalCost(), HCost(), Map2DHeading(), and SetDiagonalCost().

◆ drawWeights

bool Map2DHeading::drawWeights

Definition at line 101 of file Map2DHeading.h.

Referenced by Map2DHeading(), and OpenGLDraw().

◆ fourConnected

bool Map2DHeading::fourConnected
protected

Definition at line 105 of file Map2DHeading.h.

Referenced by EightConnected(), FourConnected(), SetEightConnected(), and SetFourConnected().

◆ map

Map* Map2DHeading::map
protected

Definition at line 103 of file Map2DHeading.h.

Referenced by GetActions(), GetMap(), GetSuccessors(), LegalState(), Map2DHeading(), and OpenGLDraw().

◆ sinTable

std::vector<float> Map2DHeading::sinTable
protected

Definition at line 107 of file Map2DHeading.h.

Referenced by BuildAngleTables(), and mySin().


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