Browse Source

Update optimal_direction_simple

main
Patricia Aas 10 months ago committed by GitHub
parent
commit
d08825f98d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      exercises/25/pacman_ai/solution/optimal_direction_simple

12
exercises/25/pacman_ai/solution/optimal_direction_simple

@ -1 +1,13 @@
Direction PacManAI::optimalDirection(const std::array<Move, 4> & moves) {
double closestDistance = std::numeric_limits<double>::infinity();
Direction dir = Direction::NONE;
for (const auto & move : moves) {
if (move.distanceToTarget < closestDistance) {
closestDistance = move.distanceToTarget;
dir = move.direction;
}
}
return dir;
}

Loading…
Cancel
Save