package sample; import robocode.*; /** * Need anyone say more than: * DropDown * IncreaseSpeed * ReverseDirection * * Seph (mijav.dk) and me didn't think so, and * this excelent bot (it won) show just that. */ public class InvaderBot extends Robot { public void run() { double halfWidth = getBattleFieldWidth()/2; double direction = getHeading(); turnLeft(direction); ahead(5000); turnRight(90); ahead(5000); while (true) { dropDown(true); increaseSpeed(halfWidth); reverseDirection(true); turnGunRight(360); dropDown(false); increaseSpeed(halfWidth); reverseDirection(false); } } private void dropDown(boolean left) { if (left) turnLeft(90); else turnRight(90); ahead(getHeight()); } private void increaseSpeed(double distance) { ahead(distance); } private void reverseDirection(boolean left) { if (left) turnLeft(90); else turnRight(90); } public void onScannedRobot(ScannedRobotEvent e) { fire(4); } }