diff options
Diffstat (limited to 'src/ch/epfl/maze/physical/zoo')
-rw-r--r-- | src/ch/epfl/maze/physical/zoo/Bear.java | 46 | ||||
-rw-r--r-- | src/ch/epfl/maze/physical/zoo/Hamster.java | 43 | ||||
-rw-r--r-- | src/ch/epfl/maze/physical/zoo/Monkey.java | 41 | ||||
-rw-r--r-- | src/ch/epfl/maze/physical/zoo/Mouse.java | 41 | ||||
-rw-r--r-- | src/ch/epfl/maze/physical/zoo/Panda.java | 43 | ||||
-rw-r--r-- | src/ch/epfl/maze/physical/zoo/SpaceInvader.java | 52 |
6 files changed, 266 insertions, 0 deletions
diff --git a/src/ch/epfl/maze/physical/zoo/Bear.java b/src/ch/epfl/maze/physical/zoo/Bear.java new file mode 100644 index 0000000..1a75932 --- /dev/null +++ b/src/ch/epfl/maze/physical/zoo/Bear.java | |||
@@ -0,0 +1,46 @@ | |||
1 | package ch.epfl.maze.physical.zoo; | ||
2 | |||
3 | import ch.epfl.maze.physical.Animal; | ||
4 | import ch.epfl.maze.util.Direction; | ||
5 | import ch.epfl.maze.util.Vector2D; | ||
6 | |||
7 | /** | ||
8 | * Bear A.I. that implements the Pledge Algorithm. | ||
9 | * | ||
10 | */ | ||
11 | |||
12 | public class Bear extends Animal { | ||
13 | |||
14 | /** | ||
15 | * Constructs a bear with a starting position. | ||
16 | * | ||
17 | * @param position | ||
18 | * Starting position of the bear in the labyrinth | ||
19 | */ | ||
20 | |||
21 | public Bear(Vector2D position) { | ||
22 | super(position); | ||
23 | // TODO | ||
24 | } | ||
25 | |||
26 | /** | ||
27 | * Moves according to the <i>Pledge Algorithm</i> : the bear tries to move | ||
28 | * towards a favorite direction until it hits a wall. In this case, it will | ||
29 | * turn right, put its paw on the left wall, count the number of times it | ||
30 | * turns right, and subtract to this the number of times it turns left. It | ||
31 | * will repeat the procedure when the counter comes to zero, or until it | ||
32 | * leaves the maze. | ||
33 | */ | ||
34 | |||
35 | @Override | ||
36 | public Direction move(Direction[] choices) { | ||
37 | // TODO | ||
38 | return Direction.NONE; | ||
39 | } | ||
40 | |||
41 | @Override | ||
42 | public Animal copy() { | ||
43 | // TODO | ||
44 | return null; | ||
45 | } | ||
46 | } | ||
diff --git a/src/ch/epfl/maze/physical/zoo/Hamster.java b/src/ch/epfl/maze/physical/zoo/Hamster.java new file mode 100644 index 0000000..a000daf --- /dev/null +++ b/src/ch/epfl/maze/physical/zoo/Hamster.java | |||
@@ -0,0 +1,43 @@ | |||
1 | package ch.epfl.maze.physical.zoo; | ||
2 | |||
3 | import ch.epfl.maze.physical.Animal; | ||
4 | import ch.epfl.maze.util.Direction; | ||
5 | import ch.epfl.maze.util.Vector2D; | ||
6 | |||
7 | /** | ||
8 | * Hamster A.I. that remembers the previous choice it has made and the dead ends | ||
9 | * it has already met. | ||
10 | * | ||
11 | */ | ||
12 | |||
13 | public class Hamster extends Animal { | ||
14 | |||
15 | /** | ||
16 | * Constructs a hamster with a starting position. | ||
17 | * | ||
18 | * @param position | ||
19 | * Starting position of the hamster in the labyrinth | ||
20 | */ | ||
21 | |||
22 | public Hamster(Vector2D position) { | ||
23 | super(position); | ||
24 | // TODO | ||
25 | } | ||
26 | |||
27 | /** | ||
28 | * Moves without retracing directly its steps and by avoiding the dead-ends | ||
29 | * it learns during its journey. | ||
30 | */ | ||
31 | |||
32 | @Override | ||
33 | public Direction move(Direction[] choices) { | ||
34 | // TODO | ||
35 | return Direction.NONE; | ||
36 | } | ||
37 | |||
38 | @Override | ||
39 | public Animal copy() { | ||
40 | // TODO | ||
41 | return null; | ||
42 | } | ||
43 | } | ||
diff --git a/src/ch/epfl/maze/physical/zoo/Monkey.java b/src/ch/epfl/maze/physical/zoo/Monkey.java new file mode 100644 index 0000000..a9295b8 --- /dev/null +++ b/src/ch/epfl/maze/physical/zoo/Monkey.java | |||
@@ -0,0 +1,41 @@ | |||
1 | package ch.epfl.maze.physical.zoo; | ||
2 | |||
3 | import ch.epfl.maze.physical.Animal; | ||
4 | import ch.epfl.maze.util.Direction; | ||
5 | import ch.epfl.maze.util.Vector2D; | ||
6 | |||
7 | /** | ||
8 | * Monkey A.I. that puts its hand on the left wall and follows it. | ||
9 | * | ||
10 | */ | ||
11 | |||
12 | public class Monkey extends Animal { | ||
13 | |||
14 | /** | ||
15 | * Constructs a monkey with a starting position. | ||
16 | * | ||
17 | * @param position | ||
18 | * Starting position of the monkey in the labyrinth | ||
19 | */ | ||
20 | |||
21 | public Monkey(Vector2D position) { | ||
22 | super(position); | ||
23 | // TODO | ||
24 | } | ||
25 | |||
26 | /** | ||
27 | * Moves according to the relative left wall that the monkey has to follow. | ||
28 | */ | ||
29 | |||
30 | @Override | ||
31 | public Direction move(Direction[] choices) { | ||
32 | // TODO | ||
33 | return Direction.NONE; | ||
34 | } | ||
35 | |||
36 | @Override | ||
37 | public Animal copy() { | ||
38 | // TODO | ||
39 | return null; | ||
40 | } | ||
41 | } | ||
diff --git a/src/ch/epfl/maze/physical/zoo/Mouse.java b/src/ch/epfl/maze/physical/zoo/Mouse.java new file mode 100644 index 0000000..17d8b5c --- /dev/null +++ b/src/ch/epfl/maze/physical/zoo/Mouse.java | |||
@@ -0,0 +1,41 @@ | |||
1 | package ch.epfl.maze.physical.zoo; | ||
2 | |||
3 | import ch.epfl.maze.physical.Animal; | ||
4 | import ch.epfl.maze.util.Direction; | ||
5 | import ch.epfl.maze.util.Vector2D; | ||
6 | |||
7 | /** | ||
8 | * Mouse A.I. that remembers only the previous choice it has made. | ||
9 | * | ||
10 | */ | ||
11 | |||
12 | public class Mouse extends Animal { | ||
13 | |||
14 | /** | ||
15 | * Constructs a mouse with a starting position. | ||
16 | * | ||
17 | * @param position | ||
18 | * Starting position of the mouse in the labyrinth | ||
19 | */ | ||
20 | |||
21 | public Mouse(Vector2D position) { | ||
22 | super(position); | ||
23 | } | ||
24 | |||
25 | /** | ||
26 | * Moves according to an improved version of a <i>random walk</i> : the | ||
27 | * mouse does not directly retrace its steps. | ||
28 | */ | ||
29 | |||
30 | @Override | ||
31 | public Direction move(Direction[] choices) { | ||
32 | // TODO | ||
33 | return Direction.NONE; | ||
34 | } | ||
35 | |||
36 | @Override | ||
37 | public Animal copy() { | ||
38 | // TODO | ||
39 | return null; | ||
40 | } | ||
41 | } | ||
diff --git a/src/ch/epfl/maze/physical/zoo/Panda.java b/src/ch/epfl/maze/physical/zoo/Panda.java new file mode 100644 index 0000000..73c7194 --- /dev/null +++ b/src/ch/epfl/maze/physical/zoo/Panda.java | |||
@@ -0,0 +1,43 @@ | |||
1 | package ch.epfl.maze.physical.zoo; | ||
2 | |||
3 | import ch.epfl.maze.physical.Animal; | ||
4 | import ch.epfl.maze.util.Direction; | ||
5 | import ch.epfl.maze.util.Vector2D; | ||
6 | |||
7 | /** | ||
8 | * Panda A.I. that implements Trémeaux's Algorithm. | ||
9 | * | ||
10 | */ | ||
11 | public class Panda extends Animal { | ||
12 | |||
13 | /** | ||
14 | * Constructs a panda with a starting position. | ||
15 | * | ||
16 | * @param position | ||
17 | * Starting position of the panda in the labyrinth | ||
18 | */ | ||
19 | |||
20 | public Panda(Vector2D position) { | ||
21 | super(position); | ||
22 | // TODO | ||
23 | } | ||
24 | |||
25 | /** | ||
26 | * Moves according to <i>Trémeaux's Algorithm</i>: when the panda | ||
27 | * moves, it will mark the ground at most two times (with two different | ||
28 | * colors). It will prefer taking the least marked paths. Special cases | ||
29 | * have to be handled, especially when the panda is at an intersection. | ||
30 | */ | ||
31 | |||
32 | @Override | ||
33 | public Direction move(Direction[] choices) { | ||
34 | // TODO | ||
35 | return Direction.NONE; | ||
36 | } | ||
37 | |||
38 | @Override | ||
39 | public Animal copy() { | ||
40 | // TODO | ||
41 | return null; | ||
42 | } | ||
43 | } | ||
diff --git a/src/ch/epfl/maze/physical/zoo/SpaceInvader.java b/src/ch/epfl/maze/physical/zoo/SpaceInvader.java new file mode 100644 index 0000000..0d8fb5d --- /dev/null +++ b/src/ch/epfl/maze/physical/zoo/SpaceInvader.java | |||
@@ -0,0 +1,52 @@ | |||
1 | package ch.epfl.maze.physical.zoo; | ||
2 | |||