Tweak text

This commit is contained in:
Patricia Aas 2021-10-05 15:30:50 +02:00
parent df118c1c0f
commit 1188d26e9a
2 changed files with 15 additions and 4 deletions

View File

@ -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"_

View File

@ -2,7 +2,7 @@
#include <PacManAI.hpp>
#include <limits>
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, std::vector<GridPosition>, 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<std::array<PacManAI::Move, 4>, Direction>;
auto makeMove = [](double distance, Direction d) {