int GameState::countCollisions() { int numberDestroyed = 0; unsigned int i = 0; while (i < robots.size()) { bool collision = (countRobotsAt(*robots[i]) > 1); if (collision && !robots[i]->isJunk()) { Junk* j = new Junk(*robots[i]); delete robots[i]; robots[i] = j; this->numberOfRobots--; numberDestroyed++; } i++; } return numberDestroyed; }
int GameState::countCollisions() { int numberDestroyed = 0; unsigned int i = 0; while (i < robots.size()) { bool hitJunk = robots[i]->isJunk(); bool collision = (countRobotsAt(*robots[i]) > 1); if (collision && !hitJunk) { Robot* temp = robots[i]; robots[i] = new Junk((*robots[i])); delete temp; numberDestroyed++; } else { i++; } } return numberDestroyed; }
/* * Free of robots and junk only */ bool GameState::isEmpty(const Unit& unit) const { return countRobotsAt(unit) == 0; }
/* * Free of robots and junk only */ bool GameState::isEmpty(const Unit& unit) const { return (countRobotsAt(unit) == 0);// && !(robot.isJunk()); }