diff options
author | Pacien TRAN-GIRARD | 2015-11-25 00:07:56 +0100 |
---|---|---|
committer | Pacien TRAN-GIRARD | 2015-11-25 00:07:56 +0100 |
commit | c5e5646b7785e1b5d1c46efd5e93a6f95d5bad9f (patch) | |
tree | eaa41d5e140f74c86b1d422c465919fc85ca0e6b /src/ch/epfl/maze/physical/stragegies | |
parent | 4da9bdc4fa2f44eedba3dff29af7b0ce9180e442 (diff) | |
download | maze-solver-c5e5646b7785e1b5d1c46efd5e93a6f95d5bad9f.tar.gz |
Implement PacMan predator avoidance
Diffstat (limited to 'src/ch/epfl/maze/physical/stragegies')
-rw-r--r-- | src/ch/epfl/maze/physical/stragegies/planner/DistanceCalculator.java | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/ch/epfl/maze/physical/stragegies/planner/DistanceCalculator.java b/src/ch/epfl/maze/physical/stragegies/planner/DistanceCalculator.java new file mode 100644 index 0000000..daeb581 --- /dev/null +++ b/src/ch/epfl/maze/physical/stragegies/planner/DistanceCalculator.java | |||
@@ -0,0 +1,33 @@ | |||
1 | package ch.epfl.maze.physical.stragegies.planner; | ||
2 | |||
3 | import ch.epfl.maze.util.Direction; | ||
4 | import ch.epfl.maze.util.Vector2D; | ||
5 | |||
6 | /** | ||
7 | * @author Pacien TRAN-GIRARD | ||
8 | */ | ||
9 | public interface DistanceCalculator { | ||
10 | |||
11 | /** | ||
12 | * Returns the current position. | ||
13 | * | ||
14 | * @return The current position vector | ||
15 | */ | ||
16 | Vector2D getPosition(); | ||
17 | |||
18 | /** | ||
19 | * Calculates the Euclidean distance from the adjacent position at the given Direction to the target position. | ||
20 | * | ||
21 | * @param dir The adjacent Direction | ||
22 | * @param targetPosition The targeted position | ||
23 | * @return The Euclidean distance between the two positions | ||
24 | */ | ||
25 | default double getDistanceTo(Direction dir, Vector2D targetPosition) { | ||
26 | return this | ||
27 | .getPosition() | ||
28 | .addDirectionTo(dir) | ||
29 | .sub(targetPosition) | ||
30 | .dist(); | ||
31 | } | ||
32 | |||
33 | } | ||