From c5e5646b7785e1b5d1c46efd5e93a6f95d5bad9f Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Wed, 25 Nov 2015 00:07:56 +0100 Subject: Implement PacMan predator avoidance --- src/ch/epfl/maze/physical/pacman/Ghost.java | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) (limited to 'src/ch/epfl/maze/physical/pacman/Ghost.java') diff --git a/src/ch/epfl/maze/physical/pacman/Ghost.java b/src/ch/epfl/maze/physical/pacman/Ghost.java index f8f511e..77d0e25 100644 --- a/src/ch/epfl/maze/physical/pacman/Ghost.java +++ b/src/ch/epfl/maze/physical/pacman/Ghost.java @@ -4,6 +4,7 @@ import ch.epfl.maze.physical.Daedalus; import ch.epfl.maze.physical.Predator; import ch.epfl.maze.physical.Prey; import ch.epfl.maze.physical.stragegies.picker.RandomPicker; +import ch.epfl.maze.physical.stragegies.planner.DistanceCalculator; import ch.epfl.maze.physical.stragegies.reducer.BackwardReducer; import ch.epfl.maze.physical.stragegies.reducer.CostReducer; import ch.epfl.maze.util.Direction; @@ -17,7 +18,7 @@ import java.util.Set; * * @author Pacien TRAN-GIRARD */ -abstract public class Ghost extends Predator implements BackwardReducer, CostReducer, RandomPicker { +abstract public class Ghost extends Predator implements DistanceCalculator, BackwardReducer, CostReducer, RandomPicker { public enum Mode { CHASE(40), @@ -207,21 +208,6 @@ abstract public class Ghost extends Predator implements BackwardReducer, CostRed return prey.getDirection(); } - /** - * Calculates the Euclidean distance from the adjacent position at the given Direction to the target position. - * - * @param dir The adjacent Direction - * @param targetPosition The targeted position - * @return The Euclidean distance between the two positions - */ - private double getDistanceTo(Direction dir, Vector2D targetPosition) { - return this - .getPosition() - .addDirectionTo(dir) - .sub(targetPosition) - .dist(); - } - /** * Rotates to the next Mode. */ -- cgit v1.2.3