SimulatorGUI Class Reference

#include <SimulatorGUI.hpp>

Collaboration diagram for SimulatorGUI:

Public Member Functions

 SimulatorGUI (int gridX, int gridY, int skillz, int bots_per_player, int obstacles_)
 
bool do_timestep ()
 

Private Attributes

int initial_robots_per_combatant
 
int skill_points
 
int length
 
int width
 
int obstacles
 
RoboSim current_sim
 

Detailed Description

SimulatorGUI: Main GUI class.

ASCII art for now.

Definition at line 9 of file SimulatorGUI.hpp.

Constructor & Destructor Documentation

SimulatorGUI::SimulatorGUI ( int  gridX,
int  gridY,
int  skillz,
int  bots_per_player,
int  obstacles_ 
)
inline

Definition at line 23 of file SimulatorGUI.hpp.

Member Function Documentation

bool SimulatorGUI::do_timestep ( )

Definition at line 32 of file SimulatorGUI.cpp.

References robot_api::BLOCKED, current_sim, robot_api::DOWN, robot_api::FORT, RoboSim::getOccupantPlayer(), RoboSim::getWorldGrid(), robot_api::LEFT, robot_api::RIGHT, robot_api::SELF, robot_api::UP, and robot_api::WALL.

33 {
34  const auto& world = current_sim.getWorldGrid();
35  for(const auto& row : world)
36  {
37  for(const auto& cell : row)
38  switch(cell.contents)
39  {
40  case robot_api::BLOCKED: cout << 'X';
41  break;
42  case robot_api::SELF: cout << current_sim.getOccupantPlayer(cell);
43  break;
44  case robot_api::WALL: cout << '+';
45  break;
46  case robot_api::FORT:
47  switch(cell.fort_orientation)
48  {
49  case robot_api::UP: cout << '^';
50  break;
51  case robot_api::DOWN: cout << 'v';
52  break;
53  case robot_api::LEFT: cout << '<';
54  break;
55  case robot_api::RIGHT: cout << '>';
56  break;
57  }
58  break;
59  case robot_api::CAPSULE: cout << 'o';
60  break;
61  case robot_api::EMPTY: cout << '*';
62  break;
63  }
64  cout << endl;
65  }
66  cout << endl;
67 
68  int ret;
69  try
70  {
71  ret = current_sim.executeSingleTimeStep();
72  }
73  catch(RoboSimExecutionException e)
74  {
75  cout << "An error occurred during execution: " << e.msg << endl;
76  ret=-1;
77  }
78 
79  return ret==-1;
80 }
RoboSim current_sim
vector< vector< GridCell > > & getWorldGrid()
Definition: RoboSim.hpp:49
int getOccupantPlayer(const GridCell &cell) const
Definition: RoboSim.hpp:54

Here is the call graph for this function:

Member Data Documentation

RoboSim SimulatorGUI::current_sim
private

Definition at line 20 of file SimulatorGUI.hpp.

Referenced by do_timestep().

int SimulatorGUI::initial_robots_per_combatant
private

Definition at line 13 of file SimulatorGUI.hpp.

int SimulatorGUI::length
private

Definition at line 15 of file SimulatorGUI.hpp.

int SimulatorGUI::obstacles
private

Definition at line 17 of file SimulatorGUI.hpp.

int SimulatorGUI::skill_points
private

Definition at line 14 of file SimulatorGUI.hpp.

int SimulatorGUI::width
private

Definition at line 16 of file SimulatorGUI.hpp.


The documentation for this class was generated from the following files: