-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDetlefMaxwellOfDoomDue.java
More file actions
178 lines (148 loc) · 4.75 KB
/
Copy pathDetlefMaxwellOfDoomDue.java
File metadata and controls
178 lines (148 loc) · 4.75 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
package aquila;
import robocode.*;
import java.awt.Color;
/**
* DetlefMaxwellOfDoom - a robot by Dominik
*/
public class DetlefMaxwellOfDoomDue extends AdvancedRobot {
int round;
byte moveDir;
byte scanDir;
double min;
boolean borderCheck;
public void run() {
/*
setBodyColor(Color.green);
setGunColor(Color.black);
setRadarColor(Color.green);
setBulletColor(Color.yellow);
setScanColor(Color.red);
*/
//setAdjustRadarForGunTurn(true);
//setAdjustRadarForRobotTurn(true);
//setAdjustGunForRobotTurn(true);
min = 50;
moveDir = 1;
scanDir = 1;
round = 0;
// Robot main loop
while (true) {
borderControl();
setTurnRadarRight(360 * scanDir);
setAhead(min * moveDir);
execute();
//message("Round: " + round++);
}
}
public void onScannedRobot(ScannedRobotEvent e) {
changeColor();
double bearing = e.getBearing();
double distance = e.getDistance();
double heading = e.getHeading(); //Wozu?!
if (distance < 400) {
fireControl(bearing, distance);
}
scanDir *= -1;
goBroadside(bearing, distance);
}
public void goBroadside(double bearing, double distance) {
if (borderCheck == true) {
setTurnRight(bearing + min);
} else {
setTurnRight(bearing);
}
}
public void borderControl() {
double maxY = getBattleFieldHeight() - min;
double maxX = getBattleFieldWidth() - min;
//message("X: "+getX()+"Y: " + getY());
if ((getX() <= min || getY() <= min) || (getX() >= maxX || getY() >= maxY)) {
/*
double a = getX();
double b = getBattleFieldHeight() / 2;
double hypo = Math.sqrt(a*a+b*b);
double g = Math.sin(a/hypo);
setTurnRight(g);
setAhead(200 * moveDir);
*/
borderCheck = false;
} else {
borderCheck = true;
}
}
public void fireControl(double bearing, double distance) {
double heading = getHeading();
double gunheading = getGunHeading();
double x = heading + bearing + (gunheading * -1);
if (getGunHeat() == 0 && getEnergy() > 3) {
turnGunRight(x);
openFire(distance);
}
}
public void openFire(double distance) {
//message("Enemy under fire!");
short max = 250;
byte min = 20;
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) {
double bearing = e.getBearing();
fireControl(bearing, 300);
fuckYou(e.getName());
}
public void onHitWall(HitWallEvent e) {
moveDir *= -1;
}
public void onHitRobot(HitRobotEvent e) {
double bearing = e.getBearing();
fireControl(bearing, 15);
if (e.isMyFault() == false) {
moveDir *= -1;
setTurnRight(bearing);
}
}
public void onWin(WinEvent e) {
for (int i = 0; i < 50; i++) {
setTurnRadarLeft(3222);
setTurnGunRight(3689);
setTurnLeft(9222);
changeColor();
execute();
}
}
public void fuckYou(String name) {
String[] fuckyou = {"Fuck you ",
"I hate you ",
"You´r 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´r a randy old bugger, "
};
int rand = (int) (Math.random() * fuckyou.length);
message(fuckyou[rand] + name + "!!!");
}
public void message(String content) {
out.println(getName() + ": " + content);
}
public void changeColor() {
Color[] colours = {Color.green, Color.black, Color.blue, Color.cyan,
Color.darkGray, Color.gray, Color.magenta,
Color.orange, Color.pink, Color.red, Color.white, Color.yellow};
setColors(colours[(int) (Math.random() * colours.length)],
colours[(int) (Math.random() * colours.length)],
colours[(int) (Math.random() * colours.length)],
colours[(int) (Math.random() * colours.length)],
colours[(int) (Math.random() * colours.length)]);
}
}