summaryrefslogtreecommitdiff
path: root/src/ch/epfl/maze/physical/stragegies/picker/CyclePicker.java
diff options
context:
space:
mode:
authorPacien TRAN-GIRARD2015-11-24 16:33:34 +0100
committerPacien TRAN-GIRARD2015-11-24 16:33:34 +0100
commit3f5c3d91a084233cfc77635697b3c537adbced74 (patch)
tree7c7f00a5024cbf3be2eaa6b746ccd48aea64f774 /src/ch/epfl/maze/physical/stragegies/picker/CyclePicker.java
parentfbbd459e2646870da9a96ce65e77bc090c2b9930 (diff)
downloadmaze-solver-3f5c3d91a084233cfc77635697b3c537adbced74.tar.gz
Refactor Monkey A.I.
Diffstat (limited to 'src/ch/epfl/maze/physical/stragegies/picker/CyclePicker.java')
-rw-r--r--src/ch/epfl/maze/physical/stragegies/picker/CyclePicker.java41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/ch/epfl/maze/physical/stragegies/picker/CyclePicker.java b/src/ch/epfl/maze/physical/stragegies/picker/CyclePicker.java
new file mode 100644
index 0000000..e1a969f
--- /dev/null
+++ b/src/ch/epfl/maze/physical/stragegies/picker/CyclePicker.java
@@ -0,0 +1,41 @@
1package ch.epfl.maze.physical.stragegies.picker;
2
3import ch.epfl.maze.util.Direction;
4
5import java.util.Set;
6
7/**
8 * A decision maker cycling in each Direction starting from a given one.
9 *
10 * @author Pacien TRAN-GIRARD
11 */
12public interface CyclePicker extends BlindPicker {
13
14 /**
15 * Returns the cycle starting Direction.
16 *
17 * @return The starting Direction
18 */
19 Direction getStartingDirection();
20
21 /**
22 * Returns the Rotation Direction.
23 *
24 * @return The Rotation Direction
25 */
26 Direction getRotationDirection();
27
28 @Override
29 default Direction pick(Set<Direction> choices) {
30 if (choices.isEmpty()) return FALLBACK_DIRECTION;
31 if (this.getStartingDirection() == Direction.NONE) return FALLBACK_DIRECTION;
32 if (this.getRotationDirection() == Direction.NONE) return FALLBACK_DIRECTION;
33
34 Direction dir = this.getStartingDirection();
35 while (!choices.contains(dir))
36 dir = dir.unRelativeDirection(this.getRotationDirection());
37
38 return dir;
39 }
40
41}