-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSAM.java
More file actions
86 lines (70 loc) · 2.07 KB
/
Copy pathSAM.java
File metadata and controls
86 lines (70 loc) · 2.07 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
package aquila;
import robocode.*;
import java.awt.Color;
public class SAM extends AdvancedRobot {
byte dirRadar = 1;
byte dirDrive = 1;
public void run() {
while (true) {
turnRadarRight(45 * dirRadar);
setAhead(100 * dirDrive);
execute();
}
}
public void onScannedRobot(ScannedRobotEvent e) {
dirRadar *= -1;
double bearing = e.getBearing();
double distance = e.getDistance();
//double heading = e.getHeading();
if (distance < 320) {
fireControl(bearing, distance);
}
}
public void fireControl(double bearing, double distance) {
double heading = getHeading();
double gunheading = getGunHeading();
double x = heading + bearing + (gunheading * -1);
if (getGunHeat() == 0 && getEnergy() > 5) {
turnGunRight(x);
openFire(distance);
}
}
public void openFire(double distance) {
//message("Open fire!");
short max = 250;
byte min = 35;
if (distance > max) {
fire(1.5);
}
if ((distance >= min) && (distance <= max)) {
fire(2.5);
}
if (distance <= min) {
fire(Rules.MAX_BULLET_POWER);
}
}
public void onHitByBullet(HitByBulletEvent e) {
fuckYou(e.getName());
}
public void onHitRobot(HitRobotEvent e) {
dirDrive *= -1;
fuckYou(e.getName());
}
public void onHitWall(HitWallEvent e) {
dirDrive *= -1;
}
public void fuckYou(String name) {
String[] fuckyou = {"Fuck you ",
"I hate you ",
"You´re a piece of shit, ",
"You are worthless trash",
"Candy Ass ",
"Hit the road, ",
"Eat my shorts, ",
"You've got the brains of a doughnut, ",
"You´re a randy old bugger, "
};
int rand = (int) (Math.random() * fuckyou.length);
message(fuckyou[rand] + name + "!!!");
}
}