Go to the documentation of this file.
12 #ifndef UNITRACESIMULATION_H
13 #define UNITRACESIMULATION_H
28 template<
class state,
class action,
class environment>
85 printf(
"EpisodicSimulation::doPreTimestepCalc checking onTarget\n");
89 for (
unsigned int t = 0; t < this->
units.size(); t++)
90 if (this->
units[t]->agent->Done())
91 this->
units[t]->converged =
true;
102 for (
unsigned int t = 0; t < this->
units.size(); t++)
104 if (
verbose) printf(
"Check unit %d (%s)\n", t, this->
units[t]->agent->GetName());
109 if (
verbose) printf(
"Unit %d is racing, check if it is on target\n",t);
113 if (
verbose) printf(
"Unit %d is not on target, break\n",t);
126 for (
unsigned int t = 0; t < this->
units.size(); t++)
128 if (
verbose) printf(
"Check unit %d (%s)\n", t, this->
units[t]->agent->GetName());
133 if (
verbose) printf(
"Unit %d is racing, check if it is on target\n",t);
137 if (
verbose) printf(
"Unit %d is on target, break\n",t);
154 for (
unsigned int t = 0; t < this->
units.size(); t++)
159 (
double) this->units[t]->totalDistance);
170 for (
unsigned int t = 0; t < this->
units.size(); t++)
174 std::cout <<
"Round ended, moving " << t <<
" (" << this->
units[t]->agent->GetName()
175 <<
") back to " << this->
units[t]->startState << std::endl;
184 for (
unsigned int t = 0; t < this->
units.size(); t++)
187 this->
units[t]->agent->LogFinalStats(&this->
stats);
197 printf(
"Continuing trial: %d\n",
currRound);
200 for (
unsigned int t = 0; t < this->
unitGroups.size(); t++)
207 for (
unsigned int t = 0; t < this->
units.size(); t++)
213 this->
units[t]->totalThinking = 0;
214 this->
units[t]->totalDistance = 0;
216 if (this->
units[t]->converged)
220 this->
stats.
AddStat(
"MakeMoveThinkingTime", this->
units[t]->agent->GetName(), (
double)0);
229 this->
units[t]->currentState = this->
units[t]->startState;
230 this->
units[t]->agent->GetUnitGroup()->UpdateLocation(this->
units[t]->agent, this->
env, this->
units[t]->startState,
false,
this);
246 for (
unsigned int t = 0; (t < this->
units.size()); t++)
251 if (!this->
units[t]->agent->Done())
267 u->
agent->GetLocation(s1);
268 u->
agent->GetGoal(s2);
283 default: assert(
false);
bool IsUnitRacing(UnitInfo< state, action, environment > *u)
virtual void ClearAllUnits()
tUnitOnTargetStatus
A class where units repeatedly path from a start to a goal until they have stopped exploring/learning...
virtual void DoTimestepCalc(double amount)
virtual void DoTimestepCalc(double amount)
void SetDisjunctiveTrialEnd(bool value)
virtual void ClearAllUnits()
std::vector< bool > racingInfo
void SetTravelLimit(double lim)
void SetStopOnConvergence(bool stop)
void DisableTravelLimit()
void SetTrialLimit(long maxTrials)
std::vector< UnitInfo< state, action, environment > * > units
void SetTargetTolerance(double x)
int AddNonRacingUnit(Unit< state, action, environment > *u, double timeOffset=0.)
virtual void DoPreTimestepCalc()
The basic simulation class for the world.
virtual int AddUnit(Unit< state, action, environment > *u, double timeOffset=0.)
double GetTargetTolerance()
tUnitOnTargetStatus UnitOnTargetStatus(UnitInfo< state, action, environment > *u)
void AddStat(const char *category, const char *owner, double value)
Add a new stat entry for the given category, owner and value.
virtual ~EpisodicSimulation()
bool UnitOnTarget(UnitInfo< state, action, environment > *u)
EpisodicSimulation(environment *e)
int AddUnit(Unit< state, action, environment > *u, double timeOffset=0.)
Unit< state, action, environment > * agent
std::vector< UnitGroup< state, action, environment > * > unitGroups
virtual bool EpisodeDone()