summaryrefslogtreecommitdiff
path: root/src/ch/epfl/maze/physical/stragegies/reducer
diff options
context:
space:
mode:
Diffstat (limited to 'src/ch/epfl/maze/physical/stragegies/reducer')
-rw-r--r--src/ch/epfl/maze/physical/stragegies/reducer/BackwardReducer.java22
-rw-r--r--src/ch/epfl/maze/physical/stragegies/reducer/BlindChoiceReducer.java20
-rw-r--r--src/ch/epfl/maze/physical/stragegies/reducer/ChoiceReducer.java34
3 files changed, 76 insertions, 0 deletions
diff --git a/src/ch/epfl/maze/physical/stragegies/reducer/BackwardReducer.java b/src/ch/epfl/maze/physical/stragegies/reducer/BackwardReducer.java
new file mode 100644
index 0000000..4ef2ff8
--- /dev/null
+++ b/src/ch/epfl/maze/physical/stragegies/reducer/BackwardReducer.java
@@ -0,0 +1,22 @@
1package ch.epfl.maze.physical.stragegies.reducer;
2
3import ch.epfl.maze.util.Direction;
4
5import java.util.Set;
6
7/**
8 * A filter removing the possibility to go backward.
9 *
10 * @author Pacien TRAN-GIRARD
11 */
12public interface BackwardReducer extends BlindChoiceReducer {
13
14 Direction getDirection();
15
16 @Override
17 default Set<Direction> reduce(Set<Direction> choices) {
18 choices.remove(this.getDirection().reverse());
19 return choices;
20 }
21
22}
diff --git a/src/ch/epfl/maze/physical/stragegies/reducer/BlindChoiceReducer.java b/src/ch/epfl/maze/physical/stragegies/reducer/BlindChoiceReducer.java
new file mode 100644
index 0000000..169a8f6
--- /dev/null
+++ b/src/ch/epfl/maze/physical/stragegies/reducer/BlindChoiceReducer.java
@@ -0,0 +1,20 @@
1package ch.epfl.maze.physical.stragegies.reducer;
2
3import ch.epfl.maze.physical.World;
4import ch.epfl.maze.util.Direction;
5
6import java.util.Set;
7
8/**
9 * A decision filter unaware of its distant environment.
10 *
11 * @author Pacien TRAN-GIRARD
12 */
13public interface BlindChoiceReducer extends ChoiceReducer {
14
15 @Override
16 default Set<Direction> reduce(Set<Direction> choices, World world) {
17 return this.reduce(choices);
18 }
19
20}
diff --git a/src/ch/epfl/maze/physical/stragegies/reducer/ChoiceReducer.java b/src/ch/epfl/maze/physical/stragegies/reducer/ChoiceReducer.java
new file mode 100644
index 0000000..3cb744d
--- /dev/null
+++ b/src/ch/epfl/maze/physical/stragegies/reducer/ChoiceReducer.java
@@ -0,0 +1,34 @@
1package ch.epfl.maze.physical.stragegies.reducer;
2
3import ch.epfl.maze.physical.World;
4import ch.epfl.maze.util.Direction;
5import ch.epfl.maze.util.Vector2D;
6
7import java.util.Set;
8
9/**
10 * A choice filter that can exclude choices.
11 *
12 * @author Pacien TRAN-GIRARD
13 */
14public interface ChoiceReducer {
15
16 /**
17 * Reduces the Direction choices by eliminating the improper ones from the given choices.
18 *
19 * @param choices The choices left to the animal
20 * @return A subset of possible direction of the animal, chosen in {@code choices}
21 */
22 Set<Direction> reduce(Set<Direction> choices);
23
24 /**
25 * Reduces the Direction choices by eliminating the improper ones from the given choices.
26 * In this variation, the animal knows the world entirely. It can therefore
27 * use the position of other animals in the world to move more effectively.
28 *
29 * @param choices The choices left to the animal
30 * @return A subset of possible direction of the animal, chosen in {@code choices}
31 */
32 Set<Direction> reduce(Set<Direction> choices, World world);
33
34}