summaryrefslogtreecommitdiff
path: root/src/ch/epfl/maze/physical/stragegies
diff options
context:
space:
mode:
authorPacien TRAN-GIRARD2015-11-24 21:56:22 +0100
committerPacien TRAN-GIRARD2015-11-24 21:56:22 +0100
commitf312719bf9df140a22406a4e40c5221a86cd8073 (patch)
tree06af4c01044096b6d2a5578d4f6b166d77384e07 /src/ch/epfl/maze/physical/stragegies
parentbe641348b8d677b3d9cdc0db90804edb0c46a3dc (diff)
downloadmaze-solver-f312719bf9df140a22406a4e40c5221a86cd8073.tar.gz
Refactor Daedalus residence
Diffstat (limited to 'src/ch/epfl/maze/physical/stragegies')
-rw-r--r--src/ch/epfl/maze/physical/stragegies/picker/BlindPicker.java4
-rw-r--r--src/ch/epfl/maze/physical/stragegies/picker/ChoicePicker.java11
-rw-r--r--src/ch/epfl/maze/physical/stragegies/reducer/BlindChoiceReducer.java4
-rw-r--r--src/ch/epfl/maze/physical/stragegies/reducer/CaseReducer.java12
-rw-r--r--src/ch/epfl/maze/physical/stragegies/reducer/ChoiceReducer.java8
5 files changed, 20 insertions, 19 deletions
diff --git a/src/ch/epfl/maze/physical/stragegies/picker/BlindPicker.java b/src/ch/epfl/maze/physical/stragegies/picker/BlindPicker.java
index 6dcf229..02cb1ef 100644
--- a/src/ch/epfl/maze/physical/stragegies/picker/BlindPicker.java
+++ b/src/ch/epfl/maze/physical/stragegies/picker/BlindPicker.java
@@ -1,6 +1,6 @@
1package ch.epfl.maze.physical.stragegies.picker; 1package ch.epfl.maze.physical.stragegies.picker;
2 2
3import ch.epfl.maze.physical.World; 3import ch.epfl.maze.physical.Daedalus;
4import ch.epfl.maze.util.Direction; 4import ch.epfl.maze.util.Direction;
5 5
6import java.util.Set; 6import java.util.Set;
@@ -13,7 +13,7 @@ import java.util.Set;
13public interface BlindPicker extends ChoicePicker { 13public interface BlindPicker extends ChoicePicker {
14 14
15 @Override 15 @Override
16 default Direction pick(Set<Direction> choices, World world) { 16 default Direction pick(Set<Direction> choices, Daedalus daedalus) {
17 return this.pick(choices); 17 return this.pick(choices);
18 } 18 }
19 19
diff --git a/src/ch/epfl/maze/physical/stragegies/picker/ChoicePicker.java b/src/ch/epfl/maze/physical/stragegies/picker/ChoicePicker.java
index 76fe3eb..756c446 100644
--- a/src/ch/epfl/maze/physical/stragegies/picker/ChoicePicker.java
+++ b/src/ch/epfl/maze/physical/stragegies/picker/ChoicePicker.java
@@ -1,5 +1,6 @@
1package ch.epfl.maze.physical.stragegies.picker; 1package ch.epfl.maze.physical.stragegies.picker;
2 2
3import ch.epfl.maze.physical.Daedalus;
3import ch.epfl.maze.physical.World; 4import ch.epfl.maze.physical.World;
4import ch.epfl.maze.util.Direction; 5import ch.epfl.maze.util.Direction;
5import ch.epfl.maze.util.Vector2D; 6import ch.epfl.maze.util.Vector2D;
@@ -33,12 +34,12 @@ public interface ChoicePicker {
33 * In this variation, the animal knows the world entirely. It can therefore 34 * In this variation, the animal knows the world entirely. It can therefore
34 * use the position of other animals in the daedalus to move more effectively. 35 * use the position of other animals in the daedalus to move more effectively.
35 * 36 *
36 * @param choices The choices left to the animal at its current position (see 37 * @param choices The choices left to the animal at its current position (see
37 * {@link ch.epfl.maze.physical.World#getChoices(Vector2D) 38 * {@link World#getChoices(Vector2D)
38 * World.getChoices(Vector2D)}) 39 * World.getChoices(Vector2D)})
39 * @param world The world in which the animal moves 40 * @param daedalus The daedalus in which the animal moves
40 * @return The next direction of the animal, chosen in {@code choices} 41 * @return The next direction of the animal, chosen in {@code choices}
41 */ 42 */
42 Direction pick(Set<Direction> choices, World world); 43 Direction pick(Set<Direction> choices, Daedalus daedalus);
43 44
44} 45}
diff --git a/src/ch/epfl/maze/physical/stragegies/reducer/BlindChoiceReducer.java b/src/ch/epfl/maze/physical/stragegies/reducer/BlindChoiceReducer.java
index 169a8f6..2e8a198 100644
--- a/src/ch/epfl/maze/physical/stragegies/reducer/BlindChoiceReducer.java
+++ b/src/ch/epfl/maze/physical/stragegies/reducer/BlindChoiceReducer.java
@@ -1,6 +1,6 @@
1package ch.epfl.maze.physical.stragegies.reducer; 1package ch.epfl.maze.physical.stragegies.reducer;
2 2
3import ch.epfl.maze.physical.World; 3import ch.epfl.maze.physical.Daedalus;
4import ch.epfl.maze.util.Direction; 4import ch.epfl.maze.util.Direction;
5 5
6import java.util.Set; 6import java.util.Set;
@@ -13,7 +13,7 @@ import java.util.Set;
13public interface BlindChoiceReducer extends ChoiceReducer { 13public interface BlindChoiceReducer extends ChoiceReducer {
14 14
15 @Override 15 @Override
16 default Set<Direction> reduce(Set<Direction> choices, World world) { 16 default Set<Direction> reduce(Set<Direction> choices, Daedalus daedalus) {
17 return this.reduce(choices); 17 return this.reduce(choices);
18 } 18 }
19 19
diff --git a/src/ch/epfl/maze/physical/stragegies/reducer/CaseReducer.java b/src/ch/epfl/maze/physical/stragegies/reducer/CaseReducer.java
index 837bd4b..71de287 100644
--- a/src/ch/epfl/maze/physical/stragegies/reducer/CaseReducer.java
+++ b/src/ch/epfl/maze/physical/stragegies/reducer/CaseReducer.java
@@ -1,6 +1,6 @@
1package ch.epfl.maze.physical.stragegies.reducer; 1package ch.epfl.maze.physical.stragegies.reducer;
2 2
3import ch.epfl.maze.physical.World; 3import ch.epfl.maze.physical.Daedalus;
4import ch.epfl.maze.util.Direction; 4import ch.epfl.maze.util.Direction;
5 5
6import java.util.Set; 6import java.util.Set;
@@ -16,17 +16,17 @@ public interface CaseReducer extends ChoiceReducer {
16 /** 16 /**
17 * Checks if the given choice should be kept or excluded by the filter. 17 * Checks if the given choice should be kept or excluded by the filter.
18 * 18 *
19 * @param choice A Direction 19 * @param choice A Direction
20 * @param world The World 20 * @param daedalus The Daedalus
21 * @return T(The filter should keep the given choice) 21 * @return T(The filter should keep the given choice)
22 */ 22 */
23 boolean keepChoice(Direction choice, World world); 23 boolean keepChoice(Direction choice, Daedalus daedalus);
24 24
25 @Override 25 @Override
26 default Set<Direction> reduce(Set<Direction> choices, World world) { 26 default Set<Direction> reduce(Set<Direction> choices, Daedalus daedalus) {
27 return choices 27 return choices
28 .stream() 28 .stream()
29 .filter(choice -> this.keepChoice(choice, world)) 29 .filter(choice -> this.keepChoice(choice, daedalus))
30 .collect(Collectors.toSet()); 30 .collect(Collectors.toSet());
31 } 31 }
32 32
diff --git a/src/ch/epfl/maze/physical/stragegies/reducer/ChoiceReducer.java b/src/ch/epfl/maze/physical/stragegies/reducer/ChoiceReducer.java
index 3cb744d..c7e8833 100644
--- a/src/ch/epfl/maze/physical/stragegies/reducer/ChoiceReducer.java
+++ b/src/ch/epfl/maze/physical/stragegies/reducer/ChoiceReducer.java
@@ -1,8 +1,7 @@
1package ch.epfl.maze.physical.stragegies.reducer; 1package ch.epfl.maze.physical.stragegies.reducer;
2 2
3import ch.epfl.maze.physical.World; 3import ch.epfl.maze.physical.Daedalus;
4import ch.epfl.maze.util.Direction; 4import ch.epfl.maze.util.Direction;
5import ch.epfl.maze.util.Vector2D;
6 5
7import java.util.Set; 6import java.util.Set;
8 7
@@ -26,9 +25,10 @@ public interface ChoiceReducer {
26 * In this variation, the animal knows the world entirely. It can therefore 25 * In this variation, the animal knows the world entirely. It can therefore
27 * use the position of other animals in the world to move more effectively. 26 * use the position of other animals in the world to move more effectively.
28 * 27 *
29 * @param choices The choices left to the animal 28 * @param choices The choices left to the animal
29 * @param daedalus The daedalus in which the animal moves
30 * @return A subset of possible direction of the animal, chosen in {@code choices} 30 * @return A subset of possible direction of the animal, chosen in {@code choices}
31 */ 31 */
32 Set<Direction> reduce(Set<Direction> choices, World world); 32 Set<Direction> reduce(Set<Direction> choices, Daedalus daedalus);
33 33
34} 34}