Remove part of the AI implementation

This commit is contained in:
Corentin Jabot 2021-10-05 15:46:06 +02:00
parent 4aff1fa43e
commit a835774f5a
2 changed files with 12 additions and 23 deletions

View file

@ -14,38 +14,24 @@ Direction PacManAI::suggestedDirection() const {
return direction;
}
// This function is not yet implemented.
// You will implement it as part of module 25.
GridPosition PacManAI::pelletClosestToPacman(GridPosition pacmanGridPosition,
std::vector<GridPosition> & pellets) {
auto pelletSort = [&pacmanGridPosition](GridPosition pelletA, GridPosition pelletB) {
double distanceA = positionDistance(pacmanGridPosition, pelletA);
double distanceB = positionDistance(pacmanGridPosition, pelletB);
return distanceA < distanceB;
};
std::sort(pellets.begin(), pellets.end(), pelletSort);
return pellets[0];
return {0, 0};
}
// This function is not yet implemented.
// You will implement it as part of module 25.
bool PacManAI::isValidMove(const Move & move) {
const bool isOpposite = (move.direction == oppositeDirection(direction));
if (isOpposite) {
return false;
}
const bool canWalk = isWalkableForPacMan(move.position);
if (!canWalk) {
return false;
}
return true;
}
// This function is not yet implemented.
// You will implement it as part of module 25.
Direction PacManAI::optimalDirection(const std::array<Move, 4> & moves) {
const auto optimalMove = std::min_element(moves.begin(), moves.end(), [](const auto & a, const auto & b) {
return a.distanceToTarget < b.distanceToTarget;
});
const auto & move = *optimalMove;
return move.direction;
return Direction::NONE;
}
void PacManAI::update(const PacMan & pacMan, const Pellets & pellets) {

View file

@ -5,4 +5,7 @@ file(GLOB_RECURSE sources CONFIGURE_DEPENDS "*.cpp")
add_executable(pacman_tests ${sources})
target_link_libraries(pacman_tests Catch2::Catch2 libpacman)
add_test(NAME pacman_tests COMMAND pacman_tests)
# This setup the tests on CI. We disable the AI tests
# because you will have to implement them.
add_test(NAME pacman_tests COMMAND pacman_tests "~[AI]")