HOG2
|
The basic simulation class for the world. More...
#include <UnitSimulation.h>
Public Member Functions | |
UnitSimulation (environment *se) | |
virtual | ~UnitSimulation () |
virtual int | AddUnit (Unit< state, action, environment > *u, double timeOffset=0.) |
unsigned int | GetNumUnits () const |
Unit< state, action, environment > * | GetUnit (unsigned int which) |
unsigned int | GetNumUnitGroups () const |
int | AddUnitGroup (UnitGroup< state, action, environment > *ug) |
UnitGroup< state, action, environment > * | GetUnitGroup (unsigned int which) |
virtual void | ClearAllUnits () |
virtual void | GetPublicUnitInfo (unsigned int which, PublicUnitInfo< state, action, environment > &info) const |
environment * | GetEnvironment () |
void | StepTime (double) |
double | GetSimulationTime () const |
double | GetTimeToNextStep () const |
void | SetStepType (tTimestep step) |
tTimestep | GetStepType () const |
void | SetPaused (bool val) |
bool | GetPaused () |
bool | Done () |
void | SetThinkingPenalty (double pen) |
setPenalty for thinking. More... | |
double | GetThinkingPenalty () |
getPenalty for thinking. More... | |
virtual void | OpenGLDraw () const |
virtual void | OpenGLDraw (unsigned int whichUnit) const |
void | SetLogStats (bool val) |
bool | GetLogStats () |
StatCollection * | GetStats () |
virtual SimulationInfo< state, action, environment > * | GetSimulationInfo () |
virtual unsigned int | GetCurrentUnit () const |
Public Member Functions inherited from SimulationInfo< state, action, environment > | |
virtual | ~SimulationInfo () |
Protected Member Functions | |
void | StepUnitTime (UnitInfo< state, action, environment > *ui, double timeStep) |
step time for a single unit. More... | |
bool | MakeUnitMove (UnitInfo< state, action, environment > *theUnit, action where, double &moveCost) |
virtual void | DoPreTimestepCalc () |
virtual void | DoTimestepCalc (double amount) |
virtual void | DoPostTimestepCalc () |
Protected Attributes | |
double | penalty |
bool | paused |
bool | logStats |
std::vector< UnitInfo< state, action, environment > * > | units |
std::vector< UnitGroup< state, action, environment > * > | unitGroups |
environment * | env |
double | currTime |
tTimestep | stepType |
StatCollection | stats |
unsigned int | currentActor |
The basic simulation class for the world.
Definition at line 85 of file UnitSimulation.h.
UnitSimulation< state, action, environment >::UnitSimulation | ( | environment * | se | ) |
Definition at line 152 of file UnitSimulation.h.
References kRealTime.
|
virtual |
Definition at line 166 of file UnitSimulation.h.
|
virtual |
timeOffset | is a setting to let the unit start a little bit later |
Reimplemented in EpisodicSimulation< state, action, environment >.
Definition at line 172 of file UnitSimulation.h.
References UnitInfo< state, action, environment >::agent, UnitInfo< state, action, environment >::currentState, Unit< state, action, environment >::GetLocation(), UnitInfo< state, action, environment >::historyIndex, UnitInfo< state, action, environment >::lastState, UnitInfo< state, action, environment >::nextTime, UnitInfo< state, action, environment >::startState, UnitInfo< state, action, environment >::stateHistory, UnitInfo< state, action, environment >::totalDistance, and UnitInfo< state, action, environment >::totalThinking.
Referenced by EpisodicSimulation< state, action, environment >::AddNonRacingUnit(), and EpisodicSimulation< state, action, environment >::AddUnit().
int UnitSimulation< state, action, environment >::AddUnitGroup | ( | UnitGroup< state, action, environment > * | ug | ) |
Definition at line 214 of file UnitSimulation.h.
|
virtual |
Reimplemented in EpisodicSimulation< state, action, environment >.
Definition at line 243 of file UnitSimulation.h.
References UnitInfo< state, action, environment >::agent, UnitInfo< state, action, environment >::currentState, and OccupancyInterface< state, action >::SetStateOccupied().
Referenced by EpisodicSimulation< state, action, environment >::ClearAllUnits().
bool UnitSimulation< state, action, environment >::Done |
Definition at line 270 of file UnitSimulation.h.
|
protectedvirtual |
Definition at line 359 of file UnitSimulation.h.
|
protectedvirtual |
Reimplemented in EpisodicSimulation< state, action, environment >.
Definition at line 338 of file UnitSimulation.h.
|
protectedvirtual |
Reimplemented in EpisodicSimulation< state, action, environment >.
Definition at line 343 of file UnitSimulation.h.
References kRealTime.
Referenced by EpisodicSimulation< state, action, environment >::DoTimestepCalc().
|
inlinevirtual |
Implements SimulationInfo< state, action, environment >.
Definition at line 129 of file UnitSimulation.h.
References UnitSimulation< state, action, environment >::currentActor.
|
inline |
Definition at line 102 of file UnitSimulation.h.
References UnitSimulation< state, action, environment >::env.
|
inline |
Definition at line 124 of file UnitSimulation.h.
References UnitSimulation< state, action, environment >::logStats.
|
virtual |
Implements SimulationInfo< state, action, environment >.
Definition at line 221 of file UnitSimulation.h.
|
virtual |
Implements SimulationInfo< state, action, environment >.
Definition at line 200 of file UnitSimulation.h.
|
inline |
Definition at line 111 of file UnitSimulation.h.
References UnitSimulation< state, action, environment >::paused.
|
virtual |
Implements SimulationInfo< state, action, environment >.
Definition at line 235 of file UnitSimulation.h.
References PublicUnitInfo< state, action, environment >::init().
|
inlinevirtual |
Definition at line 128 of file UnitSimulation.h.
|
inlinevirtual |
Implements SimulationInfo< state, action, environment >.
Definition at line 105 of file UnitSimulation.h.
References UnitSimulation< state, action, environment >::currTime.
|
inlinevirtual |
Implements SimulationInfo< state, action, environment >.
Definition at line 125 of file UnitSimulation.h.
References UnitSimulation< state, action, environment >::stats.
|
inline |
Definition at line 108 of file UnitSimulation.h.
References UnitSimulation< state, action, environment >::stepType.
|
inline |
getPenalty for thinking.
Gets the multiplier used to penalize thinking time.
Definition at line 118 of file UnitSimulation.h.
References UnitSimulation< state, action, environment >::penalty.
double UnitSimulation< state, action, environment >::GetTimeToNextStep |
Definition at line 305 of file UnitSimulation.h.
Unit< state, action, environment > * UnitSimulation< state, action, environment >::GetUnit | ( | unsigned int | which | ) |
Definition at line 206 of file UnitSimulation.h.
UnitGroup< state, action, environment > * UnitSimulation< state, action, environment >::GetUnitGroup | ( | unsigned int | which | ) |
Definition at line 227 of file UnitSimulation.h.
|
protected |
Definition at line 436 of file UnitSimulation.h.
References UnitInfo< state, action, environment >::agent, OccupancyInterface< state, action >::CanMove(), UnitInfo< state, action, environment >::currentState, OccupancyInterface< state, action >::MoveUnitOccupancy(), and UnitInfo< state, action, environment >::totalDistance.
|
virtual |
Definition at line 487 of file UnitSimulation.h.
|
virtual |
Definition at line 501 of file UnitSimulation.h.
|
inline |
Definition at line 123 of file UnitSimulation.h.
References UnitSimulation< state, action, environment >::logStats.
|
inline |
Definition at line 110 of file UnitSimulation.h.
References UnitSimulation< state, action, environment >::paused.
|
inline |
Definition at line 107 of file UnitSimulation.h.
References UnitSimulation< state, action, environment >::stepType.
|
inline |
setPenalty for thinking.
Sets the multiplier used to penalize thinking time.
Definition at line 116 of file UnitSimulation.h.
References UnitSimulation< state, action, environment >::penalty.
void UnitSimulation< state, action, environment >::StepTime | ( | double | timeStep | ) |
Definition at line 319 of file UnitSimulation.h.
|
protected |
step time for a single unit.
This function takes care of all the simulation details for moving a single unit, doing timing, etc. When overloading advanceTime, this function can be called for each unit that moves.
Definition at line 371 of file UnitSimulation.h.
References UnitInfo< state, action, environment >::agent, UnitInfo< state, action, environment >::currentState, Timer::EndTimer(), Unit< state, action, environment >::GetName(), Unit< state, action, environment >::GetUnitGroup(), kLockStep, kMinTime, kRealTime, kUniTime, UnitInfo< state, action, environment >::lastMove, UnitInfo< state, action, environment >::lastState, UnitInfo< state, action, environment >::lastTime, Unit< state, action, environment >::LogStats(), max, UnitInfo< state, action, environment >::nextTime, Timer::StartTimer(), and UnitInfo< state, action, environment >::totalThinking.
|
mutableprotected |
Definition at line 147 of file UnitSimulation.h.
Referenced by UnitSimulation< state, action, environment >::GetCurrentUnit().
|
protected |
Definition at line 144 of file UnitSimulation.h.
Referenced by EpisodicSimulation< state, action, environment >::DoPreTimestepCalc(), and UnitSimulation< state, action, environment >::GetSimulationTime().
|
protected |
Definition at line 143 of file UnitSimulation.h.
Referenced by EpisodicSimulation< state, action, environment >::DoPreTimestepCalc(), and UnitSimulation< state, action, environment >::GetEnvironment().
|
protected |
Definition at line 140 of file UnitSimulation.h.
Referenced by UnitSimulation< state, action, environment >::GetLogStats(), and UnitSimulation< state, action, environment >::SetLogStats().
|
protected |
Definition at line 140 of file UnitSimulation.h.
Referenced by UnitSimulation< state, action, environment >::GetPaused(), and UnitSimulation< state, action, environment >::SetPaused().
|
protected |
Definition at line 139 of file UnitSimulation.h.
Referenced by UnitSimulation< state, action, environment >::GetThinkingPenalty(), and UnitSimulation< state, action, environment >::SetThinkingPenalty().
|
protected |
Definition at line 146 of file UnitSimulation.h.
Referenced by EpisodicSimulation< state, action, environment >::DoPreTimestepCalc(), and UnitSimulation< state, action, environment >::GetStats().
|
protected |
Definition at line 145 of file UnitSimulation.h.
Referenced by UnitSimulation< state, action, environment >::GetStepType(), and UnitSimulation< state, action, environment >::SetStepType().
|
protected |
Definition at line 142 of file UnitSimulation.h.
Referenced by EpisodicSimulation< state, action, environment >::DoPreTimestepCalc().
|
protected |
Definition at line 141 of file UnitSimulation.h.
Referenced by EpisodicSimulation< state, action, environment >::DoPreTimestepCalc(), and EpisodicSimulation< state, action, environment >::EpisodeDone().