diff options
-rw-r--r-- | src/ch/epfl/maze/physical/pacman/PacMan.java | 12 |
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; | |||
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.Prey; | 5 | import ch.epfl.maze.physical.Prey; |
6 | import ch.epfl.maze.physical.stragegies.picker.RandomPicker; | ||
7 | import ch.epfl.maze.physical.stragegies.reducer.BackwardReducer; | ||
6 | import ch.epfl.maze.util.Direction; | 8 | import ch.epfl.maze.util.Direction; |
7 | import ch.epfl.maze.util.Vector2D; | 9 | import 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 | */ |
17 | public class PacMan extends Prey { | 19 | public 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 |