pacman/exercises/25/pacman_ai/solution/optimal_direction_simple

14 lines
367 B
Text
Raw Normal View History

2021-10-19 08:12:44 +00:00
Direction PacManAI::optimalDirection(const std::array<Move, 4> & moves) {
double closestDistance = std::numeric_limits<double>::infinity();
Direction dir = Direction::NONE;
2021-10-19 08:11:25 +00:00
2021-10-19 08:12:44 +00:00
for (const auto & move : moves) {
if (move.distanceToTarget < closestDistance) {
closestDistance = move.distanceToTarget;
dir = move.direction;
}
}
return dir;
}