-
Notifications
You must be signed in to change notification settings - Fork 0
/
HackerElite.java
58 lines (49 loc) · 971 Bytes
/
HackerElite.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
53
54
55
56
57
58
import robocode.*;
import robocode.HitRobotEvent;
import robocode.ScannedRobotEvent;
import java.awt.*;
//import java.awt.Color;
// API help : http://robocode.sourceforge.net/docs/robocode/robocode/Robot.html
/**
* HackerElite - a robot by (your name here)
*/
public class HackerElite extends CharlieBot
{
public void run() {
setBodyColor(Color.blue);
setGunColor(Color.blue);
setRadarColor(Color.black);
setScanColor(Color.yellow);
while(true) {
ahead(10);
}
}
public void onHitByBullet(HitByBulletEvent e)
{
for(int i=0;i<50;i++)
{
fire(2);
}
}
public void onRobotDetected(ScannedRobotEvent e)
{
scan();
ahead(150);
fire(3);
}
public void onHitRobot(HitRobotEvent e)
{
if (e.getBearing() > -10 && e.getBearing() < 10) {
fire(3);
}
if (e.isMyFault()) {
turnRight(10);
}
}
public void onHitWall(HitWallEvent e) {
if (e.getBearing() > -10 && e.getBearing() < 10) {
turnRight(150);
}
turnRight(15);
}
}