Here is a Perceptual Couplet Robot Droid to do the job: package bayen; import robocode.*; /** * CoupletUba - a robot by Bayen */ public class CoupletUba extends Robot implements Droid { /** * First Line - Go forward */ public void run() {while(true)ahead(5000);} /** * Second Line - Follow the Walls */ public void onHitWall(HitWallEvent e) {turnRight(e.getBearing()+90);} } If you wanted to make it better, you could add: /** * Third Line - Move from Bullets */ public void onHitByBullet(HitByBulletEvent e) {turnRight(90);} /** * Fourth Line - Move from Enemies */ public void onHitRobot(HitRobotEvent e) {turnRight(90);}
--Bayen
MovesWithWind? could be shortened as so: public class MovesWithWind? extends AdvancedRobot { private double lastEnergy=100.0, direction=1.0; public final void run() { setTurnRadarRight(Double.POSITIVE_INFINITY); } public final void onScannedRobot?(ScannedRobotEvent event) { setAhead((lastEnergy != (lastEnergy = event.getEnergy()) && event.getEnergy() - lastEnergy <= 3.0) ? 100 * (direction *= -1) : getGetDistanceRemaining()); setTurnRight((event.getBearing() - 90) - (getVelocity() / Math.abs(getVelocity())) * ((300 - event.getDistance()) / 300) * 45); //setTurnRadarLeft(getRadarTurnRemaining()); } }
With a radar with more slip-rate and assigning variables on the same line as declaring them. -- Nfwu
|