diff options
author | Pacien TRAN-GIRARD | 2015-11-24 17:57:23 +0100 |
---|---|---|
committer | Pacien TRAN-GIRARD | 2015-11-24 17:57:23 +0100 |
commit | 9bec90d20c20b01e94a8b5d8364bbe60f9687f05 (patch) | |
tree | 69056ce67731922d41505e8e684b890f7942db31 /src/ch/epfl/maze/physical/stragegies | |
parent | 96932b453e3f2fa1cfb45e79aca49e72d7b8d10f (diff) | |
download | maze-solver-9bec90d20c20b01e94a8b5d8364bbe60f9687f05.tar.gz |
Refactor Bear A.I.
Diffstat (limited to 'src/ch/epfl/maze/physical/stragegies')
-rw-r--r-- | src/ch/epfl/maze/physical/stragegies/picker/CyclePicker.java | 21 |
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 | } |