pacman/exercises/25/pacman_ai/solution/optimal_direction_simple
2021-10-19 10:12:44 +02:00

13 lines
367 B
Text

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;
}