Update optimal_direction_simple
This commit is contained in:
parent
d31d678135
commit
d08825f98d
1 changed files with 12 additions and 0 deletions
|
@ -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;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue