robot_api.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <functional>
4 #include <cstdint>
5 #include <list>
6 #include <string>
7 #include <vector>
8 
9 class Robot;
10 class RoboSim;
11 
12 namespace robot_api
13 {
14  using std::uint8_t;
15  using std::string;
16  using std::list;
17  using std::vector;
18 
20  struct Robot_Specs
21  {
23  int attack;
24 
26  int defense;
27 
29  int power;
30 
32  int charge;
33  };
34 
39  struct Robot_Status
40  {
42  int power;
43 
45  int charge;
46 
48  int health;
49 
52 
61  list<int> capsules;
62  };
63 
66 
68  enum Direction { UP, DOWN, LEFT, RIGHT };
69 
70  class RobotUtility;
71  class RobotData;
72 
74  struct GridCell
75  {
77  int x_coord;
78 
80  int y_coord;
81 
84 
87 
90 
91  private:
92  friend class ::RoboSim;
93  friend class RobotUtility;
94 
95  bool has_private_members = false;
98  };
99 
101  enum BuildStatus { NOTHING, /*WALL, FORT, CAPSULE,*/ ROBOT };
102 
103  class RobotData
104  {
105  friend class ::RoboSim;
106 
111  int player;
112 
113  //Build information
117 
118  //Buffered radio messages
119  vector<vector<uint8_t>> buffered_radio;
120  };
121 
123  enum AttackType { MELEE, RANGED, /*CAPSULE*/ };
124 
128  {
131 
134 
136  int damage;
137 
138  };
139 
142 
147  {
148  public:
155  static GridCell* findNearestAlly(GridCell& origin, std::vector<std::vector<GridCell> >& grid);
156 
170  static std::list<GridCell*> findShortestPath(GridCell& origin, const GridCell& target, std::vector<std::vector<GridCell> >& grid);
171 
172  private:
173  static std::list<GridCell*> findShortestPathInternal(GridCell& origin, const std::function<bool(const GridCell&)>& isTarget, const std::function<bool(const GridCell&)>& isPassable, std::vector<std::vector<GridCell> >& grid);
174  };
175 
177  {
178  string msg;
179 
180  RoboSimExecutionException(const string& msg_) : msg(msg_) {}
181 
182  RoboSimExecutionException(const string& msg_, int player)
183  {
184  msg = string("Player ")+std::to_string(player)+" "+msg_;
185  }
186 
187  RoboSimExecutionException(const string& msg_, int player, const GridCell& cell)
188  {
189  msg = string("Player ")+std::to_string(player)+" "+msg_+" with robot at coordinates ["+std::to_string(cell.x_coord)+"]["+std::to_string(cell.y_coord)+"]";
190  }
191 
192  RoboSimExecutionException(const string& msg_, int player, const GridCell& cell, const GridCell& cell2)
193  {
194  msg = string("Player ")+std::to_string(player)+" "+msg_+" with robot at coordinates ["+std::to_string(cell.x_coord)+"]["+std::to_string(cell.y_coord)+"], coordinates of invalid cell are ["+std::to_string(cell2.x_coord)+"]["+std::to_string(cell2.y_coord)+"]";
195  }
196 
197  RoboSimExecutionException(const string& msg_, int player, int x1, int y1, int x2, int y2)
198  {
199  msg = string("Player ")+std::to_string(player)+" "+msg_+" with robot at coordinates ["+std::to_string(x1)+"]["+std::to_string(y1)+"], coordinates of invalid cell are ["+std::to_string(x2)+"]["+std::to_string(y2)+"]";
200  }
201  };
202 }
RobotData * occupant_data
Definition: robot_api.hpp:96
RoboSimExecutionException(const string &msg_, int player)
Definition: robot_api.hpp:182
Definition: Robot.hpp:19
RoboSimExecutionException(const string &msg_, int player, int x1, int y1, int x2, int y2)
Definition: robot_api.hpp:197
vector< vector< uint8_t > > buffered_radio
Definition: robot_api.hpp:119
RoboSimExecutionException(const string &msg_)
Definition: robot_api.hpp:180
RoboSimExecutionException(const string &msg_, int player, const GridCell &cell, const GridCell &cell2)
Definition: robot_api.hpp:192
Direction fort_orientation
Definition: robot_api.hpp:86
GridObject contents
Definition: robot_api.hpp:83
Robot_Status status
Definition: robot_api.hpp:109
BuildStatus whatBuilding
Definition: robot_api.hpp:114
RoboSimExecutionException(const string &msg_, int player, const GridCell &cell)
Definition: robot_api.hpp:187
GridCell * assoc_cell
Definition: robot_api.hpp:107
static std::list< GridCell * > findShortestPathInternal(GridCell &origin, const std::function< bool(const GridCell &)> &isTarget, const std::function< bool(const GridCell &)> &isPassable, std::vector< std::vector< GridCell > > &grid)
Definition: robot_api.cpp:50
static std::list< GridCell * > findShortestPath(GridCell &origin, const GridCell &target, std::vector< std::vector< GridCell > > &grid)
Definition: robot_api.cpp:29
static GridCell * findNearestAlly(GridCell &origin, std::vector< std::vector< GridCell > > &grid)
Definition: robot_api.cpp:19
GridCell * invested_assoc_cell
Definition: robot_api.hpp:116