-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNinjaCat.java
More file actions
29 lines (25 loc) · 749 Bytes
/
NinjaCat.java
File metadata and controls
29 lines (25 loc) · 749 Bytes
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
import java.awt.*;
import java.util.Random;
public class NinjaCat extends Critter {
public NinjaCat() {
}
public Action getMove(CritterInfo info) {
if (info.getFront() == Neighbor.OTHER) { return Action.INFECT; }
else if ((info.getFront() == Neighbor.WALL) || (info.getFront() == Neighbor.SAME)) {
Random r = new Random();
int scan = r.nextInt(2);
if (scan == 0) {
return Action.LEFT;
} else {
return Action.RIGHT;
}
}
else { return Action.HOP; }
}
public Color getColor() {
return Color.BLACK;
}
public String toString() {
return "^.^";
}
}