1.
Quote:
|
You might want to make this higher, otherwise your if test will ignore all robots that are at full energy.
|
Well, I guess we ignore the robots with fewer than the current minimum (that's why we have the int leastEnergy). We want to 'keep setting' the lowest energy (Search for the robot with the lowest energry) while we're in the loop. Therefore, we started with the max, just so we have something to compare.
2. This is the best I could think of ..
// TODO: indicate each robot's position
// for each robot in the valley,
// set the appropriate element of the grid to the first character
// of the robot's name.
for (int b = 0; b < m_nrobots; b++)
{
grid[r][c] = m_robots[b] -> row() -> col() -> name()[0];
} 4. I think this logic makes sense, but it's doesn't match your idea:
for (Each robot)
{
if (robot didn't step)
return false;
}
return true;
which transate in C++ to this:
for (int p = 0; p < m_nrobots; p++)
{
if ( !(m_robot[p] -> step() ) )
return false;
}
return true;
} We go through each robot, and it that robot didn't step, then continue
in the loop. If we don't find any that didn't step, then return true.