Created
December 5, 2016 08:52
-
-
Save raindev/c8eeeb35be886ca2003d3f20fb93349d to your computer and use it in GitHub Desktop.
Tinkoween Robocode competition
This file contains hidden or 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
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); |
This file contains hidden or 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
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