summaryrefslogtreecommitdiff
path: root/src/ch/epfl/maze/physical/pacman/Clyde.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/ch/epfl/maze/physical/pacman/Clyde.java')
-rw-r--r--src/ch/epfl/maze/physical/pacman/Clyde.java46
1 files changed, 39 insertions, 7 deletions
diff --git a/src/ch/epfl/maze/physical/pacman/Clyde.java b/src/ch/epfl/maze/physical/pacman/Clyde.java
index 6b3bef3..7e8bdd7 100644
--- a/src/ch/epfl/maze/physical/pacman/Clyde.java
+++ b/src/ch/epfl/maze/physical/pacman/Clyde.java
@@ -3,35 +3,67 @@ package ch.epfl.maze.physical.pacman;
3import ch.epfl.maze.physical.Animal; 3import ch.epfl.maze.physical.Animal;
4import ch.epfl.maze.physical.Daedalus; 4import ch.epfl.maze.physical.Daedalus;
5import ch.epfl.maze.physical.GhostPredator; 5import ch.epfl.maze.physical.GhostPredator;
6import ch.epfl.maze.util.Direction;
7import ch.epfl.maze.util.Vector2D; 6import ch.epfl.maze.util.Vector2D;
8 7
9/** 8/**
10 * Orange ghost from the Pac-Man game, alternates between direct chase if far 9 * Orange ghost from the Pac-Man game, alternates between direct chase if far
11 * from its target and SCATTER if close. 10 * from its target and SCATTER if close.
11 *
12 * @author Pacien TRAN-GIRARD
12 */ 13 */
13
14public class Clyde extends GhostPredator { 14public class Clyde extends GhostPredator {
15 15
16 private static double PROXIMITY_THRESHOLD = 4.0d;
17
16 /** 18 /**
17 * Constructs a Clyde with a starting position. 19 * Constructs a Clyde with a starting position.
18 * 20 *
19 * @param position Starting position of Clyde in the labyrinth 21 * @param position Starting position of Clyde in the labyrinth
20 */ 22 */
21
22 public Clyde(Vector2D position) { 23 public Clyde(Vector2D position) {
23 super(position); 24 super(position);
24 // TODO
25 } 25 }
26 26
27 /**
28 * Checks if Clyde is close to the targeted Prey.
29 *
30 * @param daedalus The Daedalus
31 * @return T(the Prey is reckless)
32 */
33 private boolean closeToTarget(Daedalus daedalus) {
34 double dist = this
35 .getPosition()
36 .sub(this.getPreyPosition(daedalus))
37 .dist();
38
39 return dist < Clyde.PROXIMITY_THRESHOLD;
40 }
41
42 /**
43 * Returns the current Mode, forcing the SCATTER Mode if far from the target.
44 *
45 * @param daedalus The Daedalus
46 * @return The current Mode
47 */
27 @Override 48 @Override
28 public Direction move(Direction[] choices, Daedalus daedalus) { 49 protected Mode getMode(Daedalus daedalus) {
29 // TODO 50 return this.closeToTarget(daedalus) ? super.getMode(daedalus) : Mode.SCATTER;
30 return Direction.NONE; 51 }
52
53 /**
54 * Targets directly the current position of the Prey.
55 *
56 * @param daedalus The Daedalus
57 * @return The position of the Prey
58 */
59 @Override
60 protected Vector2D getPreyTargetPosition(Daedalus daedalus) {
61 return getPreyPosition(daedalus);
31 } 62 }
32 63
33 @Override 64 @Override
34 public Animal copy() { 65 public Animal copy() {
35 return new Clyde(this.getPosition()); 66 return new Clyde(this.getPosition());
36 } 67 }
68
37} 69}