Skip to content

Instantly share code, notes, and snippets.

@raindev
Created December 5, 2016 08:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raindev/c8eeeb35be886ca2003d3f20fb93349d to your computer and use it in GitHub Desktop.
Save raindev/c8eeeb35be886ca2003d3f20fb93349d to your computer and use it in GitHub Desktop.
Tinkoween Robocode competition
package clinteastwood;
import java.awt.Color;
import java.util.Random;
import robocode.AdvancedRobot;
import robocode.ScannedRobotEvent;
public class ClintBot extends AdvancedRobot {
private final Random random = new Random();
public void run() {
setTurnRadarRight(5);
while (true) {
movementIsKey();
setColors(randomColor(), randomColor(), randomColor());
turnGunRight(random.nextDouble() * 360);
}
}
@Override
public void onScannedRobot(ScannedRobotEvent event) {
fire(random.nextDouble() * 150);
}
private Color randomColor() {
return new Color(random.nextInt(255), random.nextInt(255), random.nextInt(255));
}
void movementIsKey() {
for (int i = 0; i < 3; i++) {
ahead(random.nextInt(25) + 75);
turnRight(50);
}
}
}
// ahead(random.nextDouble() * 200);
// turnRight(random.nextDouble() * 90);
// turnGunRight(random.nextDouble() * 60);
//
//
// if(random.nextBoolean())
// back(random.nextDouble() * 200);
//
// turnRight(random.nextDouble() * 90);
// turnGunRight(random.nextDouble() * 60);
package clinteastwood;
import java.awt.Color;
import java.util.Random;
import robocode.AdvancedRobot;
import robocode.ScannedRobotEvent;
public class ClintBotRetroFuturistic extends AdvancedRobot {
private final Random random = new Random();
public void run() {
setTurnRadarRight(5);
while (true) {
movementIsKey();
setColors(randomColor(), randomColor(), randomColor());
turnGunRight(random.nextDouble() * 360);
}
}
@Override
public void onScannedRobot(ScannedRobotEvent event) {
fire(random.nextDouble() * 75 + 75);
}
private Color randomColor() {
return new Color(random.nextInt(255), random.nextInt(255), random.nextInt(255));
}
void movementIsKey() {
for (int i = 0; i < 3; i++) {
if (random.nextBoolean()) {
ahead(random.nextInt(25) + 75);
} else {
ahead(random.nextInt(25) + 75);
}
turnRight(random.nextDouble() * 20 + 30);
}
}
}
// ahead(random.nextDouble() * 200);
// turnRight(random.nextDouble() * 90);
// turnGunRight(random.nextDouble() * 60);
//
//
// if(random.nextBoolean())
// back(random.nextDouble() * 200);
//
// turnRight(random.nextDouble() * 90);
// turnGunRight(random.nextDouble() * 60);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment