des/ndctt2021 #1

Merged
des merged 10 commits from des/ndctt2021 into main 2021-10-20 08:00:22 +00:00
Showing only changes of commit 30ae28cfc7 - Show all commits

View file

@ -33,8 +33,11 @@ bool PacManAI::isValidMove(const Move & move) {
// This function is not yet implemented. // This function is not yet implemented.
// You will implement it as part of module 25. // You will implement it as part of module 25.
Direction PacManAI::optimalDirection(const std::array<Move, 4> &) { Direction PacManAI::optimalDirection(const std::array<Move, 4> & moves) {
return Direction::NONE; auto bestMove = std::min_element(moves.begin(), moves.end(), [](Move a, Move b) {
return a.distanceToTarget < b.distanceToTarget;
});
return bestMove->direction;
} }
void PacManAI::update(const PacMan & pacMan, const Pellets & pellets) { void PacManAI::update(const PacMan & pacMan, const Pellets & pellets) {