summaryrefslogtreecommitdiff
path: root/src/ch/epfl/maze/physical/stragegies/picker/RandomPicker.java
diff options
context:
space:
mode:
authorPacien TRAN-GIRARD2015-11-24 15:23:36 +0100
committerPacien TRAN-GIRARD2015-11-24 15:37:19 +0100
commit33e497e3083c8446588244c1fa9e69f70af05664 (patch)
tree3ef665e3c9478f196bb6d61dd15a71c0a9919216 /src/ch/epfl/maze/physical/stragegies/picker/RandomPicker.java
parent6f2f503bbf75901273376c8c009a6b96886650c8 (diff)
downloadmaze-solver-33e497e3083c8446588244c1fa9e69f70af05664.tar.gz
Refactor Mouse strategy
Diffstat (limited to 'src/ch/epfl/maze/physical/stragegies/picker/RandomPicker.java')
-rw-r--r--src/ch/epfl/maze/physical/stragegies/picker/RandomPicker.java27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/ch/epfl/maze/physical/stragegies/picker/RandomPicker.java b/src/ch/epfl/maze/physical/stragegies/picker/RandomPicker.java
new file mode 100644
index 0000000..427c0eb
--- /dev/null
+++ b/src/ch/epfl/maze/physical/stragegies/picker/RandomPicker.java
@@ -0,0 +1,27 @@
1package ch.epfl.maze.physical.stragegies.picker;
2
3import ch.epfl.maze.util.Direction;
4
5import java.util.ArrayList;
6import java.util.List;
7import java.util.Random;
8import java.util.Set;
9
10/**
11 * A probabilistic decision maker.
12 *
13 * @author Pacien TRAN-GIRARD
14 */
15public interface RandomPicker extends BlindPicker {
16
17 Random RANDOM_SOURCE = new Random();
18
19 @Override
20 default Direction pick(Set<Direction> choices) {
21 if (choices.isEmpty()) return FALLBACK_DIRECTION;
22
23 List<Direction> choiceList = new ArrayList<>(choices);
24 return choiceList.get(RANDOM_SOURCE.nextInt(choices.size()));
25 }
26
27}