From 653a0ff5bf15616920b153f363f3e6a485819bb4 Mon Sep 17 00:00:00 2001 From: Patricia Aas Date: Tue, 19 Oct 2021 09:58:17 +0200 Subject: [PATCH] Update README.md --- exercises/25/pacman_ai/README.md | 102 +++++++++++++++---------------- 1 file changed, 50 insertions(+), 52 deletions(-) diff --git a/exercises/25/pacman_ai/README.md b/exercises/25/pacman_ai/README.md index 9c87b54..855faf0 100644 --- a/exercises/25/pacman_ai/README.md +++ b/exercises/25/pacman_ai/README.md @@ -16,7 +16,56 @@ You only need to worry about the grid itself and any ghosts on the North/South/E ## Exercise -### Part 1 +### isValidMove + +Implement [PacManAI::isValidMove](../../../lib/PacManAI.cpp) and test your implementation with the test +in [testPacmanAI.cpp](../../../test/testPacmanAI.cpp) called _"Is valid move"_ + +To run the tests through CMake change the last line in [test/CMakeLists.txt](../../../test/CMakeLists.txt) to: + +``` +add_test(NAME pacman_tests COMMAND pacman_tests) +``` + +```cpp +bool PacManAI::isValidMove(const Move & move) { + return false; +} +``` + +
+ Hint 1 + +Use [isWalkableForPacMan](../../../lib/Board.cpp) to make sure PacMan is not walking in ways that are not legal + +
+ +
+ Hint 2 + +Use [oppositeDirection](../../../lib/include/Direction.hpp) to make sure PacMan doesn't get stuck toggeling back and forth + +
+ +### optimalDirection + +Implement [PacManAI::optimalDirection](../../../lib/PacManAI.cpp) and test your implementation with the test +in [testPacmanAI.cpp](../../../test/testPacmanAI.cpp) called _"Is optimal direction"_ + +```cpp +Direction PacManAI::optimalDirection(const std::array & moves) { + return Direction::NONE; +} +``` + +
+ Hint + + You can use [std::min_element](https://en.cppreference.com/w/cpp/algorithm/min_element) to find the closest pellet + +
+ +### pelletClosestToPacman Implement [PacManAI::pelletClosestToPacman](../../../lib/PacManAI.cpp) and test your implementation with the test in [testPacmanAI.cpp](../../../test/testPacmanAI.cpp) called _"Find pellet closest to PacMan"_ @@ -52,54 +101,3 @@ Use the [std::sort](https://en.cppreference.com/w/cpp/algorithm/sort) function t and return true if the first parameter is closer from PacMan than the second. - -### Part 2 - -Implement [PacManAI::isValidMove](../../../lib/PacManAI.cpp) and test your implementation with the test -in [testPacmanAI.cpp](../../../test/testPacmanAI.cpp) called _"Is valid move"_ - -To run the tests through CMake change the last line in [test/CMakeLists.txt](../../../test/CMakeLists.txt) to: - -``` -add_test(NAME pacman_tests COMMAND pacman_tests) -``` - -```cpp -bool PacManAI::isValidMove(const Move & move) { - return false; -} -``` - -
- Hint 1 - -Use [isWalkableForPacMan](../../../lib/Board.cpp) to make sure PacMan is not walking in ways that are not legal - -
- -
- Hint 2 - -Use [oppositeDirection](../../../lib/include/Direction.hpp) to make sure PacMan doesn't get stuck toggeling back and forth - -
- -### Part 3 - -Implement [PacManAI::optimalDirection](../../../lib/PacManAI.cpp) and test your implementation with the test -in [testPacmanAI.cpp](../../../test/testPacmanAI.cpp) called _"Is optimal direction"_ - -```cpp -Direction PacManAI::optimalDirection(const std::array & moves) { - return Direction::NONE; -} -``` - -
- Hint - - You can use [std::min_element](https://en.cppreference.com/w/cpp/algorithm/min_element) to find the closest pellet - -
- -