-
Notifications
You must be signed in to change notification settings - Fork 0
/
TragicCritter.java
51 lines (42 loc) · 1.05 KB
/
TragicCritter.java
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
package assignment5;
//import project5.Critter.CritterShape;
public class TragicCritter extends Critter {
@Override
public String toString() { return "T"; }
public TragicCritter() {
Params.look_energy_cost = 0;
Params.walk_energy_cost = 0;
Params.run_energy_cost = 0;
Params.refresh_algae_count = 0;
}
public boolean fight(String not_used) { return true; }
@Override
public void doTimeStep() {
boolean moveFlag = true;
/* Move to where its kin is */
if(moveFlag) {
for (int dir = 0; dir < 8; dir++) {
if(this.look(dir, false) == null) {
walk(dir);
return;
}
if(this.look(dir, true) == null) {
run(dir);
return;
}
}
}
}
public String runStats(java.util.List<Critter> avoidingCritters) {
if(avoidingCritters.size() >= 2) {
return "Still can't get to each other";
}
else {
return "Collided, sadly";
}
}
@Override
public CritterShape viewShape() { return CritterShape.STAR; }
@Override
public javafx.scene.paint.Color viewOutlineColor() { return javafx.scene.paint.Color.CRIMSON; }
}