des/ndctt2021 #1

Merged
des merged 10 commits from des/ndctt2021 into main 2021-10-20 08:00:22 +00:00
2 changed files with 7 additions and 3 deletions
Showing only changes of commit b9354e3dd1 - Show all commits

View file

@ -59,13 +59,16 @@ static Cell cellAtPosition(GridPosition point) {
return Cell(board[point.y][point.x]);
}
bool isWall(GridPosition point) {
return cellAtPosition(point) == Cell::wall;
}
bool isWalkableForPacMan(GridPosition point) {
return cellAtPosition(point) != Cell::wall && cellAtPosition(point) != Cell::pen;
return !isWall(point) && !isInPen(point);
}
bool isWalkableForGhost(GridPosition target_position, GridPosition current_position, bool isEyes) {
const Cell cell = cellAtPosition(target_position);
if (cell == Cell::wall)
if (isWall(target_position))
return false;
return isEyes || isInPen(current_position) || !isInPen(target_position);
}

View file

@ -8,6 +8,7 @@
namespace pacman {
bool isWall(GridPosition point);
bool isWalkableForPacMan(GridPosition point);
bool isWalkableForGhost(GridPosition target_position, GridPosition current_position, bool isEyes);
bool isInPen(GridPosition point);