Skip to content

Commit 78bae70

Browse files
committed
inital commit
1 parent 53c56d7 commit 78bae70

13 files changed

+590
-0
lines changed

AntiMove.java

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
package ep;
2+
import robocode.*;
3+
//import java.awt.Color;
4+
5+
// API help : http://robocode.sourceforge.net/docs/robocode/robocode/Robot.html
6+
7+
/**
8+
* AntiMove - a robot by (your name here)
9+
*/
10+
public class AntiMove extends Robot
11+
{
12+
/**
13+
* run: AntiMove's default behavior
14+
*/
15+
public void run() {
16+
// Initialization of the robot should be put here
17+
18+
// After trying out your robot, try uncommenting the import at the top,
19+
// and the next line:
20+
21+
// setColors(Color.red,Color.blue,Color.green); // body,gun,radar
22+
23+
// Robot main loop
24+
while(true) {
25+
// Replace the next 4 lines with any behavior you would like
26+
ahead(100);
27+
turnGunRight(360);
28+
back(100);
29+
turnGunRight(360);j
30+
}
31+
}
32+
33+
/**
34+
* onScannedRobot: What to do when you see another robot
35+
*/
36+
public void onScannedRobot(ScannedRobotEvent e) {
37+
// Replace the next line with any behavior you would like
38+
fire(1);
39+
}
40+
41+
/**
42+
* onHitByBullet: What to do when you're hit by a bullet
43+
*/
44+
public void onHitByBullet(HitByBulletEvent e) {
45+
// Replace the next line with any behavior you would like
46+
back(10);
47+
}
48+
49+
/**
50+
* onHitWall: What to do when you hit a wall
51+
*/
52+
public void onHitWall(HitWallEvent e) {
53+
// Replace the next line with any behavior you would like
54+
back(20);
55+
}
56+
}

AntiWalls.class

3.39 KB
Binary file not shown.

AntiWalls.java

Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
package ep;
2+
import robocode.*;
3+
import java.awt.Color;
4+
5+
// API help : http://robocode.sourceforge.net/docs/robocode/robocode/Robot.html
6+
7+
/**
8+
* AntiWalls - a robot by (your name here)
9+
*/
10+
public class AntiWalls extends Robot
11+
{
12+
double side = 1.0;
13+
Integer back = new Integer(6);
14+
Integer fire = new Integer(0);
15+
/**
16+
* run: AntiWalls's default behavior
17+
*/
18+
public void run() {
19+
// Initialization of the robot should be put here
20+
21+
// After trying out your robot, try uncommenting the import at the top,
22+
// and the next line:
23+
24+
setColors(Color.blue,Color.blue,Color.green); // body,gun,radar
25+
26+
// Robot main loop
27+
while(true) {
28+
// Replace the next 4 lines with any behavior you would like
29+
back = new Integer(6);
30+
fire = new Integer(0);
31+
System.out.println("Position finder initialized.");
32+
System.out.println("Facing: " + getHeading());
33+
double heading = getHeading();
34+
35+
if(heading > 180) {
36+
turnRight(360 - heading);
37+
}
38+
39+
else {
40+
turnLeft(heading);
41+
}
42+
System.out.println("Facing: " + getHeading());
43+
ahead((getBattleFieldHeight() / 2) - getY());
44+
turnRight(90);
45+
ahead((getBattleFieldWidth() / 2) - getX());
46+
turnLeft(90);
47+
System.out.println("Position finder terminated. Now at " + getX() + ", " + getY());
48+
49+
System.out.println("Finding walls...");
50+
51+
scan();
52+
turnRight(360);
53+
System.out.println("Initializing movement. Facing " + getHeading() + ".");
54+
if(side < 2) {
55+
turnRight(45);
56+
ahead(100);
57+
while(fire == 1) {
58+
ahead(1);
59+
60+
fire(1);
61+
62+
System.out.println("Fire sucsessful.");
63+
}
64+
}
65+
66+
else if(side == 2) {
67+
turnRight(135);
68+
ahead(100);
69+
while(fire == 1) {
70+
ahead(1);
71+
72+
fire(1);
73+
74+
System.out.println("Fire sucsessful.");
75+
}
76+
}
77+
78+
else if(side == 3) {
79+
turnLeft(135);
80+
ahead(100);
81+
while(fire == 1) {
82+
ahead(1);
83+
84+
fire(10);
85+
86+
System.out.println("Fire sucsessful.");
87+
}
88+
}
89+
90+
else {
91+
turnLeft(45);
92+
ahead(100);
93+
while(fire == 1) {
94+
ahead(1);
95+
96+
fire(1);
97+
98+
System.out.println("Fire sucsessful.");
99+
}
100+
}
101+
System.out.println("Movement terminated.");
102+
103+
104+
105+
}
106+
}
107+
108+
/**
109+
* onScannedRobot: What to do when you see another robot
110+
*/
111+
public void onScannedRobot(ScannedRobotEvent e) {
112+
// Replace the next line with any behavior you would like
113+
114+
115+
System.out.println("Walls found.");
116+
if(getHeading() < 91) {
117+
side = (2);
118+
}
119+
else if(getHeading() < 181) {
120+
side = (3);
121+
}
122+
else if(getHeading() < 271) {
123+
side = (4);
124+
}
125+
else {
126+
side = (1);
127+
}
128+
System.out.println("Walls at side " + side);
129+
if(fire == 1) {
130+
fire = new Integer(0);
131+
System.out.println("End fire.");
132+
}
133+
else {
134+
fire = new Integer(1);
135+
System.out.println("Initialize fire.");
136+
}
137+
138+
139+
140+
141+
}
142+
143+
/**
144+
* onHitByBullet: What to do when you're hit by a bullet
145+
*/
146+
public void onHitByBullet(HitByBulletEvent e) {
147+
// Replace the next line with any behavior you would like
148+
System.out.println("Report-damage taken.");
149+
}
150+
151+
/**
152+
* onHitWall: What to do when you hit a wall
153+
*/
154+
public void onBulletHit(BulletHitEvent e) {
155+
System.out.println("Report-" + e.getName() + " has been struck.");
156+
fire = new Integer(0);
157+
}
158+
public void onHitWall(HitWallEvent e) {
159+
// Replace the next line with any behavior you would like
160+
System.out.println("Position finder failed.");
161+
back(20);
162+
}
163+
}

ErixClone.class

2.63 KB
Binary file not shown.

ErixClone.java

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
package ep;
2+
import robocode.*;
3+
import java.awt.Color;
4+
5+
// API help : http://robocode.sourceforge.net/docs/robocode/robocode/Robot.html
6+
7+
/**
8+
* ErixClone - a robot by Eric
9+
*/
10+
public class ErixClone extends Robot
11+
{
12+
Integer Random = new Integer(1);
13+
/**
14+
* run: ErixClone's default behavior
15+
*/
16+
public void run() {
17+
// Initialization of the robot should be put here
18+
19+
// After trying out your robot, try uncommenting the import at the top,
20+
// and the next line:
21+
22+
setColors(Color.green,Color.green,Color.green); // body,gun,radar
23+
double heading = getHeading();
24+
if(heading > 180) {
25+
turnRight(360 - heading);
26+
}
27+
else {
28+
turnLeft(heading);
29+
}
30+
ahead((getBattleFieldHeight() / 2) - getY());
31+
turnRight(90);
32+
ahead((getBattleFieldWidth() / 2) - getX());
33+
turnLeft(90);
34+
// Robot main loop
35+
while(true) {
36+
37+
38+
if(getOthers() < 2) {
39+
// Assertive Mode
40+
41+
System.out.println("Assertive mode active.");
42+
Random = new Integer(100);
43+
turnRight(180);
44+
ahead(Random);
45+
turnGunRight(360);
46+
back(Random);
47+
turnRight(180);
48+
System.out.println("Currently at x:" + getX() + " and y:" + getY() + " and traveling at:" + getVelocity());
49+
}
50+
else if(getOthers() < 4) {
51+
// Regular Mode
52+
if(getOthers() > 1) {
53+
System.out.println("Regular mode active.");
54+
setAdjustGunForRobotTurn(false);
55+
ahead(100);
56+
turnGunRight(360);
57+
turnRight(90);
58+
turnGunRight(360);
59+
System.out.println("Currently at x:" + getX() + " and y:" + getY() + " and traveling at:" + getVelocity());
60+
}
61+
}
62+
else {
63+
//Dodging Mode
64+
65+
setAdjustGunForRobotTurn(true);
66+
System.out.println("Dodging mode actve.");
67+
turnLeft(45);
68+
ahead(10);
69+
turnGunRight(360);
70+
back(10);
71+
turnGunRight(45);
72+
System.out.println("Currently at x:" + getX() + " and y:" + getY() + " and traveling at:" + getVelocity());
73+
}
74+
75+
76+
}
77+
78+
}
79+
80+
81+
82+
/**
83+
* onScannedRobot: What to do when you see another robot
84+
*/
85+
public void onScannedRobot(ScannedRobotEvent e) {
86+
// Replace the next line with any behavior you would like
87+
setColors(Color.red,Color.red,Color.red);
88+
fire(5);
89+
setColors(Color.green,Color.green,Color.green);
90+
}
91+
92+
/**
93+
* onHitByBullet: What to do when you're hit by a bullet
94+
*/
95+
public void onHitByBullet(HitByBulletEvent e) {
96+
// Replace the next line with any behavior you would like
97+
back(10);
98+
System.out.println("I've been hit!");
99+
ahead(20);
100+
}
101+
102+
/**
103+
* onHitWall: What to do when you hit a wall
104+
*/
105+
public void onHitWall(HitWallEvent e) {
106+
// Replace the next line with any behavior you would like
107+
back(20);
108+
System.out.println("Whoops!");
109+
}
110+
}

ErixClone2.class

2.11 KB
Binary file not shown.

0 commit comments

Comments
 (0)