From fbbd459e2646870da9a96ce65e77bc090c2b9930 Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Tue, 24 Nov 2015 16:18:19 +0100 Subject: Refactor Hamster A.I. --- .../stragegies/reducer/BlindCaseReducer.java | 31 ++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 src/ch/epfl/maze/physical/stragegies/reducer/BlindCaseReducer.java (limited to 'src/ch/epfl/maze/physical/stragegies/reducer') 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 @@ +package ch.epfl.maze.physical.stragegies.reducer; + +import ch.epfl.maze.util.Direction; + +import java.util.Set; +import java.util.stream.Collectors; + +/** + * A blind reducer filtering possibilities case by case. + * + * @author Pacien TRAN-GIRARD + */ +public interface BlindCaseReducer extends BlindChoiceReducer { + + /** + * Checks if the given choice should be kept or excluded by the filter. + * + * @param choice A Direction + * @return T(The filter should keep the given choice) + */ + boolean keepChoice(Direction choice); + + @Override + default Set reduce(Set choices) { + return choices + .stream() + .filter(choice -> this.keepChoice(choice)) + .collect(Collectors.toSet()); + } + +} -- cgit v1.2.3