HOG2
|
A unit that moves in random directions changing direction randomly. More...
#include <RandomUnit.h>
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 |
A unit that moves in random directions changing direction randomly.
Definition at line 16 of file RandomUnit.h.
|
inline |
Definition at line 19 of file RandomUnit.h.
|
inlinevirtual |
Definition at line 20 of file RandomUnit.h.
|
inline |
Definition at line 23 of file RandomUnits.h.
References RandomUnit< state, action, environment >::lastIndex.
|
inlinevirtual |
Reimplemented from Unit< state, action, environment >.
Definition at line 45 of file RandomUnit.h.
References RandomUnit< state, action, environment >::loc.
|
inlinevirtual |
Implements Unit< state, action, environment >.
Definition at line 34 of file RandomUnit.h.
References RandomUnit< state, action, environment >::loc.
|
inlinevirtual |
Implements Unit< state, action, environment >.
Definition at line 21 of file RandomUnit.h.
|
inlinevirtual |
Implements Unit< state, action, environment >.
Definition at line 25 of file RandomUnits.h.
|
inlinevirtual |
Implements Unit< state, action, environment >.
Definition at line 22 of file RandomUnit.h.
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.
|
inlinevirtual |
Implements Unit< state, action, environment >.
Definition at line 36 of file RandomUnit.h.
References PublicUnitInfo< state, action, environment >::currentState, SimulationInfo< state, action, environment >::GetCurrentUnit(), SimulationInfo< state, action, environment >::GetPublicUnitInfo(), SimulationInfo< state, action, environment >::GetSimulationTime(), PublicUnitInfo< state, action, environment >::lastState, PublicUnitInfo< state, action, environment >::lastTime, and PublicUnitInfo< state, action, environment >::nextTime.
|
inlinevirtual |
Implements Unit< state, action, environment >.
Definition at line 29 of file RandomUnit.h.
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().
|
private |
Definition at line 31 of file RandomUnits.h.
Referenced by RandomUnit< state, action, environment >::MakeMove(), RandomUnit< state, action, environment >::RandomUnit(), and RandomUnit< state, action, environment >::UpdateLocation().
|
private |
Definition at line 48 of file RandomUnit.h.
Referenced by RandomUnit< state, action, environment >::GetGoal(), and RandomUnit< state, action, environment >::GetLocation().