summaryrefslogtreecommitdiff
path: root/src/ch/epfl/maze
diff options
context:
space:
mode:
Diffstat (limited to 'src/ch/epfl/maze')
-rw-r--r--src/ch/epfl/maze/physical/DaedalusAware.java54
-rw-r--r--src/ch/epfl/maze/physical/Predator.java46
-rw-r--r--src/ch/epfl/maze/physical/Prey.java46
-rw-r--r--src/ch/epfl/maze/physical/stragegies/picker/BlindPicker.java4
-rw-r--r--src/ch/epfl/maze/physical/stragegies/picker/ChoicePicker.java11
-rw-r--r--src/ch/epfl/maze/physical/stragegies/reducer/BlindChoiceReducer.java4
-rw-r--r--src/ch/epfl/maze/physical/stragegies/reducer/CaseReducer.java12
-rw-r--r--src/ch/epfl/maze/physical/stragegies/reducer/ChoiceReducer.java8
8 files changed, 76 insertions, 109 deletions
diff --git a/src/ch/epfl/maze/physical/DaedalusAware.java b/src/ch/epfl/maze/physical/DaedalusAware.java
new file mode 100644
index 0000000..16f20ee
--- /dev/null
+++ b/src/ch/epfl/maze/physical/DaedalusAware.java
@@ -0,0 +1,54 @@
1package ch.epfl.maze.physical;
2
3import ch.epfl.maze.util.Direction;
4import ch.epfl.maze.util.Vector2D;
5
6import java.util.Arrays;
7import java.util.EnumSet;
8import java.util.Set;
9
10/**
11 * @author Pacien TRAN-GIRARD
12 */
13public interface DaedalusAware {
14
15 /**
16 * Retrieves the next direction of the animal, by selecting one choice among
17 * the ones available from its position.
18 * <p>
19 * In this variation, the animal knows the world entirely. It can therefore
20 * use the position of other animals in the daedalus to hunt or to evade predators
21 * more effectively.
22 *
23 * @param choices The choices left to the animal at its current position (see
24 * {@link ch.epfl.maze.physical.World#getChoices(Vector2D)
25 * World.getChoices(Vector2D)})
26 * @param daedalus The world in which the animal moves
27 * @return The next direction of the animal, chosen in {@code choices}
28 * @implNote Not abstract for compatibility purpose (in order not to break tests)
29 */
30 default Direction move(Set<Direction> choices, Daedalus daedalus) {
31 return null;
32 }
33
34 /**
35 * Retrieves the next direction of the animal, by selecting one choice among
36 * the ones available from its position.
37 * <p>
38 * In this variation, the animal knows the world entirely. It can therefore
39 * use the position of other animals in the daedalus to hunt or to evade predators
40 * more effectively.
41 *
42 * @param choices The choices left to the animal at its current position (see
43 * {@link ch.epfl.maze.physical.World#getChoices(Vector2D)
44 * World.getChoices(Vector2D)})
45 * @param daedalus The world in which the animal moves
46 * @return The next direction of the animal, chosen in {@code choices}
47 * @apiNote Not final for compatibility purpose (in order not to break tests)
48 * @deprecated Use @code{Direction move(Set<Direction> choices, Daedalus daedalus)} instead
49 */
50 default Direction move(Direction[] choices, Daedalus daedalus) {
51 return this.move(EnumSet.copyOf(Arrays.asList(choices)), daedalus);
52 }
53
54}
diff --git a/src/ch/epfl/maze/physical/Predator.java b/src/ch/epfl/maze/physical/Predator.java
index ad5900e..9cc7256 100644
--- a/src/ch/epfl/maze/physical/Predator.java
+++ b/src/ch/epfl/maze/physical/Predator.java
@@ -1,19 +1,14 @@
1package ch.epfl.maze.physical; 1package ch.epfl.maze.physical;
2 2
3import ch.epfl.maze.util.Direction;
4import ch.epfl.maze.util.Vector2D; 3import ch.epfl.maze.util.Vector2D;
5 4
6import java.util.Arrays;
7import java.util.EnumSet;
8import java.util.Set;
9
10/** 5/**
11 * Predator that kills a prey when they meet with each other in the labyrinth. 6 * Predator that kills a prey when they meet with each other in the labyrinth.
12 * 7 *
13 * @author EPFL 8 * @author EPFL
14 * @author Pacien TRAN-GIRARD 9 * @author Pacien TRAN-GIRARD
15 */ 10 */
16abstract public class Predator extends ProbabilisticAnimal { 11abstract public class Predator extends Animal implements DaedalusAware {
17 12
18 /** 13 /**
19 * Constructs a predator with a specified position. 14 * Constructs a predator with a specified position.
@@ -24,43 +19,4 @@ abstract public class Predator extends ProbabilisticAnimal {
24 super(position); 19 super(position);
25 } 20 }
26 21
27 /**
28 * Retrieves the next direction of the animal, by selecting one choice among
29 * the ones available from its position.
30 * <p>
31 * In this variation, the animal knows the world entirely. It can therefore
32 * use the position of other animals in the daedalus to hunt more
33 * effectively.
34 *
35 * @param choices The choices left to the animal at its current position (see
36 * {@link ch.epfl.maze.physical.World#getChoices(Vector2D)
37 * World.getChoices(Vector2D)})
38 * @param daedalus The world in which the animal moves
39 * @return The next direction of the animal, chosen in {@code choices}
40 * @implNote Not abstract for compatibility purpose (in order not to break tests)
41 */
42 public Direction move(Set<Direction> choices, Daedalus daedalus) {
43 return null;
44 }
45
46 /**
47 * Retrieves the next direction of the animal, by selecting one choice among
48 * the ones available from its position.
49 * <p>
50 * In this variation, the animal knows the world entirely. It can therefore
51 * use the position of other animals in the daedalus to hunt more
52 * effectively.
53 *
54 * @param choices The choices left to the animal at its current position (see
55 * {@link ch.epfl.maze.physical.World#getChoices(Vector2D)
56 * World.getChoices(Vector2D)})
57 * @param daedalus The world in which the animal moves
58 * @return The next direction of the animal, chosen in {@code choices}
59 * @apiNote Not final for compatibility purpose (in order not to break tests)
60 * @deprecated Use @code{Direction move(Set<Direction> choices, Daedalus daedalus)} instead
61 */
62 public Direction move(Direction[] choices, Daedalus daedalus) {
63 return this.move(EnumSet.copyOf(Arrays.asList(choices)), daedalus);
64 }
65
66} 22}
diff --git a/src/ch/epfl/maze/physical/Prey.java b/src/ch/epfl/maze/physical/Prey.java
index ff760c5..0ad62ff 100644
--- a/src/ch/epfl/maze/physical/Prey.java
+++ b/src/ch/epfl/maze/physical/Prey.java
@@ -1,19 +1,14 @@
1package ch.epfl.maze.physical; 1package ch.epfl.maze.physical;
2 2
3import ch.epfl.maze.util.Direction;
4import ch.epfl.maze.util.Vector2D; 3import ch.epfl.maze.util.Vector2D;
5 4
6import java.util.Arrays;
7import java.util.EnumSet;
8import java.util.Set;
9
10/** 5/**
11 * Prey that is killed by a predator when they meet each other in the labyrinth. 6 * Prey that is killed by a predator when they meet each other in the labyrinth.
12 * 7 *
13 * @author EPFL 8 * @author EPFL
14 * @author Pacien TRAN-GIRARD 9 * @author Pacien TRAN-GIRARD
15 */ 10 */
16abstract public class Prey extends ProbabilisticAnimal { 11abstract public class Prey extends Animal implements DaedalusAware {
17 12
18 /** 13 /**
19 * Constructs a prey with a specified position. 14 * Constructs a prey with a specified position.
@@ -24,43 +19,4 @@ abstract public class Prey extends ProbabilisticAnimal {
24 super(position); 19 super(position);
25 } 20 }
26 21
27 /**
28 * Retrieves the next direction of the animal, by selecting one choice among
29 * the ones available from its position.
30 * <p>
31 * In this variation, the animal knows the world entirely. It can therefore
32 * use the position of other animals in the daedalus to evade predators more
33 * effectively.
34 *
35 * @param choices The choices left to the animal at its current position (see
36 * {@link ch.epfl.maze.physical.World#getChoices(Vector2D)
37 * World.getChoices(Vector2D)})
38 * @param daedalus The world in which the animal moves
39 * @return The next direction of the animal, chosen in {@code choices}
40 * @implNote Not abstract for compatibility purpose (in order not to break tests)
41 */
42 public Direction move(Set<Direction> choices, Daedalus daedalus) {
43 return null;
44 }
45
46 /**
47 * Retrieves the next direction of the animal, by selecting one choice among
48 * the ones available from its position.
49 * <p>
50 * In this variation, the animal knows the world entirely. It can therefore
51 * use the position of other animals in the daedalus to evade predators more
52 * effectively.
53 *
54 * @param choices The choices left to the animal at its current position (see
55 * {@link ch.epfl.maze.physical.World#getChoices(Vector2D)
56 * World.getChoices(Vector2D)})
57 * @param daedalus The world in which the animal moves
58 * @return The next direction of the animal, chosen in {@code choices}
59 * @apiNote Not final for compatibility purpose (in order not to break tests)
60 * @deprecated Use @code{Direction move(Set<Direction> choices, Daedalus daedalus)} instead
61 */
62 public Direction move(Direction[] choices, Daedalus daedalus) {
63 return this.move(EnumSet.copyOf(Arrays.asList(choices)), daedalus);
64 }
65
66} 22}
diff --git a/src/ch/epfl/maze/physical/stragegies/picker/BlindPicker.java b/src/ch/epfl/maze/physical/stragegies/picker/BlindPicker.java
index 6dcf229..02cb1ef 100644
--- a/src/ch/epfl/maze/physical/stragegies/picker/BlindPicker.java
+++ b/src/ch/epfl/maze/physical/stragegies/picker/BlindPicker.java
@@ -1,6 +1,6 @@
1package ch.epfl.maze.physical.stragegies.picker; 1package ch.epfl.maze.physical.stragegies.picker;
2 2
3import ch.epfl.maze.physical.World; 3import ch.epfl.maze.physical.Daedalus;
4import ch.epfl.maze.util.Direction; 4import ch.epfl.maze.util.Direction;
5