Okay, thanks for clarifying this. I'm on the right track. Just a few more tasks I believe.
Next task I tried to do, but can't think of how, is the step function. I think knowing this would help me think of ideas for other functions:
I'm on bool Robot::step().
bool Robot::step()
{
// If the robot has no energy left, return false
// if (FULL_ENERGY == 0)
// return false;
// Otherwise,
else
{
// Randomly change direction with probability 1/3
if (rand() % 3 == 0) // 1/3 probability to pick a direction
m_dir = Dir(rand() % 4); // pick a random direction
// Attempt to move one step in the direction we're currently facing.
// (E.g., to move north, decrement the row coordinate.) If we can't
// move in that direction, don't move.
if (r < 0 || r >= NROWS || c < 0 || c >= NCOLS)
{
cout << "***** Robot created with invalid coordinates (" << r << ","
<< c << ")!" << endl;
exit(1);
}
switch (m_dir)
{
case NORTH:
// TODO: Move one step north, if possible.
r--;
break;
case SOUTH:
r++;
case WEST:
c++;
case EAST:
c--;
The stuff I did was in blue. Can you tell me if I'm on the right track?
EDIT: Compiling said that r and c are undeclared! What must I do to use them?