diff options
Diffstat (limited to 'src/ch/epfl/maze/physical/zoo')
-rw-r--r-- | src/ch/epfl/maze/physical/zoo/Mouse.java | 18 |
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 @@ | |||
1 | package ch.epfl.maze.physical.zoo; | 1 | package ch.epfl.maze.physical.zoo; |
2 | 2 | ||
3 | import ch.epfl.maze.physical.Animal; | 3 | import ch.epfl.maze.physical.Animal; |
4 | import ch.epfl.maze.physical.ProbabilisticAnimal; | 4 | import ch.epfl.maze.physical.stragegies.picker.RandomPicker; |
5 | import ch.epfl.maze.physical.stragegies.reducer.BackwardReducer; | ||
6 | import ch.epfl.maze.util.Direction; | ||
5 | import ch.epfl.maze.util.Vector2D; | 7 | import ch.epfl.maze.util.Vector2D; |
6 | 8 | ||
9 | import 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 | */ |
13 | public class Mouse extends ProbabilisticAnimal { | 17 | public 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()); |