HOG2
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
SearchUnit Class Reference

A general unit which collects path information from a SearchAlgorithm and incrementally executes that path in the world. More...

#include <SearchUnit.h>

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

Public Member Functions

 SearchUnit (int x, int y, AbsMapUnit *target, SearchAlgorithm *alg)
 
virtual ~SearchUnit ()
 
virtual const char * GetName ()
 
virtual SearchAlgorithmgetAlgorithm ()
 
virtual bool Done ()
 
void GetGoal (xyLoc &gs)
 
virtual void setTarget (AbsMapUnit *u)
 
virtual bool MakeMove (AbsMapEnvironment *ame, OccupancyInterface< xyLoc, tDirection > *, AbsMapSimulationInfo *si, tDirection &dir)
 
virtual bool makeMove (MapProvider *, reservationProvider *, AbsMapSimulationInfo *simInfo, tDirection &dir)
 
void UpdateLocation (AbsMapEnvironment *, xyLoc &l, bool success, AbsMapSimulationInfo *si)
 
virtual void updateLocation (int _x, int _y, bool, AbsMapSimulationInfo *)
 
virtual void OpenGLDraw (const AbsMapEnvironment *, const AbsMapSimulationInfo *) const
 
void LogStats (StatCollection *stats)
 log an stats that may have been computed during the last run More...
 
void LogFinalStats (StatCollection *stats)
 log any final one-time stats before a simulation is ended More...
 
- Public Member Functions inherited from AbsMapUnit
 AbsMapUnit (int x, int y)
 
virtual ~AbsMapUnit ()
 
virtual void GetLocation (xyLoc &l)
 
- Public Member Functions inherited from Unit< state, action, environment >
 Unit ()
 
virtual ~Unit ()
 
virtual bool MakeMove (environment *, OccupancyInterface< state, action > *, SimulationInfo< state, action, environment > *, action &a)=0
 
virtual void UpdateLocation (environment *, state &, bool success, SimulationInfo< state, action, environment > *)=0
 
virtual void GetLocation (state &)=0
 
virtual void OpenGLDraw (const environment *, const SimulationInfo< state, action, environment > *) const =0
 
virtual void GetGoal (state &s)
 
virtual double GetSpeed ()
 
void SetSpeed (double s)
 
virtual void SetColor (GLfloat _r, GLfloat _g, GLfloat _b)
 
virtual void GetColor (GLfloat &_r, GLfloat &_g, GLfloat &_b) const
 
UnitGroup< state, action, environment > * GetUnitGroup ()
 
void SetUnitGroup (UnitGroup< state, action, environment > *_group)
 
virtual unsigned int GetNum ()
 
virtual void SetNum (unsigned int num)
 
virtual void StartNewTrial (StatCollection *)
 
virtual int GetPriority ()
 
virtual void SetPriority (int val)
 

Protected Member Functions

virtual void addPathToCache (path *p)
 
bool getCachedMove (tDirection &dir)
 

Protected Attributes

int nodesExpanded
 
int nodesTouched
 
std::vector< tDirectionmoves
 
SearchAlgorithmalgorithm
 
spreadExecSearchAlgorithms_algorithm
 
pathspread_cache
 
AbsMapUnittarget
 
double targetTime
 
bool onTarget
 
- Protected Attributes inherited from AbsMapUnit
GLfloat r
 
GLfloat g
 
GLfloat b
 
xyLoc loc
 

Detailed Description

A general unit which collects path information from a SearchAlgorithm and incrementally executes that path in the world.

Definition at line 26 of file SearchUnit.h.

Constructor & Destructor Documentation

◆ SearchUnit()

SearchUnit::SearchUnit ( int  x,
int  y,
AbsMapUnit target,
SearchAlgorithm alg 
)

◆ ~SearchUnit()

SearchUnit::~SearchUnit ( )
virtual

Definition at line 79 of file SearchUnit.cpp.

References algorithm, and spread_cache.

Member Function Documentation

◆ addPathToCache()

void SearchUnit::addPathToCache ( path p)
protectedvirtual

Definition at line 222 of file SearchUnit.cpp.

References node::GetLabelL(), GetName(), kE, GraphAbstractionConstants::kFirstData, kN, kS, kStay, kW, moves, path::n, and path::next.

Referenced by makeMove().

◆ Done()

virtual bool SearchUnit::Done ( )
inlinevirtual

Reimplemented from Unit< state, action, environment >.

Definition at line 33 of file SearchUnit.h.

References onTarget.

◆ getAlgorithm()

virtual SearchAlgorithm* SearchUnit::getAlgorithm ( )
inlinevirtual

Definition at line 31 of file SearchUnit.h.

References algorithm.

◆ getCachedMove()

bool SearchUnit::getCachedMove ( tDirection dir)
protected

◆ GetGoal()

void SearchUnit::GetGoal ( xyLoc gs)
inlinevirtual

Implements AbsMapUnit.

Definition at line 35 of file SearchUnit.h.

References AbsMapUnit::GetLocation(), and target.

◆ GetName()

virtual const char* SearchUnit::GetName ( )
inlinevirtual

Implements AbsMapUnit.

Reimplemented in praStarUnit.

Definition at line 30 of file SearchUnit.h.

References algorithm, and SearchAlgorithm::GetName().

Referenced by addPathToCache(), LogStats(), makeMove(), and updateLocation().

◆ LogFinalStats()

void SearchUnit::LogFinalStats ( StatCollection )
virtual

log any final one-time stats before a simulation is ended

Reimplemented from Unit< state, action, environment >.

Definition at line 346 of file SearchUnit.cpp.

References algorithm, and SearchAlgorithm::LogFinalStats().

◆ LogStats()

void SearchUnit::LogStats ( StatCollection )
virtual

log an stats that may have been computed during the last run

Reimplemented from Unit< state, action, environment >.

Definition at line 330 of file SearchUnit.cpp.

References StatCollection::AddStat(), GetName(), nodesExpanded, and nodesTouched.

◆ MakeMove()

virtual bool SearchUnit::MakeMove ( AbsMapEnvironment *  ame,
OccupancyInterface< xyLoc, tDirection > *  ,
AbsMapSimulationInfo si,
tDirection dir 
)
inlinevirtual

Implements AbsMapUnit.

Definition at line 41 of file SearchUnit.h.

References makeMove().

◆ makeMove()

bool SearchUnit::makeMove ( MapProvider mp,
reservationProvider rp,
AbsMapSimulationInfo simInfo,
tDirection dir 
)
virtual

◆ OpenGLDraw()

void SearchUnit::OpenGLDraw ( const AbsMapEnvironment *  ame,
const AbsMapSimulationInfo si 
) const
virtual

◆ setTarget()

virtual void SearchUnit::setTarget ( AbsMapUnit u)
inlinevirtual

Definition at line 37 of file SearchUnit.h.

References target.

◆ UpdateLocation()

void SearchUnit::UpdateLocation ( AbsMapEnvironment *  ,
xyLoc l,
bool  success,
AbsMapSimulationInfo si 
)
inlinevirtual

Reimplemented from AbsMapUnit.

Definition at line 45 of file SearchUnit.h.

References updateLocation(), xyLoc::x, and xyLoc::y.

◆ updateLocation()

void SearchUnit::updateLocation ( int  _x,
int  _y,
bool  success,
AbsMapSimulationInfo  
)
virtual

Definition at line 270 of file SearchUnit.cpp.

References GetName(), moves, spread_cache, verbose, loc::x, and loc::y.

Referenced by UpdateLocation().

Member Data Documentation

◆ algorithm

SearchAlgorithm* SearchUnit::algorithm
protected

◆ moves

std::vector<tDirection> SearchUnit::moves
protected

◆ nodesExpanded

int SearchUnit::nodesExpanded
protected

Definition at line 54 of file SearchUnit.h.

Referenced by getCachedMove(), LogStats(), makeMove(), and SearchUnit().

◆ nodesTouched

int SearchUnit::nodesTouched
protected

Definition at line 55 of file SearchUnit.h.

Referenced by getCachedMove(), LogStats(), makeMove(), and SearchUnit().

◆ onTarget

bool SearchUnit::onTarget
protected

Definition at line 65 of file SearchUnit.h.

Referenced by Done(), makeMove(), OpenGLDraw(), and SearchUnit().

◆ s_algorithm

spreadExecSearchAlgorithm* SearchUnit::s_algorithm
protected

Definition at line 59 of file SearchUnit.h.

Referenced by getCachedMove(), makeMove(), and SearchUnit().

◆ spread_cache

path* SearchUnit::spread_cache
protected

Definition at line 60 of file SearchUnit.h.

Referenced by getCachedMove(), makeMove(), SearchUnit(), updateLocation(), and ~SearchUnit().

◆ target

AbsMapUnit* SearchUnit::target
protected

Definition at line 62 of file SearchUnit.h.

Referenced by GetGoal(), makeMove(), OpenGLDraw(), SearchUnit(), and setTarget().

◆ targetTime

double SearchUnit::targetTime
protected

Definition at line 64 of file SearchUnit.h.

Referenced by makeMove(), OpenGLDraw(), and SearchUnit().


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