summaryrefslogtreecommitdiff
path: root/src/ch/epfl/maze/physical/Prey.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/ch/epfl/maze/physical/Prey.java')
-rw-r--r--src/ch/epfl/maze/physical/Prey.java24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/ch/epfl/maze/physical/Prey.java b/src/ch/epfl/maze/physical/Prey.java
index 26fe92b..3654807 100644
--- a/src/ch/epfl/maze/physical/Prey.java
+++ b/src/ch/epfl/maze/physical/Prey.java
@@ -3,6 +3,10 @@ package ch.epfl.maze.physical;
3import ch.epfl.maze.util.Direction; 3import ch.epfl.maze.util.Direction;
4import ch.epfl.maze.util.Vector2D; 4import ch.epfl.maze.util.Vector2D;
5 5
6import java.util.Arrays;
7import java.util.EnumSet;
8import java.util.Set;
9
6/** 10/**
7 * Prey that is killed by a predator when they meet each other in the labyrinth. 11 * Prey that is killed by a predator when they meet each other in the labyrinth.
8 * 12 *
@@ -34,6 +38,24 @@ abstract public class Prey extends ProbabilisticAnimal {
34 * @param daedalus The world in which the animal moves 38 * @param daedalus The world in which the animal moves
35 * @return The next direction of the animal, chosen in {@code choices} 39 * @return The next direction of the animal, chosen in {@code choices}
36 */ 40 */
37 abstract public Direction move(Direction[] choices, Daedalus daedalus); 41 abstract public Direction move(Set<Direction> choices, Daedalus daedalus);
42
43 /**
44 * Retrieves the next direction of the animal, by selecting one choice among
45 * the ones available from its position.
46 * <p>
47 * In this variation, the animal knows the world entirely. It can therefore
48 * use the position of other animals in the daedalus to evade predators more
49 * effectively.
50 *
51 * @param choices The choices left to the animal at its current position (see
52 * {@link ch.epfl.maze.physical.World#getChoices(Vector2D)
53 * World.getChoices(Vector2D)})
54 * @param daedalus The world in which the animal moves
55 * @return The next direction of the animal, chosen in {@code choices}
56 */
57 public final Direction move(Direction[] choices, Daedalus daedalus) {
58 return this.move(EnumSet.copyOf(Arrays.asList(choices)), daedalus);
59 }
38 60
39} 61}