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

A simple unit that attempts to follow walls using the right hand rule. More...

#include <RHRUnit.h>

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

Public Member Functions

 RHRUnit (int x, int y)
 
const char * GetName ()
 
bool MakeMove (MapEnvironment *, OccupancyInterface< xyLoc, tDirection > *, MapSimulationInfo *, tDirection &)
 Make the next move. More...
 
void UpdateLocation (MapEnvironment *, xyLoc &, bool, MapSimulationInfo *)
 set rhr unit location. More...
 
- Public Member Functions inherited from MapUnit
 MapUnit (int x, int y)
 
virtual void GetLocation (xyLoc &l)
 
virtual void OpenGLDraw (const MapEnvironment *, const MapSimulationInfo *) const
 
virtual void GetGoal (xyLoc &s)
 
- Public Member Functions inherited from Unit< xyLoc, tDirection, MapEnvironment >
 Unit ()
 
virtual ~Unit ()
 
virtual bool Done ()
 
virtual double GetSpeed ()
 
void SetSpeed (double s)
 
virtual void LogStats (StatCollection *)
 log an stats that may have been computed during the last run More...
 
virtual void LogFinalStats (StatCollection *)
 log any final one-time stats before a simulation is ended More...
 
virtual void SetColor (GLfloat _r, GLfloat _g, GLfloat _b)
 
virtual void GetColor (GLfloat &_r, GLfloat &_g, GLfloat &_b) const
 
UnitGroup< xyLoc, tDirection, MapEnvironment > * GetUnitGroup ()
 
void SetUnitGroup (UnitGroup< xyLoc, tDirection, MapEnvironment > *_group)
 
virtual unsigned int GetNum ()
 
virtual void SetNum (unsigned int num)
 
virtual void StartNewTrial (StatCollection *)
 
virtual int GetPriority ()
 
virtual void SetPriority (int val)
 

Private Attributes

int lastIndex
 
bool initial
 

Additional Inherited Members

- Protected Attributes inherited from MapUnit
GLfloat r
 
GLfloat g
 
GLfloat b
 
xyLoc loc
 

Detailed Description

A simple unit that attempts to follow walls using the right hand rule.

Definition at line 19 of file RHRUnit.h.

Constructor & Destructor Documentation

◆ RHRUnit()

RHRUnit::RHRUnit ( int  x,
int  y 
)
inline

Definition at line 21 of file RHRUnit.h.

References initial, and lastIndex.

Member Function Documentation

◆ GetName()

const char* RHRUnit::GetName ( )
inlinevirtual

Implements Unit< xyLoc, tDirection, MapEnvironment >.

Definition at line 24 of file RHRUnit.h.

◆ MakeMove()

bool RHRUnit::MakeMove ( MapEnvironment ,
OccupancyInterface< xyLoc, tDirection > *  ,
MapSimulationInfo ,
tDirection dir 
)
virtual

Make the next move.

Make the next move following the right hand rule.

Implements Unit< xyLoc, tDirection, MapEnvironment >.

Definition at line 17 of file RHRUnit.cpp.

References lastIndex, and possibleDir.

◆ UpdateLocation()

void RHRUnit::UpdateLocation ( MapEnvironment ,
xyLoc l,
bool  success,
MapSimulationInfo  
)
virtual

set rhr unit location.

To follow the right hand rule, we do the following: 1) if the last move was successful, turn 90 degrees to the right and keep going. 2) if the last move wasn't successful, turn 90 degrees to the left and keep going.

Reimplemented from MapUnit.

Definition at line 30 of file RHRUnit.cpp.

References initial, and lastIndex.

Member Data Documentation

◆ initial

bool RHRUnit::initial
private

Definition at line 29 of file RHRUnit.h.

Referenced by RHRUnit(), and UpdateLocation().

◆ lastIndex

int RHRUnit::lastIndex
private

Definition at line 28 of file RHRUnit.h.

Referenced by MakeMove(), RHRUnit(), and UpdateLocation().


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