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

A configurable billiard ball unit. More...

#include <RandomUnits.h>

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

Public Member Functions

 BilliardBallUnit (int _x, int _y, int _coolOffPeriod, double _probDirChange)
 
virtual const char * GetName ()
 
bool MakeMove (MapEnvironment *, OccupancyInterface< xyLoc, tDirection > *, MapSimulationInfo *, tDirection &dir)
 Make a move. More...
 
void UpdateLocation (MapEnvironment *, xyLoc &, bool, MapSimulationInfo *)
 Set location after last move. 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
 
int collisionStatus
 
double probDirChange
 
int coolOffPeriod
 

Additional Inherited Members

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

Detailed Description

A configurable billiard ball unit.

Definition at line 64 of file RandomUnits.h.

Constructor & Destructor Documentation

◆ BilliardBallUnit()

BilliardBallUnit::BilliardBallUnit ( int  _x,
int  _y,
int  _coolOffPeriod,
double  _probDirChange 
)
inline

Definition at line 66 of file RandomUnits.h.

References collisionStatus, coolOffPeriod, kStayIndex, lastIndex, and probDirChange.

Member Function Documentation

◆ GetName()

virtual const char* BilliardBallUnit::GetName ( )
inlinevirtual

Implements Unit< xyLoc, tDirection, MapEnvironment >.

Definition at line 73 of file RandomUnits.h.

◆ MakeMove()

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

Make a move.

the billiard ball unit keeps following the same direction until either a collision or instability

Implements Unit< xyLoc, tDirection, MapEnvironment >.

Definition at line 62 of file RandomUnits.cpp.

References lastIndex, and possibleDir.

◆ UpdateLocation()

void BilliardBallUnit::UpdateLocation ( MapEnvironment me,
xyLoc l,
bool  success,
MapSimulationInfo si 
)
virtual

Set location after last move.

if the billiard ball unit collides, it will cool off for a period of time otherwise, it may changes its mind if it unstable

Reimplemented from MapUnit.

Definition at line 74 of file RandomUnits.cpp.

References collisionStatus, coolOffPeriod, fless(), kStayIndex, lastIndex, probDirChange, and MapUnit::UpdateLocation().

Member Data Documentation

◆ collisionStatus

int BilliardBallUnit::collisionStatus
private

Definition at line 79 of file RandomUnits.h.

Referenced by BilliardBallUnit(), and UpdateLocation().

◆ coolOffPeriod

int BilliardBallUnit::coolOffPeriod
private

Definition at line 81 of file RandomUnits.h.

Referenced by BilliardBallUnit(), and UpdateLocation().

◆ lastIndex

int BilliardBallUnit::lastIndex
private

Definition at line 78 of file RandomUnits.h.

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

◆ probDirChange

double BilliardBallUnit::probDirChange
private

Definition at line 80 of file RandomUnits.h.

Referenced by BilliardBallUnit(), and UpdateLocation().


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