13 lines
367 B
Text
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;
|
|
}
|