From a835774f5a1f44664a89a0f94570b69a1d8c5962 Mon Sep 17 00:00:00 2001 From: Corentin Jabot Date: Tue, 5 Oct 2021 15:46:06 +0200 Subject: [PATCH] Remove part of the AI implementation --- lib/PacManAI.cpp | 30 ++++++++---------------------- test/CMakeLists.txt | 5 ++++- 2 files changed, 12 insertions(+), 23 deletions(-) diff --git a/lib/PacManAI.cpp b/lib/PacManAI.cpp index 1e4d3ad..41fd954 100644 --- a/lib/PacManAI.cpp +++ b/lib/PacManAI.cpp @@ -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 & 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 & 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) { diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 9815763..ad6067e 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -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]")