diff options
author | Pacien TRAN-GIRARD | 2015-11-24 16:18:19 +0100 |
---|---|---|
committer | Pacien TRAN-GIRARD | 2015-11-24 16:18:19 +0100 |
commit | fbbd459e2646870da9a96ce65e77bc090c2b9930 (patch) | |
tree | 2c156e920c5fccd2cd10d3a4725a303fa6f59f93 /src/ch/epfl/maze/physical/stragegies/reducer | |
parent | 33e497e3083c8446588244c1fa9e69f70af05664 (diff) | |
download | maze-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.java | 31 |
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 @@ | |||
1 | package ch.epfl.maze.physical.stragegies.reducer; | ||
2 | |||
3 | import ch.epfl.maze.util.Direction; | ||
4 | |||
5 | import java.util.Set; | ||
6 | import java.util.stream.Collectors; | ||
7 | |||
8 | /** | ||
9 | * A blind reducer filtering possibilities case by case. | ||
10 | * | ||
11 | * @author Pacien TRAN-GIRARD | ||
12 | */ | ||
13 | public 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 | } | ||