package ch.epfl.maze.physical.stragegies.picker; import ch.epfl.maze.util.Direction; import java.util.ArrayList; import java.util.List; import java.util.Random; import java.util.Set; /** * A probabilistic decision maker. * * @author Pacien TRAN-GIRARD */ public interface RandomPicker extends BlindPicker { Random RANDOM_SOURCE = new Random(); @Override default Direction pick(Set choices) { if (choices.isEmpty()) return FALLBACK_DIRECTION; List choiceList = new ArrayList<>(choices); return choiceList.get(RANDOM_SOURCE.nextInt(choices.size())); } }