-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCyberCapivara.java
41 lines (30 loc) · 1.09 KB
/
CyberCapivara.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
package CyberCapivara;
import robocode.*;
import java.awt.Color;
import robocode.util.Utils;
public class CyberCapivara extends AdvancedRobot {
public void run() {
setColors(Color.yellow, Color.yellow, Color.yellow, Color.yellow, Color.yellow);
setAdjustRadarForRobotTurn(true);
setAdjustGunForRobotTurn(true);
while(true) {
turnRadarRightRadians(Double.POSITIVE_INFINITY);
}
}
public void onScannedRobot(ScannedRobotEvent e) {
double absoluteBearing = getHeadingRadians() + e.getBearingRadians();
double distance = e.getDistance();
setBackAsFront(distance < 200 ? -1 : 1);
setTurnGunRightRadians(Utils.normalRelativeAngle(absoluteBearing - getGunHeadingRadians()));
if (Math.abs(getGunTurnRemaining()) < 10) {
setFire(3);
}
}
public void onHitWall(HitWallEvent e) {
setBackAsFront(-1);
}
void setBackAsFront(int direction) {
setTurnRightRadians(Math.tan(direction));
setAhead(Double.POSITIVE_INFINITY * direction);
}
}