HOG2
RandomUnits.h
Go to the documentation of this file.
1 /*
2  * RandomUnits.h
3  * hog2
4  *
5  * Created by Nathan Sturtevant on 4/23/07.
6  * Copyright 2007 Nathan Sturtevant, University of Alberta. All rights reserved.
7  *
8  */
9 
10 
11 #include "Unit.h"
12 #include "MapUnit.h"
13 #include "Map2DEnvironment.h"
14 
15 #ifndef RANDOMUNITS_H
16 #define RANDOMUNITS_H
17 
21 class RandomUnit : public MapUnit {
22 public:
23  RandomUnit(int _x, int _y)
24  :MapUnit(_x, _y) { lastIndex = 0; }
25  virtual const char *GetName() { return "randomUnit"; }
26 
27 // virtual bool MakeMove(environment *, OccupancyInterface<state,action> *, MapSimulationInfo *, tDirection& a) = 0;
30 private:
31  int lastIndex;
32 };
33 
37 class TeleportUnit : public MapUnit {
38 public:
39  TeleportUnit(int x, int y, int _stayTime)
40  :MapUnit(x, y), stayTime(_stayTime), timer(_stayTime) { }
41  const char *GetName() { return "TeleportUnit"; }
42 
44 private:
45  int stayTime;
46  int timer;
47 };
48 
52 class RandomerUnit : public MapUnit {
53 public:
54  RandomerUnit(int _x, int _y)
55  :MapUnit(_x, _y) { }
56  const char *GetName() { return "RandomerUnit"; }
57 
59 };
60 
64 class BilliardBallUnit : public MapUnit {
65 public:
66  BilliardBallUnit(int _x, int _y, int _coolOffPeriod, double _probDirChange)
67  :MapUnit(_x, _y) {
69  collisionStatus = 0;
70  coolOffPeriod = _coolOffPeriod;
71  probDirChange = _probDirChange;
72  }
73  virtual const char *GetName() { return "BilliardBallUnit"; }
74 
77 private:
78  int lastIndex;
80  double probDirChange;
82 };
83 
84 #endif
TeleportUnit::MakeMove
bool MakeMove(MapEnvironment *, OccupancyInterface< xyLoc, tDirection > *, MapSimulationInfo *, tDirection &dir)
make teleport move.
Definition: RandomUnits.cpp:101
RandomUnit::MakeMove
virtual bool MakeMove(environment *theEnv, OccupancyInterface< state, action > *, SimulationInfo< state, action, environment > *, action &a)
Definition: RandomUnit.h:22
SimulationInfo
Definition: SimulationInfo.h:13
RandomUnit
A unit that moves in random directions changing direction randomly.
Definition: RandomUnit.h:16
BilliardBallUnit::MakeMove
bool MakeMove(MapEnvironment *, OccupancyInterface< xyLoc, tDirection > *, MapSimulationInfo *, tDirection &dir)
Make a move.
Definition: RandomUnits.cpp:62
RandomUnit::lastIndex
int lastIndex
Definition: RandomUnits.h:31
RandomerUnit::MakeMove
bool MakeMove(MapEnvironment *, OccupancyInterface< xyLoc, tDirection > *, MapSimulationInfo *, tDirection &dir)
Make a random move.
Definition: RandomUnits.cpp:50
BilliardBallUnit::coolOffPeriod
int coolOffPeriod
Definition: RandomUnits.h:81
TeleportUnit::timer
int timer
Definition: RandomUnits.h:46
RandomUnit::UpdateLocation
virtual void UpdateLocation(environment *, state &newloc, bool success, SimulationInfo< state, action, environment > *)
Definition: RandomUnit.h:29
BilliardBallUnit::lastIndex
int lastIndex
Definition: RandomUnits.h:78
xyLoc
Definition: Map2DEnvironment.h:37
TeleportUnit::GetName
const char * GetName()
Definition: RandomUnits.h:41
TeleportUnit::stayTime
int stayTime
Definition: RandomUnits.h:45
BilliardBallUnit::UpdateLocation
void UpdateLocation(MapEnvironment *, xyLoc &, bool, MapSimulationInfo *)
Set location after last move.
Definition: RandomUnits.cpp:74
Map2DEnvironment.h
kStayIndex
const int kStayIndex
Definition: Map2DEnvironment.h:105
BilliardBallUnit::GetName
virtual const char * GetName()
Definition: RandomUnits.h:73
MapEnvironment
Definition: Map2DEnvironment.h:133
RandomerUnit
A unit that moves in random directions for every step.
Definition: RandomUnits.h:52
BilliardBallUnit::collisionStatus
int collisionStatus
Definition: RandomUnits.h:79
RandomerUnit::RandomerUnit
RandomerUnit(int _x, int _y)
Definition: RandomUnits.h:54
TeleportUnit
A unit which randomly teleports around the world.
Definition: RandomUnits.h:37
RandomUnit::RandomUnit
RandomUnit(int _x, int _y)
Definition: RandomUnits.h:23
tDirection
tDirection
Definition: Map2DEnvironment.h:77
RandomUnit::GetName
virtual const char * GetName()
Definition: RandomUnits.h:25
TeleportUnit::TeleportUnit
TeleportUnit(int x, int y, int _stayTime)
Definition: RandomUnits.h:39
RandomerUnit::GetName
const char * GetName()
Definition: RandomUnits.h:56
MapUnit
A simple map-based unit.
Definition: MapUnit.h:22
BilliardBallUnit::probDirChange
double probDirChange
Definition: RandomUnits.h:80
BilliardBallUnit::BilliardBallUnit
BilliardBallUnit(int _x, int _y, int _coolOffPeriod, double _probDirChange)
Definition: RandomUnits.h:66
BilliardBallUnit
A configurable billiard ball unit.
Definition: RandomUnits.h:64
MapUnit.h
Unit.h
OccupancyInterface< xyLoc, tDirection >