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
|
## Exercise
|
||||||
|
|
||||||
1. Implement [PacManAI::pelletClosestToPacman](../../../lib/PacManAI.cpp) and test your implementation with the test
|
### Part 1
|
||||||
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
|
Implement [PacManAI::pelletClosestToPacman](../../../lib/PacManAI.cpp) and test your implementation with the test
|
||||||
to sort the vector of pellets by the distance they have to PacMan, and then return the first one.
|
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
|
```cpp
|
||||||
GridPosition PacManAI::pelletClosestToPacman(GridPosition pacmanGridPosition,
|
GridPosition PacManAI::pelletClosestToPacman(GridPosition pacmanGridPosition,
|
||||||
|
@ -31,20 +33,22 @@ GridPosition PacManAI::pelletClosestToPacman(GridPosition pacmanGridPosition,
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
<summary>Hint 1</summary>
|
<summary>Hint 1</summary>
|
||||||
|
|
||||||
Use the `positionDistance` function to find the distance to PacMan.
|
Use the `positionDistance` function to find the distance to PacMan.
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
<details>
|
<details>
|
||||||
<summary>Hint 2</summary>
|
<summary>Hint 2</summary>
|
||||||
|
|
||||||
Use the [std::sort](https://en.cppreference.com/w/cpp/algorithm/sort) function to sort the vector.
|
Use the [std::sort](https://en.cppreference.com/w/cpp/algorithm/sort) function to sort the vector.
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
2. Implement [PacManAI::isValidMove](../../../lib/PacManAI.cpp) and test your implementation with the test
|
### Part 2
|
||||||
in [testPacmanAI.cpp](../../../test/testPacmanAI.cpp) called _"Is valid move"_
|
|
||||||
|
Implement [PacManAI::isValidMove](../../../lib/PacManAI.cpp) and test your implementation with the test
|
||||||
|
in [testPacmanAI.cpp](../../../test/testPacmanAI.cpp) called _"Is valid move"_
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
bool PacManAI::isValidMove(const Move & move) {
|
bool PacManAI::isValidMove(const Move & move) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -53,13 +57,14 @@ bool PacManAI::isValidMove(const Move & move) {
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
<summary>Hint</summary>
|
<summary>Hint</summary>
|
||||||
|
|
||||||
</details>
|
|
||||||
|
|
||||||
|
|
||||||
3. Implement [PacManAI::optimalDirection](../../../lib/PacManAI.cpp) and test your implementation with the test
|
</details>
|
||||||
in [testPacmanAI.cpp](../../../test/testPacmanAI.cpp) called _"Is optimal direction"_
|
|
||||||
|
### 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
|
```cpp
|
||||||
Direction PacManAI::optimalDirection(const std::array<Move, 4> & moves) {
|
Direction PacManAI::optimalDirection(const std::array<Move, 4> & moves) {
|
||||||
return Direction::NONE;
|
return Direction::NONE;
|
||||||
|
|
Loading…
Reference in a new issue