HOG2
Public Member Functions | Private Member Functions | Private Attributes | List of all members
NaryTree Class Reference

#include <NaryTree.h>

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

Public Member Functions

 NaryTree (int branchingFactor, int depth)
 
int GetBranchingFactor ()
 
NaryState GetLastNode ()
 
NaryState GetParent (NaryState s) const
 
virtual void GetSuccessors (const NaryState &nodeID, std::vector< NaryState > &neighbors) const
 
virtual void GetActions (const NaryState &nodeID, std::vector< NaryAction > &actions) const
 
virtual NaryAction GetAction (const NaryState &s1, const NaryState &s2) const
 
virtual void ApplyAction (NaryState &s, NaryAction a) const
 
virtual void GetNextState (const NaryState &, NaryAction, NaryState &) const
 
virtual bool InvertAction (NaryAction &a) const
 
virtual double HCost (const NaryState &node1, const NaryState &node2) const
 Heuristic value between two arbitrary nodes. More...
 
virtual double HCost (const NaryState &node) const
 Heuristic value between node and the stored goal. More...
 
virtual double GCost (const NaryState &node1, const NaryState &node2) const
 
virtual double GCost (const NaryState &node, const NaryAction &act) const
 
virtual bool GoalTest (const NaryState &node, const NaryState &goal) const
 
virtual bool GoalTest (const NaryState &node) const
 Goal Test if the goal is stored. More...
 
virtual uint64_t GetStateHash (const NaryState &node) const
 
virtual uint64_t GetActionHash (NaryAction act) const
 
void SetWidthScale (double v)
 
virtual void OpenGLDraw () const
 
virtual void OpenGLDraw (const NaryState &) const
 
virtual void OpenGLDraw (const NaryState &, const NaryState &, float) const
 Draw the transition at some percentage 0...1 between two states. More...
 
virtual void OpenGLDraw (const NaryState &, const NaryAction &) const
 
void GLDrawLine (const NaryState &x, const NaryState &y) const
 
virtual void Draw (Graphics::Display &display) const
 
virtual void Draw (Graphics::Display &display, const NaryState &s) const
 
virtual void DrawLine (Graphics::Display &display, const NaryState &, const NaryState &, float width) const
 
NaryState GetClosestNode (float x, float y)
 
- Public Member Functions inherited from SearchEnvironment< NaryState, NaryAction >
virtual ~SearchEnvironment ()
 
virtual int GetNumSuccessors (const NaryState &stateID) const
 
virtual void UndoAction (NaryState &s, NaryAction a) const
 
virtual void StoreGoal (NaryState &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 NaryState &node1, const NaryState &node2, double parentHCost) const
 
virtual uint64_t GetMaxHash () const
 
virtual void GetStateFromHash (uint64_t parent, NaryState &s) const
 
virtual double GetPathLength (std::vector< NaryState > &neighbors)
 
virtual double GetPathLength (const NaryState &start, std::vector< NaryAction > &neighbors)
 
virtual OccupancyInterface< NaryState, NaryAction > * GetOccupancyInfo ()
 
virtual void SetOccupancyInfo (OccupancyInterface< NaryState, NaryAction > *)
 
virtual void OpenGLDraw () const
 
virtual void GLLabelState (const NaryState &, const char *) const
 
virtual void GLDrawPath (const std::vector< NaryState > &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
 
- Public Member Functions inherited from Heuristic< NaryState >
 Heuristic ()
 
virtual ~Heuristic ()
 

Private Member Functions

int GetDepth (const NaryState s) const
 
float GetDepthRadius (int depth) const
 
uint64_t GetOffset (const NaryState s) const
 
void GetLocation (const NaryState &s, float &x, float &y) const
 

Private Attributes

int b
 
int d
 
std::vector< uint64_t > nodesAtDepth
 
std::vector< uint64_t > totalNodesAtDepth
 
double scaleWidth
 

Additional Inherited Members

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

Detailed Description

Definition at line 21 of file NaryTree.h.

Constructor & Destructor Documentation

◆ NaryTree()

NaryTree::NaryTree ( int  branchingFactor,
int  depth 
)

Definition at line 14 of file NaryTree.cpp.

References b, d, nodesAtDepth, scaleWidth, and totalNodesAtDepth.

Member Function Documentation

◆ ApplyAction()

void NaryTree::ApplyAction ( NaryState s,
NaryAction  a 
) const
virtual

Implements SearchEnvironment< NaryState, NaryAction >.

Definition at line 59 of file NaryTree.cpp.

References b.

◆ Draw() [1/2]

void NaryTree::Draw ( Graphics::Display display) const
virtual

◆ Draw() [2/2]

void NaryTree::Draw ( Graphics::Display display,
const NaryState s 
) const
virtual

◆ DrawLine()

void NaryTree::DrawLine ( Graphics::Display display,
const NaryState f,
const NaryState t,
float  width 
) const
virtual

◆ GCost() [1/2]

double NaryTree::GCost ( const NaryState node,
const NaryAction act 
) const
virtual

Implements SearchEnvironment< NaryState, NaryAction >.

Definition at line 89 of file NaryTree.cpp.

◆ GCost() [2/2]

double NaryTree::GCost ( const NaryState node1,
const NaryState node2 
) const
virtual

Implements SearchEnvironment< NaryState, NaryAction >.

Definition at line 87 of file NaryTree.cpp.

◆ GetAction()

NaryAction NaryTree::GetAction ( const NaryState s1,
const NaryState s2 
) const
virtual

Reimplemented from SearchEnvironment< NaryState, NaryAction >.

Definition at line 53 of file NaryTree.cpp.

◆ GetActionHash()

uint64_t NaryTree::GetActionHash ( NaryAction  act) const
virtual

Implements SearchEnvironment< NaryState, NaryAction >.

Definition at line 98 of file NaryTree.cpp.

References b.

◆ GetActions()

void NaryTree::GetActions ( const NaryState nodeID,
std::vector< NaryAction > &  actions 
) const
virtual

Implements SearchEnvironment< NaryState, NaryAction >.

Definition at line 42 of file NaryTree.cpp.

References b, d, and GetDepth().

◆ GetBranchingFactor()

int NaryTree::GetBranchingFactor ( )
inline

Definition at line 25 of file NaryTree.h.

References b.

◆ GetClosestNode()

NaryState NaryTree::GetClosestNode ( float  x,
float  y 
)

Definition at line 106 of file NaryTree.cpp.

References GetLocation(), sqdist(), and totalNodesAtDepth.

◆ GetDepth()

int NaryTree::GetDepth ( const NaryState  s) const
private

Definition at line 135 of file NaryTree.cpp.

References b.

Referenced by Draw(), DrawLine(), GetActions(), GetLocation(), GetSuccessors(), and OpenGLDraw().

◆ GetDepthRadius()

float NaryTree::GetDepthRadius ( int  depth) const
private

Definition at line 245 of file NaryTree.cpp.

References min(), and nodesAtDepth.

Referenced by Draw(), and DrawLine().

◆ GetLastNode()

NaryState NaryTree::GetLastNode ( )
inline

Definition at line 26 of file NaryTree.h.

References totalNodesAtDepth.

◆ GetLocation()

void NaryTree::GetLocation ( const NaryState s,
float &  x,
float &  y 
) const
private

Definition at line 124 of file NaryTree.cpp.

References d, GetDepth(), GetOffset(), nodesAtDepth, and scaleWidth.

Referenced by Draw(), DrawLine(), GetClosestNode(), GLDrawLine(), and OpenGLDraw().

◆ GetNextState()

void NaryTree::GetNextState ( const NaryState s1,
NaryAction  a,
NaryState s2 
) const
virtual

Reimplemented from SearchEnvironment< NaryState, NaryAction >.

Definition at line 70 of file NaryTree.cpp.

References b.

◆ GetOffset()

uint64_t NaryTree::GetOffset ( const NaryState  s) const
private

Definition at line 144 of file NaryTree.cpp.

References totalNodesAtDepth.

Referenced by GetLocation().

◆ GetParent()

NaryState NaryTree::GetParent ( NaryState  s) const

Definition at line 156 of file NaryTree.cpp.

References b.

◆ GetStateHash()

uint64_t NaryTree::GetStateHash ( const NaryState node) const
virtual

Implements SearchEnvironment< NaryState, NaryAction >.

Definition at line 95 of file NaryTree.cpp.

◆ GetSuccessors()

void NaryTree::GetSuccessors ( const NaryState nodeID,
std::vector< NaryState > &  neighbors 
) const
virtual

Implements SearchEnvironment< NaryState, NaryAction >.

Definition at line 32 of file NaryTree.cpp.

References b, d, and GetDepth().

Referenced by Draw(), and OpenGLDraw().

◆ GLDrawLine()

void NaryTree::GLDrawLine ( const NaryState x,
const NaryState y 
) const
virtual

◆ GoalTest() [1/2]

virtual bool NaryTree::GoalTest ( const NaryState node) const
inlinevirtual

◆ GoalTest() [2/2]

bool NaryTree::GoalTest ( const NaryState node,
const NaryState goal 
) const
virtual

Implements SearchEnvironment< NaryState, NaryAction >.

Definition at line 91 of file NaryTree.cpp.

◆ HCost() [1/2]

virtual double NaryTree::HCost ( const NaryState node) const
inlinevirtual

Heuristic value between node and the stored goal.

Asserts that the goal is stored

Reimplemented from SearchEnvironment< NaryState, NaryAction >.

Definition at line 43 of file NaryTree.h.

References SearchEnvironment< NaryState, NaryAction >::bValidSearchGoal, HCost(), and SearchEnvironment< NaryState, NaryAction >::searchGoal.

◆ HCost() [2/2]

double NaryTree::HCost ( const NaryState node1,
const NaryState node2 
) const
virtual

Heuristic value between two arbitrary nodes.

Implements SearchEnvironment< NaryState, NaryAction >.

Definition at line 84 of file NaryTree.cpp.

Referenced by HCost().

◆ InvertAction()

bool NaryTree::InvertAction ( NaryAction a) const
virtual

Implements SearchEnvironment< NaryState, NaryAction >.

Definition at line 80 of file NaryTree.cpp.

◆ OpenGLDraw() [1/4]

void NaryTree::OpenGLDraw ( ) const
virtual

Definition at line 163 of file NaryTree.cpp.

References GetLocation(), GetSuccessors(), and totalNodesAtDepth.

◆ OpenGLDraw() [2/4]

void NaryTree::OpenGLDraw ( const NaryState s) const
virtual

◆ OpenGLDraw() [3/4]

void NaryTree::OpenGLDraw ( const NaryState ,
const NaryAction  
) const
virtual

Reimplemented from SearchEnvironment< NaryState, NaryAction >.

Definition at line 285 of file NaryTree.cpp.

◆ OpenGLDraw() [4/4]

void NaryTree::OpenGLDraw ( const NaryState ,
const NaryState ,
float   
) const
virtual

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

Reimplemented from SearchEnvironment< NaryState, NaryAction >.

Definition at line 284 of file NaryTree.cpp.

◆ SetWidthScale()

void NaryTree::SetWidthScale ( double  v)
inline

Definition at line 58 of file NaryTree.h.

References scaleWidth.

Member Data Documentation

◆ b

int NaryTree::b
private

◆ d

int NaryTree::d
private

Definition at line 78 of file NaryTree.h.

Referenced by GetActions(), GetLocation(), GetSuccessors(), NaryTree(), and OpenGLDraw().

◆ nodesAtDepth

std::vector<uint64_t> NaryTree::nodesAtDepth
private

Definition at line 79 of file NaryTree.h.

Referenced by GetDepthRadius(), GetLocation(), NaryTree(), and OpenGLDraw().

◆ scaleWidth

double NaryTree::scaleWidth
private

Definition at line 81 of file NaryTree.h.

Referenced by GetLocation(), NaryTree(), and SetWidthScale().

◆ totalNodesAtDepth

std::vector<uint64_t> NaryTree::totalNodesAtDepth
private

Definition at line 80 of file NaryTree.h.

Referenced by Draw(), GetClosestNode(), GetLastNode(), GetOffset(), NaryTree(), and OpenGLDraw().


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