summaryrefslogtreecommitdiff
path: root/src/ch/epfl/maze/physical/ProbabilisticAnimal.java
diff options
context:
space:
mode:
authorPacien TRAN-GIRARD2015-11-21 17:31:08 +0100
committerPacien TRAN-GIRARD2015-11-21 17:31:08 +0100
commit9dfd4cbfce88951f196cfbb86154d7d7b2320cf3 (patch)
tree0513d3d269b05d08a526b880664d06e9e112ad1b /src/ch/epfl/maze/physical/ProbabilisticAnimal.java
parent6add32eb44cf4a9e3228c74f79742ade424f08b1 (diff)
downloadmaze-solver-9dfd4cbfce88951f196cfbb86154d7d7b2320cf3.tar.gz
Add ProbabilisticAnimal type and adapt assets retrieval accordingly
Diffstat (limited to 'src/ch/epfl/maze/physical/ProbabilisticAnimal.java')
-rw-r--r--src/ch/epfl/maze/physical/ProbabilisticAnimal.java38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/ch/epfl/maze/physical/ProbabilisticAnimal.java b/src/ch/epfl/maze/physical/ProbabilisticAnimal.java
new file mode 100644
index 0000000..6b0c57f
--- /dev/null
+++ b/src/ch/epfl/maze/physical/ProbabilisticAnimal.java
@@ -0,0 +1,38 @@
1package ch.epfl.maze.physical;
2
3import ch.epfl.maze.util.Direction;
4import ch.epfl.maze.util.Vector2D;
5
6import java.util.Random;
7
8/**
9 * A probabilistic animal that use a random component in its decision making process.
10 *
11 * @author Pacien TRAN-GIRARD
12 */
13
14abstract public class ProbabilisticAnimal extends Animal {
15
16 private final Random randomSource;
17
18 /**
19 * Constructs a probabilistic animal with a starting position
20 *
21 * @param position Starting position of the probabilistic animal in the labyrinth
22 */
23
24 public ProbabilisticAnimal(Vector2D position) {
25 super(position); // no pun intended
26 this.randomSource = new Random();
27 }
28
29 /**
30 * Moves according to a <i>random walk</i>.
31 */
32
33 @Override
34 public Direction move(Direction[] choices) {
35 return choices[randomSource.nextInt(choices.length)];
36 }
37
38}