summaryrefslogtreecommitdiff
path: root/src/ch
diff options
context:
space:
mode:
authorPacien TRAN-GIRARD2015-11-24 21:35:11 +0100
committerPacien TRAN-GIRARD2015-11-24 21:35:11 +0100
commitbe641348b8d677b3d9cdc0db90804edb0c46a3dc (patch)
tree31612d5706f6d5536bc6d084d99f970ee0ae6bfe /src/ch
parent5a45593914a7f96f5d6dfe8526caa5dcc34ac16a (diff)
downloadmaze-solver-be641348b8d677b3d9cdc0db90804edb0c46a3dc.tar.gz
Refactor PacMan A.I.
Diffstat (limited to 'src/ch')
-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