From 5fa007f267c5656adb3689fbf47a4f34f4d5879f Mon Sep 17 00:00:00 2001 From: Patricia Aas Date: Tue, 5 Oct 2021 16:00:40 +0200 Subject: [PATCH] Fill in exercise PacMan AI --- exercises/25/pacman_ai/README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/exercises/25/pacman_ai/README.md b/exercises/25/pacman_ai/README.md index d70b1a1..eb320b8 100644 --- a/exercises/25/pacman_ai/README.md +++ b/exercises/25/pacman_ai/README.md @@ -19,7 +19,11 @@ You only need to worry about the grid itself and any ghosts on the North/South/E 1. 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"_ -*Hint*: +The function should return the position of the pellet that is "closest" to PacMan. One implementation could be +to sort the vector of pellets by the distance they have to PacMan, and then return the first one. + +*Hint 1*: use the `positionDistance` function to find the distance to PacMan +*Hint 2*: use the [std::sort](https://en.cppreference.com/w/cpp/algorithm/sort) function to sort the vector ```cpp GridPosition PacManAI::pelletClosestToPacman(GridPosition pacmanGridPosition,