Early return in Clyde
This commit is contained in:
parent
ab9664d07f
commit
c10eb99336
1 changed files with 3 additions and 1 deletions
|
@ -25,10 +25,12 @@ Position Clyde::target(const GameState & gameState) const {
|
|||
|
||||
// Clyde always target its scatter target, unless pacman is further than 8 tiles away
|
||||
auto targetPosition = scatterTarget();
|
||||
if (state == State::Scatter)
|
||||
return targetPosition;
|
||||
|
||||
const auto pacManPosition = gameState.pacMan.positionInGrid();
|
||||
auto distanceFomPacMan = std::hypot(pos.x - pacManPosition.x, pos.y - pacManPosition.y);
|
||||
if (state == State::Chase && distanceFomPacMan > 8)
|
||||
if (distanceFomPacMan > 8)
|
||||
targetPosition = gridPositionToPosition(pacManPosition);
|
||||
|
||||
return targetPosition;
|
||||
|
|
Loading…
Reference in a new issue