Update optimal_direction_simple

This commit is contained in:
Patricia Aas 2021-10-19 10:12:44 +02:00 committed by GitHub
parent d31d678135
commit d08825f98d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

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