HOG2
PatrolUnit.h
Go to the documentation of this file.
1 /*
2  * $Id: patrolUnit.h
3  * hog2
4  *
5  * Created by Nathan Sturtevant on 3/23/06.
6  * Modified by Nathan Sturtevant on 02/29/20.
7  *
8  * This file is part of HOG2. See https://github.com/nathansttt/hog2 for licensing information.
9  *
10  */
11 
12 #include "AStar.h"
13 #include "PRAStar.h"
14 #include "Unit.h"
15 
16 #ifndef PATROLUNIT_H
17 #define PATROLUNIT_H
18 
19 class patrolUnit : public Unit {
20 public:
21  patrolUnit(int x, int y);
22 // patrolUnit(int _x, int _y, int numPLocations, unitSimulation* us);
23  virtual const char *GetName() { return "patrolUnit"; }
25  void OpenGLDraw(const MapProvider *, const SimulationInfo *) const;
26  void addPatrolLocation(unit *);
27  unit *GetGoal();
28  void updateLocation(int _x, int _y, bool worked, SimulationInfo *)
29  { x = _x; y = _y; if (!worked) { moves.resize(0); if (currTarget != -1) currTarget = 0; } }
30  void LogStats(StatCollection *stats);
31  void LogFinalStats(StatCollection *stats);
32 private:
33  double goToLoc(MapAbstraction *aMap, int which);
34  void addPathToCache(path *p);
35  std::vector<tDirection> moves;
36  std::vector<unit *> Locs;
38 // praStar a;
40  uint64_t nodesExpanded;
41  uint64_t nodesTouched;
42 };
43 
44 #endif
SimulationInfo
Definition: SimulationInfo.h:13
MapProvider
Definition: MapProvider.h:23
patrolUnit::goToLoc
double goToLoc(MapAbstraction *aMap, int which)
Definition: PatrolUnit.cpp:64
patrolUnit::OpenGLDraw
void OpenGLDraw(const MapProvider *, const SimulationInfo *) const
Definition: PatrolUnit.cpp:85
patrolUnit::makeMove
virtual tDirection makeMove(MapProvider *, reservationProvider *, SimulationInfo *simInfo)
‍** Creates a patrol unit and assigns it numPLocations random locations to patrol.
Definition: PatrolUnit.cpp:40
patrolUnit::addPathToCache
void addPathToCache(path *p)
Definition: PatrolUnit.cpp:125
patrolUnit
Definition: PatrolUnit.h:19
patrolUnit::nodesExpanded
uint64_t nodesExpanded
Definition: PatrolUnit.h:40
aStar
Definition: AStar.h:81
patrolUnit::GetGoal
unit * GetGoal()
Definition: PatrolUnit.cpp:118
patrolUnit::patrolUnit
patrolUnit(int x, int y)
Definition: PatrolUnit.cpp:15
patrolUnit::moves
std::vector< tDirection > moves
Definition: PatrolUnit.h:35
patrolUnit::LogFinalStats
void LogFinalStats(StatCollection *stats)
log any final one-time stats before a simulation is ended
Definition: PatrolUnit.cpp:189
patrolUnit::a
aStar a
Definition: PatrolUnit.h:37
tDirection
tDirection
Definition: Map2DEnvironment.h:77
StatCollection
The StatCollection class is for collecting stats across different parts of the simulation.
Definition: StatCollection.h:34
patrolUnit::updateLocation
void updateLocation(int _x, int _y, bool worked, SimulationInfo *)
Definition: PatrolUnit.h:28
patrolUnit::nodesTouched
uint64_t nodesTouched
Definition: PatrolUnit.h:41
PRAStar.h
patrolUnit::addPatrolLocation
void addPatrolLocation(unit *)
Definition: PatrolUnit.cpp:112
reservationProvider
Definition: ReservationProvider.h:33
patrolUnit::Locs
std::vector< unit * > Locs
Definition: PatrolUnit.h:36
path
A linked list of nodes which form a continuous path.
Definition: Path.h:20
AStar.h
patrolUnit::LogStats
void LogStats(StatCollection *stats)
log an stats that may have been computed during the last run
Definition: PatrolUnit.cpp:173
patrolUnit::currTarget
int currTarget
Definition: PatrolUnit.h:39
patrolUnit::GetName
virtual const char * GetName()
Definition: PatrolUnit.h:23
Unit.h
Unit
Definition: Unit.h:23