summaryrefslogtreecommitdiff
path: root/src/ch/epfl/maze/physical/zoo
diff options
context:
space:
mode:
authorPacien TRAN-GIRARD2015-11-24 15:23:36 +0100
committerPacien TRAN-GIRARD2015-11-24 15:37:19 +0100
commit33e497e3083c8446588244c1fa9e69f70af05664 (patch)
tree3ef665e3c9478f196bb6d61dd15a71c0a9919216 /src/ch/epfl/maze/physical/zoo
parent6f2f503bbf75901273376c8c009a6b96886650c8 (diff)
downloadmaze-solver-33e497e3083c8446588244c1fa9e69f70af05664.tar.gz
Refactor Mouse strategy
Diffstat (limited to 'src/ch/epfl/maze/physical/zoo')
-rw-r--r--src/ch/epfl/maze/physical/zoo/Mouse.java18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/ch/epfl/maze/physical/zoo/Mouse.java b/src/ch/epfl/maze/physical/zoo/Mouse.java
index f7084d7..8f68af6 100644
--- a/src/ch/epfl/maze/physical/zoo/Mouse.java
+++ b/src/ch/epfl/maze/physical/zoo/Mouse.java
@@ -1,16 +1,20 @@
1package ch.epfl.maze.physical.zoo; 1package ch.epfl.maze.physical.zoo;
2 2
3import ch.epfl.maze.physical.Animal; 3import ch.epfl.maze.physical.Animal;
4import ch.epfl.maze.physical.ProbabilisticAnimal; 4import ch.epfl.maze.physical.stragegies.picker.RandomPicker;
5import ch.epfl.maze.physical.stragegies.reducer.BackwardReducer;
6import ch.epfl.maze.util.Direction;
5import ch.epfl.maze.util.Vector2D; 7import ch.epfl.maze.util.Vector2D;
6 8
9import java.util.Set;
10
7/** 11/**
8 * Mouse A.I. that remembers only the previous choice it has made. 12 * Mouse A.I. that remembers only the previous choice it has made.
9 * 13 *
10 * @author EPFL 14 * @author EPFL
11 * @author Pacien TRAN-GIRARD 15 * @author Pacien TRAN-GIRARD
12 */ 16 */
13public class Mouse extends ProbabilisticAnimal { 17public class Mouse extends Animal implements BackwardReducer, RandomPicker {
14 18
15 /** 19 /**
16 * Constructs a mouse with a starting position. 20 * Constructs a mouse with a starting position.
@@ -21,6 +25,16 @@ public class Mouse extends ProbabilisticAnimal {
21 super(position); 25 super(position);
22 } 26 }
23 27
28 /**
29 * Moves according to an improved version of a <i>random walk</i> : the
30 * mouse does not directly retrace its steps.
31 */
32 @Override
33 public Direction move(Set<Direction> choices) {
34 Set<Direction> smartChoices = choices.size() > 1 ? this.reduce(choices) : choices;
35 return this.pick(smartChoices);
36 }
37
24 @Override 38 @Override
25 public Animal copy() { 39 public Animal copy() {
26 return new Mouse(this.getPosition()); 40 return new Mouse(this.getPosition());