From 9811ea74bcc9793a1ba6659aab850259e5671763 Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Sun, 22 Nov 2015 18:56:56 +0100 Subject: Implement Predator and distinguish derived GhostPredator --- src/ch/epfl/maze/physical/GhostPredator.java | 25 +++++++++++++++++++++++++ src/ch/epfl/maze/physical/Predator.java | 24 ++++-------------------- src/ch/epfl/maze/physical/pacman/Blinky.java | 4 ++-- src/ch/epfl/maze/physical/pacman/Clyde.java | 4 ++-- src/ch/epfl/maze/physical/pacman/Inky.java | 4 ++-- src/ch/epfl/maze/physical/pacman/Pinky.java | 4 ++-- 6 files changed, 37 insertions(+), 28 deletions(-) create mode 100644 src/ch/epfl/maze/physical/GhostPredator.java 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 @@ +package ch.epfl.maze.physical; + +import ch.epfl.maze.util.Vector2D; + +/** + * Predator ghost that have two different modes and a home position in the labyrinth. + * + * @author Pacien TRAN-GIRARD + */ +abstract public class GhostPredator extends Predator { + + /* constants relative to the Pac-Man game */ + public static final int SCATTER_DURATION = 14; + public static final int CHASE_DURATION = 40; + + /** + * Constructs a predator with a specified position. + * + * @param position Position of the predator in the labyrinth + */ + public GhostPredator(Vector2D position) { + super(position); + } + +} 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; /** * Predator that kills a prey when they meet with each other in the labyrinth. + * + * @author Pacien TRAN-GIRARD */ - -abstract public class Predator extends Animal { - - /* constants relative to the Pac-Man game */ - public static final int SCATTER_DURATION = 14; - public static final int CHASE_DURATION = 40; +abstract public class Predator extends ProbabilisticAnimal { /** * Constructs a predator with a specified position. * * @param position Position of the predator in the labyrinth */ - public Predator(Vector2D position) { super(position); - // TODO - } - - /** - * Moves according to a random walk, used while not hunting in a - * {@code MazeSimulation}. - */ - - @Override - public final Direction move(Direction[] choices) { - // TODO - return Direction.NONE; } /** @@ -49,6 +33,6 @@ abstract public class Predator extends Animal { * @param daedalus The world in which the animal moves * @return The next direction of the animal, chosen in {@code choices} */ - abstract public Direction move(Direction[] choices, Daedalus daedalus); + } 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; import ch.epfl.maze.physical.Animal; import ch.epfl.maze.physical.Daedalus; -import ch.epfl.maze.physical.Predator; +import ch.epfl.maze.physical.GhostPredator; import ch.epfl.maze.util.Direction; import ch.epfl.maze.util.Vector2D; @@ -10,7 +10,7 @@ import ch.epfl.maze.util.Vector2D; * Red ghost from the Pac-Man game, chases directly its target. */ -public class Blinky extends Predator { +public class Blinky extends GhostPredator { /** * 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; import ch.epfl.maze.physical.Animal; import ch.epfl.maze.physical.Daedalus; -import ch.epfl.maze.physical.Predator; +import ch.epfl.maze.physical.GhostPredator; import ch.epfl.maze.util.Direction; import ch.epfl.maze.util.Vector2D; @@ -11,7 +11,7 @@ import ch.epfl.maze.util.Vector2D; * from its target and SCATTER if close. */ -public class Clyde extends Predator { +public class Clyde extends GhostPredator { /** * 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; import ch.epfl.maze.physical.Animal; import ch.epfl.maze.physical.Daedalus; -import ch.epfl.maze.physical.Predator; +import ch.epfl.maze.physical.GhostPredator; import ch.epfl.maze.util.Direction; import ch.epfl.maze.util.Vector2D; @@ -11,7 +11,7 @@ import ch.epfl.maze.util.Vector2D; * from Blinky to its target. */ -public class Inky extends Predator { +public class Inky extends GhostPredator { /** * 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; import ch.epfl.maze.physical.Animal; import ch.epfl.maze.physical.Daedalus; -import ch.epfl.maze.physical.Predator; +import ch.epfl.maze.physical.GhostPredator; import ch.epfl.maze.util.Direction; import ch.epfl.maze.util.Vector2D; @@ -10,7 +10,7 @@ import ch.epfl.maze.util.Vector2D; * Pink ghost from the Pac-Man game, targets 4 squares in front of its target. */ -public class Pinky extends Predator { +public class Pinky extends GhostPredator { /** * Constructs a Pinky with a starting position. -- cgit v1.2.3