summaryrefslogtreecommitdiff
path: root/src/ch/epfl/maze/physical/pacman/Ghost.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/ch/epfl/maze/physical/pacman/Ghost.java')
-rw-r--r--src/ch/epfl/maze/physical/pacman/Ghost.java18
1 files changed, 2 insertions, 16 deletions
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;
4import ch.epfl.maze.physical.Predator; 4import ch.epfl.maze.physical.Predator;
5import ch.epfl.maze.physical.Prey; 5import ch.epfl.maze.physical.Prey;
6import ch.epfl.maze.physical.stragegies.picker.RandomPicker; 6import ch.epfl.maze.physical.stragegies.picker.RandomPicker;
7import ch.epfl.maze.physical.stragegies.planner.DistanceCalculator;
7import ch.epfl.maze.physical.stragegies.reducer.BackwardReducer; 8import ch.epfl.maze.physical.stragegies.reducer.BackwardReducer;
8import ch.epfl.maze.physical.stragegies.reducer.CostReducer; 9import ch.epfl.maze.physical.stragegies.reducer.CostReducer;
9import ch.epfl.maze.util.Direction; 10import ch.epfl.maze.util.Direction;
@@ -17,7 +18,7 @@ import java.util.Set;
17 * 18 *
18 * @author Pacien TRAN-GIRARD 19 * @author Pacien TRAN-GIRARD
19 */ 20 */
20abstract public class Ghost extends Predator implements BackwardReducer, CostReducer, RandomPicker { 21abstract public class Ghost extends Predator implements DistanceCalculator, BackwardReducer, CostReducer, RandomPicker {
21 22
22 public enum Mode { 23 public enum Mode {
23 CHASE(40), 24 CHASE(40),
@@ -208,21 +209,6 @@ abstract public class Ghost extends Predator implements BackwardReducer, CostRed
208 } 209 }
209 210
210 /** 211 /**
211 * Calculates the Euclidean distance from the adjacent position at the given Direction to the target position.
212 *
213 * @param dir The adjacent Direction
214 * @param targetPosition The targeted position
215 * @return The Euclidean distance between the two positions
216 */
217 private double getDistanceTo(Direction dir, Vector2D targetPosition) {
218 return this
219 .getPosition()
220 .addDirectionTo(dir)
221 .sub(targetPosition)
222 .dist();
223 }
224
225 /**
226 * Rotates to the next Mode. 212 * Rotates to the next Mode.
227 */ 213 */
228 protected void rotateMode() { 214 protected void rotateMode() {