From be641348b8d677b3d9cdc0db90804edb0c46a3dc Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Tue, 24 Nov 2015 21:35:11 +0100 Subject: Refactor PacMan A.I. --- src/ch/epfl/maze/physical/pacman/PacMan.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/ch') 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; import ch.epfl.maze.physical.Animal; import ch.epfl.maze.physical.Daedalus; import ch.epfl.maze.physical.Prey; +import ch.epfl.maze.physical.stragegies.picker.RandomPicker; +import ch.epfl.maze.physical.stragegies.reducer.BackwardReducer; import ch.epfl.maze.util.Direction; import ch.epfl.maze.util.Vector2D; @@ -14,15 +16,21 @@ import java.util.Set; * @author EPFL * @author Pacien TRAN-GIRARD */ -public class PacMan extends Prey { +public class PacMan extends Prey implements BackwardReducer, RandomPicker { + /** + * Constructs a new Pac-Man. + * + * @param position Starting position of the Pac-Man in the Daedalus + */ public PacMan(Vector2D position) { super(position); } @Override public Direction move(Set choices, Daedalus daedalus) { - return this.move(choices); + Set smartChoices = choices.size() > 1 ? this.reduce(choices) : choices; + return this.pick(smartChoices); } @Override -- cgit v1.2.3