From b97e1c6f2cfa090510e4215f83cf7ad3ef91ec8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dag-Erling=20Sm=C3=B8rgrav?= Date: Tue, 19 Oct 2021 09:48:30 +0200 Subject: [PATCH] Ex 25: Implement isValidMove(). --- lib/PacManAI.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/PacManAI.cpp b/lib/PacManAI.cpp index 9168ab7..523bdff 100644 --- a/lib/PacManAI.cpp +++ b/lib/PacManAI.cpp @@ -27,8 +27,8 @@ GridPosition PacManAI::pelletClosestToPacman(GridPosition position, // This function is not yet implemented. // You will implement it as part of module 25. -bool PacManAI::isValidMove(const Move &) { - return false; +bool PacManAI::isValidMove(const Move & move) { + return isWalkableForPacMan(move.position) && move.direction != oppositeDirection(direction); } // This function is not yet implemented.