Created
September 25, 2015 09:44
-
-
Save berkes/1d2e0c7cd5f990fd6564 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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