diff options
author | Pacien TRAN-GIRARD | 2015-11-24 18:36:44 +0100 |
---|---|---|
committer | Pacien TRAN-GIRARD | 2015-11-24 18:36:44 +0100 |
commit | 5a45593914a7f96f5d6dfe8526caa5dcc34ac16a (patch) | |
tree | 256c147e4ade4dd7545caab77a9cbfad8d7c86a7 /src/ch/epfl/maze | |
parent | 7a71ddfd0a103abeab1280aa33583d28f7e8e756 (diff) | |
download | maze-solver-5a45593914a7f96f5d6dfe8526caa5dcc34ac16a.tar.gz |
Add World-aware case reducer
Diffstat (limited to 'src/ch/epfl/maze')
-rw-r--r-- | src/ch/epfl/maze/physical/stragegies/reducer/CaseReducer.java | 33 |
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 @@ | |||
1 | package ch.epfl.maze.physical.stragegies.reducer; | ||
2 | |||
3 | import ch.epfl.maze.physical.World; | ||
4 | import ch.epfl.maze.util.Direction; | ||
5 | |||
6 | import java.util.Set; | ||
7 | import java.util.stream.Collectors; | ||
8 | |||
9 | /** | ||
10 | * A filter reducer filtering possibilities case by case. | ||
11 | * | ||
12 | * @author Pacien TRAN-GIRARD | ||
13 | */ | ||
14 | public 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 | } | ||