Skip to content

Instantly share code, notes, and snippets.

@berkes
Created September 25, 2015 09:44
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 berkes/1d2e0c7cd5f990fd6564 to your computer and use it in GitHub Desktop.
Save berkes/1d2e0c7cd5f990fd6564 to your computer and use it in GitHub Desktop.
import robocode.*;
import java.util.Random;
public class Marnick extends Robot {
boolean found = false;
int movingCounter = 72;
public void run() {
while (true) {
if(movingCounter > 0 || found) {
movingCounter--;
if(!found) {
turnGunRight(5);
} else {
fire(1);
}
} else {
movingCounter = 72;
Random rand = new Random();
int n = rand.nextInt(1000) + 1;
ahead(n);
int m = rand.nextInt(180) - 90;
turnRight(m);
}
}
}
public void onScannedRobot(ScannedRobotEvent e) {
stop();
found = true;
}
public void onBulletMissed(BulletMissedEvent e) {
found = false;
}
public void onHitWall(HitWallEvent e) {
back(100);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment