HOG2
Public Member Functions | Private Attributes | List of all members
RandomUnit< state, action, environment > Class Template Reference

A unit that moves in random directions changing direction randomly. More...

#include <RandomUnit.h>

Inheritance diagram for RandomUnit< state, action, environment >:
Inheritance graph
[legend]
Collaboration diagram for RandomUnit< state, action, environment >:
Collaboration graph
[legend]

Public Member Functions

 RandomUnit (state startLoc)
 
virtual ~RandomUnit ()
 
virtual const char * GetName ()
 
virtual bool MakeMove (environment *theEnv, OccupancyInterface< state, action > *, SimulationInfo< state, action, environment > *, action &a)
 
virtual void UpdateLocation (environment *, state &newloc, bool success, SimulationInfo< state, action, environment > *)
 
virtual void GetLocation (state &l)
 
virtual void OpenGLDraw (const environment *theEnv, const SimulationInfo< state, action, environment > *si) const
 
virtual void GetGoal (state &s)
 
 RandomUnit (int _x, int _y)
 
virtual const char * GetName ()
 
bool MakeMove (MapEnvironment *, OccupancyInterface< xyLoc, tDirection > *, MapSimulationInfo *, tDirection &dir)
 Make a random move. More...
 
void UpdateLocation (MapEnvironment *, xyLoc &, bool, MapSimulationInfo *)
 Set location after last move. More...
 
- Public Member Functions inherited from Unit< state, action, environment >
 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< 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)
 

Private Attributes

state loc
 
int lastIndex
 

Detailed Description

template<class state, class action, class environment>
class RandomUnit< state, action, environment >

A unit that moves in random directions changing direction randomly.

Definition at line 16 of file RandomUnit.h.

Constructor & Destructor Documentation

◆ RandomUnit() [1/2]

template<class state , class action , class environment >
RandomUnit< state, action, environment >::RandomUnit ( state  startLoc)
inline

Definition at line 19 of file RandomUnit.h.

◆ ~RandomUnit()

template<class state , class action , class environment >
virtual RandomUnit< state, action, environment >::~RandomUnit ( )
inlinevirtual

Definition at line 20 of file RandomUnit.h.

◆ RandomUnit() [2/2]

template<class state , class action , class environment >
RandomUnit< state, action, environment >::RandomUnit ( int  _x,
int  _y 
)
inline

Definition at line 23 of file RandomUnits.h.

References RandomUnit< state, action, environment >::lastIndex.

Member Function Documentation

◆ GetGoal()

template<class state , class action , class environment >
virtual void RandomUnit< state, action, environment >::GetGoal ( state &  s)
inlinevirtual

Reimplemented from Unit< state, action, environment >.

Definition at line 45 of file RandomUnit.h.

References RandomUnit< state, action, environment >::loc.

◆ GetLocation()

template<class state , class action , class environment >
virtual void RandomUnit< state, action, environment >::GetLocation ( state &  l)
inlinevirtual

◆ GetName() [1/2]

template<class state , class action , class environment >
virtual const char* RandomUnit< state, action, environment >::GetName ( )
inlinevirtual

Implements Unit< state, action, environment >.

Definition at line 21 of file RandomUnit.h.

◆ GetName() [2/2]

template<class state , class action , class environment >
virtual const char* RandomUnit< state, action, environment >::GetName ( )
inlinevirtual

Implements Unit< state, action, environment >.

Definition at line 25 of file RandomUnits.h.

◆ MakeMove() [1/2]

template<class state , class action , class environment >
virtual bool RandomUnit< state, action, environment >::MakeMove ( environment *  theEnv,
OccupancyInterface< state, action > *  ,
SimulationInfo< state, action, environment > *  ,
action &  a 
)
inlinevirtual

Implements Unit< state, action, environment >.

Definition at line 22 of file RandomUnit.h.

◆ MakeMove() [2/2]

template<class state , class action , class environment >
bool RandomUnit< state, action, environment >::MakeMove ( MapEnvironment ,
OccupancyInterface< xyLoc, tDirection > *  ,
MapSimulationInfo ,
tDirection dir 
)

Make a random move.

the random unit follows a certain direction for a random amount of time, and then picks a new direction. makeMove just returns the current direction.

Definition at line 19 of file RandomUnits.cpp.

References RandomUnit< state, action, environment >::lastIndex, and possibleDir.

◆ OpenGLDraw()

template<class state , class action , class environment >
virtual void RandomUnit< state, action, environment >::OpenGLDraw ( const environment *  theEnv,
const SimulationInfo< state, action, environment > *  si 
) const
inlinevirtual

◆ UpdateLocation() [1/2]

template<class state , class action , class environment >
virtual void RandomUnit< state, action, environment >::UpdateLocation ( environment *  ,
state &  newloc,
bool  success,
SimulationInfo< state, action, environment > *   
)
inlinevirtual

Implements Unit< state, action, environment >.

Definition at line 29 of file RandomUnit.h.

◆ UpdateLocation() [2/2]

template<class state , class action , class environment >
void RandomUnit< state, action, environment >::UpdateLocation ( MapEnvironment me,
xyLoc l,
bool  success,
MapSimulationInfo si 
)

Set location after last move.

After moving, the unit picks a new random direction if the move wasn't a success. If it was, it has a 5% chance of changing direction.

Definition at line 31 of file RandomUnits.cpp.

References RandomUnit< state, action, environment >::lastIndex, and MapUnit::UpdateLocation().

Member Data Documentation

◆ lastIndex

template<class state , class action , class environment >
int RandomUnit< state, action, environment >::lastIndex
private

◆ loc

template<class state , class action , class environment >
state RandomUnit< state, action, environment >::loc
private

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