-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gozi.java
78 lines (69 loc) · 1.74 KB
/
Gozi.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package GO;
import robocode.*;
import java.awt.Color;
//import java.awt.Color;
// API help : http://robocode.sourceforge.net/docs/robocode/robocode/Robot.html
/**
* Gozi - a robot by (your name here)
*/
public class Gozi extends Robot
{
/**
* run: Gozi's default behavior
*/
public void run() {
// Initialization of the robot should be put here
// After trying out your robot, try uncommenting the import at the top,
// and the next line:
// setColors(Color.red,Color.blue,Color.green); // body,gun,radar
setColors(Color.blue, Color.red, Color.gray, Color.black, Color.blue);
// Robot main loop
while(true) {
// Replace the next 4 lines with any behavior you would like
ahead(100);
scan();
turnGunRight(360);
back(100);
scan();
turnGunRight(360);
}
}
/**
* onScannedRobot: What to do when you see another robot
*/
public void onScannedRobot(ScannedRobotEvent e) {
// Replace the next line with any behavior you would like
fire(1);
}
/**
* onHitByBullet: What to do when you're hit by a bullet
*/
public void onHitByBullet(HitByBulletEvent e) {
// Replace the next line with any behavior you would like
turnLeft(90);
ahead(100);
turnGunRight(360);
scan();
turnRight(90);
ahead(100);
turnGunLeft(360);
scan();
}
/**
* onHitWall: What to do when you hit a wall
*/
public void onHitWall(HitWallEvent e) {
// Replace the next line with any behavior you would like
back(100);
}
public void onBulletMissed(BulletMissedEvent e) {
turnLeft(90);
ahead(100);
turnGunRight(360);
scan();
turnRight(90);
ahead(100);
turnGunLeft(360);
scan();
}
}