summaryrefslogtreecommitdiff
path: root/src/ch/epfl/maze/physical/stragegies/picker/CyclePicker.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/ch/epfl/maze/physical/stragegies/picker/CyclePicker.java')
-rw-r--r--src/ch/epfl/maze/physical/stragegies/picker/CyclePicker.java21
1 files changed, 21 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
index e1a969f..efa3794 100644
--- a/src/ch/epfl/maze/physical/stragegies/picker/CyclePicker.java
+++ b/src/ch/epfl/maze/physical/stragegies/picker/CyclePicker.java
@@ -38,4 +38,25 @@ public interface CyclePicker extends BlindPicker {
38 return dir; 38 return dir;
39 } 39 }
40 40
41 /**
42 * Counts the number of rotations to rotates to the given Direction
43 *
44 * @param direction The Direction
45 * @return The number of rotations
46 */
47 default int countRotations(Direction direction) {
48 if (direction == Direction.NONE) return 0;
49 if (this.getStartingDirection() == Direction.NONE) return 0;
50 if (this.getRotationDirection() == Direction.NONE) return 0;
51
52 Direction dir = this.getStartingDirection();
53 int counter = 0;
54 while (dir != direction) {
55 dir = dir.unRelativeDirection(this.getRotationDirection());
56 counter += 1;
57 }
58
59 return counter;
60 }
61
41} 62}