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