# Acero/AceroCode

Robo Home | Acero | Changes | Preferences | AllPages

```package ahf;
import robocode.*;
import java.awt.geom.Rectangle2D;
import robocode.util.Utils;

{
static double direction;

public void run(){
direction=1;
do{
}
while(true);
}
public void onScannedRobot(ScannedRobotEvent e){
double enemyAbsoluteBearing;
double distance;

while (!new Rectangle2D.Double(19.0,19.0,762.0,562.0).contains(getX()+Math.sin(goalDirection)*120,getY()+Math.cos(goalDirection)*120)){
goalDirection = goalDirection+direction*.1;
if (Math.random()<.01)
direction=-direction;
}
if (Math.random()<.04)
direction=-direction;
setFire(2);
}
}

```
can anyone make it smaller?

oh yeah,in the next version i'll take out the distance variable or do somthing better than math.random<.04:direction*=-1 --andrew

You could replace your radar code and get some space. Take a look to any of the open source nanos (ie. NanoLauLectrik) to see the implementation. It avoids the do-while loop in the run method and makes the setTurnRadar?... simpler. -- Albert

isn't this the best radar configuration there is for nanos? the do while loop is the same as the turnrightradians(infiniti) thing in terms of bytes. and the loop is better because when it falls off, it doesn't just die.

I haven't measured the exact number of bytes used, but

``` public void run() { turnRadarRightRadians?(Double.POSITIVE_INFINITY); }
```
will probably be smaller (anyway, it's worth a try). In the other hand, it never stops when it falls, because the remaining turn of infinity is just infinity :-) Albert

thanks Albert, i'll try it. --andrew

Changing your while loop to a do-while loop will make it slightly smaller, too, if you think it's ok to do. -- Kawigi

don't i have a do-while loop?--andrew

ah. thanks, i'll try it. --andrew

anyone know what the most effective gun would be. i can have about 15 more bytes while having head on. --andrew

cool codesize 219!--mike

yeah,with the help of mike, codesize is now 219 w/ same functionality. --andrew

Robo Home | Acero | Changes | Preferences | AllPages