diff options
Diffstat (limited to 'src/ch/epfl/maze/physical/pacman/Ghost.java')
-rw-r--r-- | src/ch/epfl/maze/physical/pacman/Ghost.java | 18 |
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; | |||
4 | import ch.epfl.maze.physical.Predator; | 4 | import ch.epfl.maze.physical.Predator; |
5 | import ch.epfl.maze.physical.Prey; | 5 | import ch.epfl.maze.physical.Prey; |
6 | import ch.epfl.maze.physical.stragegies.picker.RandomPicker; | 6 | import ch.epfl.maze.physical.stragegies.picker.RandomPicker; |
7 | import ch.epfl.maze.physical.stragegies.planner.DistanceCalculator; | ||
7 | import ch.epfl.maze.physical.stragegies.reducer.BackwardReducer; | 8 | import ch.epfl.maze.physical.stragegies.reducer.BackwardReducer; |
8 | import ch.epfl.maze.physical.stragegies.reducer.CostReducer; | 9 | import ch.epfl.maze.physical.stragegies.reducer.CostReducer; |
9 | import ch.epfl.maze.util.Direction; | 10 | import 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 | */ |
20 | abstract public class Ghost extends Predator implements BackwardReducer, CostReducer, RandomPicker { | 21 | abstract 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() { |