des/ndctt2021 #1
2 changed files with 7 additions and 3 deletions
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue