summaryrefslogtreecommitdiff
path: root/src/ch/epfl/maze/physical/stragegies/reducer
diff options
context:
space:
mode:
authorPacien TRAN-GIRARD2015-11-24 16:18:19 +0100
committerPacien TRAN-GIRARD2015-11-24 16:18:19 +0100
commitfbbd459e2646870da9a96ce65e77bc090c2b9930 (patch)
tree2c156e920c5fccd2cd10d3a4725a303fa6f59f93 /src/ch/epfl/maze/physical/stragegies/reducer
parent33e497e3083c8446588244c1fa9e69f70af05664 (diff)
downloadmaze-solver-fbbd459e2646870da9a96ce65e77bc090c2b9930.tar.gz
Refactor Hamster A.I.
Diffstat (limited to 'src/ch/epfl/maze/physical/stragegies/reducer')
-rw-r--r--src/ch/epfl/maze/physical/stragegies/reducer/BlindCaseReducer.java31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/ch/epfl/maze/physical/stragegies/reducer/BlindCaseReducer.java b/src/ch/epfl/maze/physical/stragegies/reducer/BlindCaseReducer.java
new file mode 100644
index 0000000..b359cc2
--- /dev/null
+++ b/src/ch/epfl/maze/physical/stragegies/reducer/BlindCaseReducer.java
@@ -0,0 +1,31 @@
1package ch.epfl.maze.physical.stragegies.reducer;
2
3import ch.epfl.maze.util.Direction;
4
5import java.util.Set;
6import java.util.stream.Collectors;
7
8/**
9 * A blind reducer filtering possibilities case by case.
10 *
11 * @author Pacien TRAN-GIRARD
12 */
13public interface BlindCaseReducer extends BlindChoiceReducer {
14
15 /**
16 * Checks if the given choice should be kept or excluded by the filter.
17 *
18 * @param choice A Direction
19 * @return T(The filter should keep the given choice)
20 */
21 boolean keepChoice(Direction choice);
22
23 @Override
24 default Set<Direction> reduce(Set<Direction> choices) {
25 return choices
26 .stream()
27 .filter(choice -> this.keepChoice(choice))
28 .collect(Collectors.toSet());
29 }
30
31}