package ch.epfl.maze.physical.zoo;
import ch.epfl.maze.physical.Animal;
import ch.epfl.maze.physical.stragegies.picker.RandomPicker;
import ch.epfl.maze.physical.stragegies.reducer.BackwardReducer;
import ch.epfl.maze.util.Direction;
import ch.epfl.maze.util.Vector2D;
import java.util.Set;
/**
* Mouse A.I. that remembers only the previous choice it has made.
*
* @author EPFL
* @author Pacien TRAN-GIRARD
*/
public class Mouse extends Animal implements BackwardReducer, RandomPicker {
/**
* Constructs a mouse with a starting position.
*
* @param position Starting position of the mouse in the labyrinth
*/
public Mouse(Vector2D position) {
super(position);
}
/**
* Moves according to an improved version of a random walk : the
* mouse does not directly retrace its steps.
*/
@Override
public Direction move(Set choices) {
Set smartChoices = choices.size() > 1 ? this.reduce(choices) : choices;
return this.pick(smartChoices);
}
@Override
public Animal copy() {
return new Mouse(this.getPosition());
}
}