summaryrefslogtreecommitdiff
path: root/src/ch/epfl/maze/physical/pacman
diff options
context:
space:
mode:
Diffstat (limited to 'src/ch/epfl/maze/physical/pacman')
-rw-r--r--src/ch/epfl/maze/physical/pacman/PacMan.java12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/ch/epfl/maze/physical/pacman/PacMan.java b/src/ch/epfl/maze/physical/pacman/PacMan.java
index debac67..e2a55e9 100644
--- a/src/ch/epfl/maze/physical/pacman/PacMan.java
+++ b/src/ch/epfl/maze/physical/pacman/PacMan.java
@@ -3,6 +3,8 @@ 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.Prey; 5import ch.epfl.maze.physical.Prey;
6import ch.epfl.maze.physical.stragegies.picker.RandomPicker;
7import ch.epfl.maze.physical.stragegies.reducer.BackwardReducer;
6import ch.epfl.maze.util.Direction; 8import ch.epfl.maze.util.Direction;
7import ch.epfl.maze.util.Vector2D; 9import ch.epfl.maze.util.Vector2D;
8 10
@@ -14,15 +16,21 @@ import java.util.Set;
14 * @author EPFL 16 * @author EPFL
15 * @author Pacien TRAN-GIRARD 17 * @author Pacien TRAN-GIRARD
16 */ 18 */
17public class PacMan extends Prey { 19public class PacMan extends Prey implements BackwardReducer, RandomPicker {
18 20
21 /**
22 * Constructs a new Pac-Man.
23 *
24 * @param position Starting position of the Pac-Man in the Daedalus
25 */
19 public PacMan(Vector2D position) { 26 public PacMan(Vector2D position) {
20 super(position); 27 super(position);
21 } 28 }
22 29
23 @Override 30 @Override
24 public Direction move(Set<Direction> choices, Daedalus daedalus) { 31 public Direction move(Set<Direction> choices, Daedalus daedalus) {
25 return this.move(choices); 32 Set<Direction> smartChoices = choices.size() > 1 ? this.reduce(choices) : choices;
33 return this.pick(smartChoices);
26 } 34 }
27 35
28 @Override 36 @Override