summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ch/epfl/maze/physical/stragegies/reducer/CaseReducer.java33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/ch/epfl/maze/physical/stragegies/reducer/CaseReducer.java b/src/ch/epfl/maze/physical/stragegies/reducer/CaseReducer.java
new file mode 100644
index 0000000..837bd4b
--- /dev/null
+++ b/src/ch/epfl/maze/physical/stragegies/reducer/CaseReducer.java
@@ -0,0 +1,33 @@
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;
7import java.util.stream.Collectors;
8
9/**
10 * A filter reducer filtering possibilities case by case.
11 *
12 * @author Pacien TRAN-GIRARD
13 */
14public interface CaseReducer extends ChoiceReducer {
15
16 /**
17 * Checks if the given choice should be kept or excluded by the filter.
18 *
19 * @param choice A Direction
20 * @param world The World
21 * @return T(The filter should keep the given choice)
22 */
23 boolean keepChoice(Direction choice, World world);
24
25 @Override
26 default Set<Direction> reduce(Set<Direction> choices, World world) {
27 return choices
28 .stream()
29 .filter(choice -> this.keepChoice(choice, world))
30 .collect(Collectors.toSet());
31 }
32
33}