Change structure
This commit is contained in:
parent
c9b8277d8f
commit
9934add502
|
@ -16,11 +16,13 @@ You only need to worry about the grid itself and any ghosts on the North/South/E
|
|||
|
||||
## Exercise
|
||||
|
||||
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"_
|
||||
### Part 1
|
||||
|
||||
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.
|
||||
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"_
|
||||
|
||||
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.
|
||||
|
||||
```cpp
|
||||
GridPosition PacManAI::pelletClosestToPacman(GridPosition pacmanGridPosition,
|
||||
|
@ -42,8 +44,10 @@ Use the [std::sort](https://en.cppreference.com/w/cpp/algorithm/sort) function t
|
|||
|
||||
</details>
|
||||
|
||||
2. Implement [PacManAI::isValidMove](../../../lib/PacManAI.cpp) and test your implementation with the test
|
||||
in [testPacmanAI.cpp](../../../test/testPacmanAI.cpp) called _"Is valid move"_
|
||||
### 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"_
|
||||
|
||||
```cpp
|
||||
bool PacManAI::isValidMove(const Move & move) {
|
||||
|
@ -56,9 +60,10 @@ bool PacManAI::isValidMove(const Move & move) {
|
|||
|
||||
</details>
|
||||
|
||||
### Part 3
|
||||
|
||||
3. Implement [PacManAI::optimalDirection](../../../lib/PacManAI.cpp) and test your implementation with the test
|
||||
in [testPacmanAI.cpp](../../../test/testPacmanAI.cpp) called _"Is optimal direction"_
|
||||
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<Move, 4> & moves) {
|
||||
|
|
Loading…
Reference in a new issue