diff options
author | Pacien TRAN-GIRARD | 2015-11-22 18:56:56 +0100 |
---|---|---|
committer | Pacien TRAN-GIRARD | 2015-11-22 18:56:56 +0100 |
commit | 9811ea74bcc9793a1ba6659aab850259e5671763 (patch) | |
tree | b79433e546db6d27fc944b735c72bba670321297 /src | |
parent | 04fa54cd5132aab16104a5dbbccbbdb18243aab6 (diff) | |
download | maze-solver-9811ea74bcc9793a1ba6659aab850259e5671763.tar.gz |
Implement Predator and distinguish derived GhostPredator
Diffstat (limited to 'src')
-rw-r--r-- | src/ch/epfl/maze/physical/GhostPredator.java | 25 | ||||
-rw-r--r-- | src/ch/epfl/maze/physical/Predator.java | 24 | ||||
-rw-r--r-- | src/ch/epfl/maze/physical/pacman/Blinky.java | 4 | ||||
-rw-r--r-- | src/ch/epfl/maze/physical/pacman/Clyde.java | 4 | ||||
-rw-r--r-- | src/ch/epfl/maze/physical/pacman/Inky.java | 4 | ||||
-rw-r--r-- | src/ch/epfl/maze/physical/pacman/Pinky.java | 4 |
6 files changed, 37 insertions, 28 deletions
diff --git a/src/ch/epfl/maze/physical/GhostPredator.java b/src/ch/epfl/maze/physical/GhostPredator.java new file mode 100644 index 0000000..34b8c4f --- /dev/null +++ b/src/ch/epfl/maze/physical/GhostPredator.java | |||
@@ -0,0 +1,25 @@ | |||
1 | package ch.epfl.maze.physical; | ||
2 | |||
3 | import ch.epfl.maze.util.Vector2D; | ||
4 | |||
5 | /** | ||
6 | * Predator ghost that have two different modes and a home position in the labyrinth. | ||
7 | * | ||
8 | * @author Pacien TRAN-GIRARD | ||
9 | */ | ||
10 | abstract public class GhostPredator extends Predator { | ||
11 | |||
12 | /* constants relative to the Pac-Man game */ | ||
13 | public static final int SCATTER_DURATION = 14; | ||
14 | public static final int CHASE_DURATION = 40; | ||
15 | |||
16 | /** | ||
17 | * Constructs a predator with a specified position. | ||
18 | * | ||
19 | * @param position Position of the predator in the labyrinth | ||
20 | */ | ||
21 | public GhostPredator(Vector2D position) { | ||
22 | super(position); | ||
23 | } | ||
24 | |||
25 | } | ||
diff --git a/src/ch/epfl/maze/physical/Predator.java b/src/ch/epfl/maze/physical/Predator.java index 8c340e8..7d30ce6 100644 --- a/src/ch/epfl/maze/physical/Predator.java +++ b/src/ch/epfl/maze/physical/Predator.java | |||
@@ -5,34 +5,18 @@ import ch.epfl.maze.util.Vector2D; | |||
5 | 5 | ||
6 | /** | 6 | /** |
7 | * Predator that kills a prey when they meet with each other in the labyrinth. | 7 | * Predator that kills a prey when they meet with each other in the labyrinth. |
8 | * | ||
9 | * @author Pacien TRAN-GIRARD | ||
8 | */ | 10 | */ |
9 | 11 | abstract public class Predator extends ProbabilisticAnimal { | |
10 | abstract public class Predator extends Animal { | ||
11 | |||
12 | /* constants relative to the Pac-Man game */ | ||
13 | public static final int SCATTER_DURATION = 14; | ||
14 | public static final int CHASE_DURATION = 40; | ||
15 | 12 | ||
16 | /** | 13 | /** |
17 | * Constructs a predator with a specified position. | 14 | * Constructs a predator with a specified position. |
18 | * | 15 | * |
19 | * @param position Position of the predator in the labyrinth | 16 | * @param position Position of the predator in the labyrinth |
20 | */ | 17 | */ |
21 | |||
22 | public Predator(Vector2D position) { | 18 | public Predator(Vector2D position) { |
23 | super(position); | 19 | super(position); |
24 | // TODO | ||
25 | } | ||
26 | |||
27 | /** | ||
28 | * Moves according to a <i>random walk</i>, used while not hunting in a | ||
29 | * {@code MazeSimulation}. | ||
30 | */ | ||
31 | |||
32 | @Override | ||
33 | public final Direction move(Direction[] choices) { | ||
34 | // TODO | ||
35 | return Direction.NONE; | ||
36 | } | 20 | } |
37 | 21 | ||
38 | /** | 22 | /** |
@@ -49,6 +33,6 @@ abstract public class Predator extends Animal { | |||
49 | * @param daedalus The world in which the animal moves | 33 | * @param daedalus The world in which the animal moves |
50 | * @return The next direction of the animal, chosen in {@code choices} | 34 | * @return The next direction of the animal, chosen in {@code choices} |
51 | */ | 35 | */ |
52 | |||
53 | abstract public Direction move(Direction[] choices, Daedalus daedalus); | 36 | abstract public Direction move(Direction[] choices, Daedalus daedalus); |
37 | |||
54 | } | 38 | } |
diff --git a/src/ch/epfl/maze/physical/pacman/Blinky.java b/src/ch/epfl/maze/physical/pacman/Blinky.java index 02b7159..f91f5e0 100644 --- a/src/ch/epfl/maze/physical/pacman/Blinky.java +++ b/src/ch/epfl/maze/physical/pacman/Blinky.java | |||
@@ -2,7 +2,7 @@ package ch.epfl.maze.physical.pacman; | |||
2 | 2 | ||
3 | import ch.epfl.maze.physical.Animal; | 3 | import ch.epfl.maze.physical.Animal; |
4 | import ch.epfl.maze.physical.Daedalus; | 4 | import ch.epfl.maze.physical.Daedalus; |
5 | import ch.epfl.maze.physical.Predator; | 5 | import ch.epfl.maze.physical.GhostPredator; |
6 | import ch.epfl.maze.util.Direction; | 6 | import ch.epfl.maze.util.Direction; |
7 | import ch.epfl.maze.util.Vector2D; | 7 | import ch.epfl.maze.util.Vector2D; |
8 | 8 | ||
@@ -10,7 +10,7 @@ import ch.epfl.maze.util.Vector2D; | |||
10 | * Red ghost from the Pac-Man game, chases directly its target. | 10 | * Red ghost from the Pac-Man game, chases directly its target. |
11 | */ | 11 | */ |
12 | 12 | ||
13 | public class Blinky extends Predator { | 13 | public class Blinky extends GhostPredator { |
14 | 14 | ||
15 | /** | 15 | /** |
16 | * Constructs a Blinky with a starting position. | 16 | * Constructs a Blinky with a starting position. |
diff --git a/src/ch/epfl/maze/physical/pacman/Clyde.java b/src/ch/epfl/maze/physical/pacman/Clyde.java index 35d0a9b..6b3bef3 100644 --- a/src/ch/epfl/maze/physical/pacman/Clyde.java +++ b/src/ch/epfl/maze/physical/pacman/Clyde.java | |||
@@ -2,7 +2,7 @@ package ch.epfl.maze.physical.pacman; | |||
2 | 2 | ||
3 | import ch.epfl.maze.physical.Animal; | 3 | import ch.epfl.maze.physical.Animal; |
4 | import ch.epfl.maze.physical.Daedalus; | 4 | import ch.epfl.maze.physical.Daedalus; |
5 | import ch.epfl.maze.physical.Predator; | 5 | import ch.epfl.maze.physical.GhostPredator; |
6 | import ch.epfl.maze.util.Direction; | 6 | import ch.epfl.maze.util.Direction; |
7 | import ch.epfl.maze.util.Vector2D; | 7 | import ch.epfl.maze.util.Vector2D; |
8 | 8 | ||
@@ -11,7 +11,7 @@ import ch.epfl.maze.util.Vector2D; | |||
11 | * from its target and SCATTER if close. | 11 | * from its target and SCATTER if close. |
12 | */ | 12 | */ |
13 | 13 | ||
14 | public class Clyde extends Predator { | 14 | public class Clyde extends GhostPredator { |
15 | 15 | ||
16 | /** | 16 | /** |
17 | * Constructs a Clyde with a starting position. | 17 | * Constructs a Clyde with a starting position. |
diff --git a/src/ch/epfl/maze/physical/pacman/Inky.java b/src/ch/epfl/maze/physical/pacman/Inky.java index e5cf5ad..146ecef 100644 --- a/src/ch/epfl/maze/physical/pacman/Inky.java +++ b/src/ch/epfl/maze/physical/pacman/Inky.java | |||
@@ -2,7 +2,7 @@ package ch.epfl.maze.physical.pacman; | |||
2 | 2 | ||
3 | import ch.epfl.maze.physical.Animal; | 3 | import ch.epfl.maze.physical.Animal; |
4 | import ch.epfl.maze.physical.Daedalus; | 4 | import ch.epfl.maze.physical.Daedalus; |
5 | import ch.epfl.maze.physical.Predator; | 5 | import ch.epfl.maze.physical.GhostPredator; |
6 | import ch.epfl.maze.util.Direction; | 6 | import ch.epfl.maze.util.Direction; |
7 | import ch.epfl.maze.util.Vector2D; | 7 | import ch.epfl.maze.util.Vector2D; |
8 | 8 | ||
@@ -11,7 +11,7 @@ import ch.epfl.maze.util.Vector2D; | |||
11 | * from Blinky to its target. | 11 | * from Blinky to its target. |
12 | */ | 12 | */ |
13 | 13 | ||
14 | public class Inky extends Predator { | 14 | public class Inky extends GhostPredator { |
15 | 15 | ||
16 | /** | 16 | /** |
17 | * Constructs a Inky with a starting position. | 17 | * Constructs a Inky with a starting position. |
diff --git a/src/ch/epfl/maze/physical/pacman/Pinky.java b/src/ch/epfl/maze/physical/pacman/Pinky.java index 100264c..3e4209d 100644 --- a/src/ch/epfl/maze/physical/pacman/Pinky.java +++ b/src/ch/epfl/maze/physical/pacman/Pinky.java | |||
@@ -2,7 +2,7 @@ package ch.epfl.maze.physical.pacman; | |||
2 | 2 | ||
3 | import ch.epfl.maze.physical.Animal; | 3 | import ch.epfl.maze.physical.Animal; |
4 | import ch.epfl.maze.physical.Daedalus; | 4 | import ch.epfl.maze.physical.Daedalus; |
5 | import ch.epfl.maze.physical.Predator; | 5 | import ch.epfl.maze.physical.GhostPredator; |
6 | import ch.epfl.maze.util.Direction; | 6 | import ch.epfl.maze.util.Direction; |
7 | import ch.epfl.maze.util.Vector2D; | 7 | import ch.epfl.maze.util.Vector2D; |
8 | 8 | ||
@@ -10,7 +10,7 @@ import ch.epfl.maze.util.Vector2D; | |||
10 | * Pink ghost from the Pac-Man game, targets 4 squares in front of its target. | 10 | * Pink ghost from the Pac-Man game, targets 4 squares in front of its target. |
11 | */ | 11 | */ |
12 | 12 | ||
13 | public class Pinky extends Predator { | 13 | public class Pinky extends GhostPredator { |
14 | 14 | ||
15 | /** | 15 | /** |
16 | * Constructs a Pinky with a starting position. | 16 | * Constructs a Pinky with a starting position. |