Question: add 3 functions to a robot #include #include #include bot.h using namespace std; const int MAX_ROBOT_NUM = 50; int NUM; // to remember number or

add 3 functions to a robot

add 3 functions to a robot #include #include #include "bot.h" using namespace

#include  #include  #include "bot.h" using namespace std; const int MAX_ROBOT_NUM = 50; int NUM; // to remember number or robots int ROWS, COLS; // map dimensions /* Initialization procedure, called when the game starts: */ void onStart(int num, int rows, int cols, double mpr, Area &area, ostream &log) { NUM = num; // save the number of robots and the map size ROWS = rows; COLS = cols; log  "Start!"  endl; } /* Deciding robot's next move */ Action onRobotAction(int id, Loc loc, Area &area, ostream &log) { int row = loc.r; // current row and column int col = loc.c; if (area.inspect(row, col) == DEBRIS) return COLLECT; else { // if not at a debris field, move randomly: switch(rand() % 4) { case 0: return LEFT; case 1: return RIGHT; case 2: return UP; default: return DOWN; } } } void onRobotMalfunction(int id, Loc loc, ostream &log) { log  "Robot "  id  " is damaged."  endl; } void onClockTick(int time, ostream &log) { if (time % 100 == 0) log  time  " "; }

std; const int MAX_ROBOT_NUM = 50; int NUM; // to remember number

or robots int ROWS, COLS; // map dimensions /* Initialization procedure, calledwhen the game starts: */ void onStart(int num, int rows, int cols,

Your task is to program the robots' logic so they do their work more efficiently. There is no harod cap on what you can do, the task is relatively open-ended. You can start with simple improvements, and progress towards more complex ones: 1. Start by tinkering with the provided functions, to see what can be done, and how the robot's behavior changes in response to your code modifications. (The program must be recompiled each time with make for changes to take an effect) 2. As you can see, robots' movement is pretty chaotic now. Make them move more direct towards ltni 3. Improve their logic so they are not waiting for other robots and distribute work efficiently 4. Make sure the robots work well for all possible map sizes, robot numbers, and debris density. 5. Identify how to make them work quicker, and implement that. 6. Further improvements include handling the problem of robots malfunctioning, when they occasionally break, and are shown red on the screen. It will be described later All robot logic is implemented in the file bot.cpp edit the other files. This is the only file you are going to submit. Don't Now, please open bot.cpp and inspect its code: Your task is to program the robots' logic so they do their work more efficiently. There is no harod cap on what you can do, the task is relatively open-ended. You can start with simple improvements, and progress towards more complex ones: 1. Start by tinkering with the provided functions, to see what can be done, and how the robot's behavior changes in response to your code modifications. (The program must be recompiled each time with make for changes to take an effect) 2. As you can see, robots' movement is pretty chaotic now. Make them move more direct towards ltni 3. Improve their logic so they are not waiting for other robots and distribute work efficiently 4. Make sure the robots work well for all possible map sizes, robot numbers, and debris density. 5. Identify how to make them work quicker, and implement that. 6. Further improvements include handling the problem of robots malfunctioning, when they occasionally break, and are shown red on the screen. It will be described later All robot logic is implemented in the file bot.cpp edit the other files. This is the only file you are going to submit. Don't Now, please open bot.cpp and inspect its code

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!