summaryrefslogtreecommitdiff
path: root/src/ch/epfl
diff options
context:
space:
mode:
authorPacien TRAN-GIRARD2015-11-24 18:36:44 +0100
committerPacien TRAN-GIRARD2015-11-24 18:36:44 +0100
commit5a45593914a7f96f5d6dfe8526caa5dcc34ac16a (patch)
tree256c147e4ade4dd7545caab77a9cbfad8d7c86a7 /src/ch/epfl
parent7a71ddfd0a103abeab1280aa33583d28f7e8e756 (diff)
downloadmaze-solver-5a45593914a7f96f5d6dfe8526caa5dcc34ac16a.tar.gz
Add World-aware case reducer
Diffstat (limited to 'src/ch/epfl')
-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}