-
Notifications
You must be signed in to change notification settings - Fork 0
/
AlgaephobicCritter.java
52 lines (42 loc) · 1.05 KB
/
AlgaephobicCritter.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
52
package assignment5;
//import project5.Critter.CritterShape;
public class AlgaephobicCritter extends Critter {
@Override
public String toString() { return "S"; }
public AlgaephobicCritter() {
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 false; }
@Override
public void doTimeStep() {
/* Move to somewhere without algae */
for (int dir = 0; dir < 8; dir++) {
if(this.look(dir, false) == null) {
walk(dir);
return;
}
}
for (int dir = 0; dir < 8; dir++) {
if(this.look(dir, true) == null) {
run(dir);
return;
}
}
return;
}
public String runStats(java.util.List<Critter> avoidingCritters) {
if(avoidingCritters.size() != 0) {
return "So far so good";
}
else {
return "Algae suck";
}
}
@Override
public CritterShape viewShape() { return CritterShape.DIAMOND; }
@Override
public javafx.scene.paint.Color viewOutlineColor() { return javafx.scene.paint.Color.SALMON; }
}