diff options
Diffstat (limited to 'src/ch/epfl/maze/physical/ProbabilisticAnimal.java')
-rw-r--r-- | src/ch/epfl/maze/physical/ProbabilisticAnimal.java | 16 |
1 files changed, 2 insertions, 14 deletions
diff --git a/src/ch/epfl/maze/physical/ProbabilisticAnimal.java b/src/ch/epfl/maze/physical/ProbabilisticAnimal.java index ed26d23..650cecf 100644 --- a/src/ch/epfl/maze/physical/ProbabilisticAnimal.java +++ b/src/ch/epfl/maze/physical/ProbabilisticAnimal.java | |||
@@ -17,8 +17,6 @@ abstract public class ProbabilisticAnimal extends Animal { | |||
17 | 17 | ||
18 | public static final Random RANDOM_SOURCE = new Random(); | 18 | public static final Random RANDOM_SOURCE = new Random(); |
19 | 19 | ||
20 | private Direction currentDirection; | ||
21 | |||
22 | /** | 20 | /** |
23 | * Constructs a probabilistic animal with a starting position | 21 | * Constructs a probabilistic animal with a starting position |
24 | * | 22 | * |
@@ -26,15 +24,6 @@ abstract public class ProbabilisticAnimal extends Animal { | |||
26 | */ | 24 | */ |
27 | public ProbabilisticAnimal(Vector2D position) { | 25 | public ProbabilisticAnimal(Vector2D position) { |
28 | super(position); // no pun intended | 26 | super(position); // no pun intended |
29 | this.currentDirection = Direction.NONE; | ||
30 | } | ||
31 | |||
32 | protected Direction getCurrentDirection() { | ||
33 | return this.currentDirection; | ||
34 | } | ||
35 | |||
36 | protected void setCurrentDirection(Direction direction) { | ||
37 | this.currentDirection = direction; | ||
38 | } | 27 | } |
39 | 28 | ||
40 | /** | 29 | /** |
@@ -59,7 +48,7 @@ abstract public class ProbabilisticAnimal extends Animal { | |||
59 | * @return An array of smart choices | 48 | * @return An array of smart choices |
60 | */ | 49 | */ |
61 | protected Direction[] excludeOrigin(Direction[] choices) { | 50 | protected Direction[] excludeOrigin(Direction[] choices) { |
62 | return this.excludeDirection(choices, this.currentDirection.reverse()); | 51 | return this.excludeDirection(choices, this.getDirection().reverse()); |
63 | } | 52 | } |
64 | 53 | ||
65 | /** | 54 | /** |
@@ -81,8 +70,7 @@ abstract public class ProbabilisticAnimal extends Animal { | |||
81 | if (choices.length == 0) return Direction.NONE; | 70 | if (choices.length == 0) return Direction.NONE; |
82 | 71 | ||
83 | Direction[] smartChoices = choices.length > 1 ? this.excludeOrigin(choices) : choices; | 72 | Direction[] smartChoices = choices.length > 1 ? this.excludeOrigin(choices) : choices; |
84 | this.currentDirection = this.getRandomDirection(smartChoices); | 73 | return this.getRandomDirection(smartChoices); |
85 | return this.currentDirection; | ||
86 | } | 74 | } |
87 | 75 | ||
88 | } | 76 | } |