Create is_valid_move_simple
This commit is contained in:
parent
653a0ff5bf
commit
c981f127ed
1 changed files with 13 additions and 0 deletions
13
exercises/25/pacman_ai/solution/is_valid_move_simple
Normal file
13
exercises/25/pacman_ai/solution/is_valid_move_simple
Normal file
|
@ -0,0 +1,13 @@
|
|||
bool PacManAI::isValidMove(const Move & move) {
|
||||
const bool isOpposite = (move.direction == oppositeDirection(direction));
|
||||
if (isOpposite) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const bool canWalk = isWalkableForPacMan(move.position);
|
||||
if (!canWalk) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
Loading…
Reference in a new issue