#include <GhostNavigator.h>
|
| static bool | sameDirection (Moves a, Moves b) |
| | Compares Move a and b and returns whether they are in the same direction.
|
| static bool | isAtIntersection (const World &world, const GhostModel &ghost) |
| | Checks whether the provided Ghost currently is at an intersection.
|
| static std::vector< Moves > | getPossibleMoves (const World &world, const GhostModel &ghost) |
| | Checks all possible directions the Ghost can go at its current position and returns them.
|
| static std::list< Moves > | findPathToSpawn (const World &world, const GhostModel &ghost) |
| | Determines the fastest path back to the Ghost enclosure starting from the Ghost position using BFS pathfinding.
|
| static Moves | maximizeDistance (const World &world, const GhostModel &ghost) |
| | Will return the best Move from all possible moves to maximize the Manhattan distance between the Ghost and Pacman.
|
| static Moves | minimizeDistance (const World &world, const GhostModel &ghost, int targetX, int targetY) |
| | Will return the best Move from all possible moves to minimize the Manhattan distance between the Ghost and the provided target.
|
◆ findPathToSpawn()
| std::list< Moves > GhostNavigator::findPathToSpawn |
( |
const World & | world, |
|
|
const GhostModel & | ghost ) |
|
staticnodiscard |
Determines the fastest path back to the Ghost enclosure starting from the Ghost position using BFS pathfinding.
- Parameters
-
| world | World |
| ghost | Ghost in need of a path |
- Returns
- An ordered list of moves to be strictly followed
A breadth-first search is started from the ghost's current grid position and expands outward until the spawn position is reached. During the search, the direction taken to enter each cell is recorded.
Once the spawn tile is found, the path is reconstructed by walking backwards from the spawn to the start using the recorded directions, producing a sequence of concrete Moves (LEFT, RIGHT, UP, DOWN).
The returned list represents the shortest possible path in grid steps. If multiple shortest paths exist, the chosen one depends on exploration order.
◆ getPossibleMoves()
| std::vector< Moves > GhostNavigator::getPossibleMoves |
( |
const World & | world, |
|
|
const GhostModel & | ghost ) |
|
staticnodiscard |
Checks all possible directions the Ghost can go at its current position and returns them.
- Parameters
-
| world | World |
| ghost | Ghost to be checked |
- Returns
- A vector of moves
◆ isAtIntersection()
| bool GhostNavigator::isAtIntersection |
( |
const World & | world, |
|
|
const GhostModel & | ghost ) |
|
staticnodiscard |
Checks whether the provided Ghost currently is at an intersection.
- Parameters
-
| world | World |
| ghost | Ghost to be checked |
- Returns
- Whether ghost is at intersection
◆ maximizeDistance()
Will return the best Move from all possible moves to maximize the Manhattan distance between the Ghost and Pacman.
- Parameters
-
| world | World |
| ghost | Ghosts to be checked |
- Returns
- Best move
◆ minimizeDistance()
| Moves GhostNavigator::minimizeDistance |
( |
const World & | world, |
|
|
const GhostModel & | ghost, |
|
|
int | targetX, |
|
|
int | targetY ) |
|
staticnodiscard |
Will return the best Move from all possible moves to minimize the Manhattan distance between the Ghost and the provided target.
- Parameters
-
| world | World |
| ghost | Ghosts to be checked |
| targetX | X grid target coordinate |
| targetY | Y grid target coordinate |
- Returns
- Best move
◆ sameDirection()
| bool GhostNavigator::sameDirection |
( |
Moves | a, |
|
|
Moves | b ) |
|
staticnodiscard |
Compares Move a and b and returns whether they are in the same direction.
- Parameters
-
- Returns
- Whether they are the same direction
The documentation for this class was generated from the following files: