blob: ad5900e4a7a160dd82384b02e0eb19a3f37ab5ba (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
package ch.epfl.maze.physical;
import ch.epfl.maze.util.Direction;
import ch.epfl.maze.util.Vector2D;
import java.util.Arrays;
import java.util.EnumSet;
import java.util.Set;
/**
* Predator that kills a prey when they meet with each other in the labyrinth.
*
* @author EPFL
* @author Pacien TRAN-GIRARD
*/
abstract public class Predator extends ProbabilisticAnimal {
/**
* Constructs a predator with a specified position.
*
* @param position Position of the predator in the labyrinth
*/
public Predator(Vector2D position) {
super(position);
}
/**
* Retrieves the next direction of the animal, by selecting one choice among
* the ones available from its position.
* <p>
* In this variation, the animal knows the world entirely. It can therefore
* use the position of other animals in the daedalus to hunt more
* effectively.
*
* @param choices The choices left to the animal at its current position (see
* {@link ch.epfl.maze.physical.World#getChoices(Vector2D)
* World.getChoices(Vector2D)})
* @param daedalus The world in which the animal moves
* @return The next direction of the animal, chosen in {@code choices}
* @implNote Not abstract for compatibility purpose (in order not to break tests)
*/
public Direction move(Set<Direction> choices, Daedalus daedalus) {
return null;
}
/**
* Retrieves the next direction of the animal, by selecting one choice among
* the ones available from its position.
* <p>
* In this variation, the animal knows the world entirely. It can therefore
* use the position of other animals in the daedalus to hunt more
* effectively.
*
* @param choices The choices left to the animal at its current position (see
* {@link ch.epfl.maze.physical.World#getChoices(Vector2D)
* World.getChoices(Vector2D)})
* @param daedalus The world in which the animal moves
* @return The next direction of the animal, chosen in {@code choices}
* @apiNote Not final for compatibility purpose (in order not to break tests)
* @deprecated Use @code{Direction move(Set<Direction> choices, Daedalus daedalus)} instead
*/
public Direction move(Direction[] choices, Daedalus daedalus) {
return this.move(EnumSet.copyOf(Arrays.asList(choices)), daedalus);
}
}
|