From 1188d26e9a007681fc6c713a41726cd9929fc881 Mon Sep 17 00:00:00 2001 From: Patricia Aas Date: Tue, 5 Oct 2021 15:30:50 +0200 Subject: [PATCH] Tweak text --- exercises/25/pacman_ai/README.md | 15 +++++++++++++-- test/testPacmanAI.cpp | 4 ++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/exercises/25/pacman_ai/README.md b/exercises/25/pacman_ai/README.md index 5368eb0..01b3139 100644 --- a/exercises/25/pacman_ai/README.md +++ b/exercises/25/pacman_ai/README.md @@ -2,9 +2,11 @@ # Exercise: PacMan AI -The exercise above is fixed based on the layout of the board and is hard to make generic. +Let's implement a naive AI for PacMan. -Let's implement a naive AI for PacMan. At each intersection, check if there is a ghost directly inline with that path. +## Background: PacMan Moves + +At each intersection, check if there is a ghost directly inline with that path. If the path is free of ghosts, you are allowed to turn there. And if PacMan is moving in a direction, and a ghost enters his path, then pacman will reverse. @@ -12,3 +14,12 @@ For example if pacman is at an intersection and can go either right or up, and t then pacman will go up. Then while pacman is going up, a ghost enters that path, pacman will go back. You only need to worry about the grid itself and any ghosts on the North/South/East/West axis of PacMan. + +## Exercise + +1. Implement `PacManAI::pelletClosestToPacman` and test your implementation with the test + in [testPacmanAI.cpp](../../../test/testPacmanAI.cpp) called _"Find pellet closest to pacman"_ +2. Implement `PacManAI::isValidMove` and test your implementation with the test + in [testPacmanAI.cpp](../../../test/testPacmanAI.cpp) called _"Is valid move"_ +3. Implement `PacManAI::optimalDirection` and test your implementation with the test + in [testPacmanAI.cpp](../../../test/testPacmanAI.cpp) called _"Is optimal direction"_ diff --git a/test/testPacmanAI.cpp b/test/testPacmanAI.cpp index 1033027..0c13b36 100644 --- a/test/testPacmanAI.cpp +++ b/test/testPacmanAI.cpp @@ -2,7 +2,7 @@ #include #include -TEST_CASE("find pellet closest to pacman", "[AI]") { +TEST_CASE("Find pellet closest to pacman", "[AI]") { using namespace pacman; PacManAI AI; using TestData = std::tuple, GridPosition>; @@ -30,7 +30,7 @@ TEST_CASE("Is valid move", "[AI]") { CHECK(AI.isValidMove(std::get<0>(data)) == std::get<1>(data)); } -TEST_CASE("is optimal direction", "[AI]") { +TEST_CASE("Is optimal direction", "[AI]") { using namespace pacman; using TestData = std::tuple, Direction>; auto makeMove = [](double distance, Direction d) {