[Home]Xaxa

Robo Home | Changes | Preferences | AllPages

Showing revision 4
package cx.haiku;

import robocode.AdvancedRobot;
import robocode.ScannedRobotEvent;
/**
 * @author iiley
 * Xaxa a haiku bot with random linear aiming and radar-lock.
 */
public class Xaxa extends AdvancedRobot {
    public void run() {
        while (true) {
            turnRight(10);
            setAhead(Math.sin(getTime()/8)*1200d);
        }
    }

    public void onScannedRobot(ScannedRobotEvent e) {
        if (setFireBullet(Math.min(600d/e.getDistance(),Math.min(getEnergy()/5d,Math.min(3d,e.getEnergy()/5d))))==null || true) {
            setTurnRadarRight(getRadarTurnRemaining()==0?Double.POSITIVE_INFINITY:0-getRadarTurnRemaining());
            setTurnGunLeftRadians(Math.asin(Math.sin(getGunHeadingRadians()-(e.getBearingRadians()+getHeadingRadians())-
                Math.asin(e.getVelocity()*Math.sin(e.getHeadingRadians()-e.getBearingRadians()-getHeadingRadians())/11)*
                (1+Math.random()*(0.4-Math.abs(e.getVelocity())/10)))));
        }
    }
}

You should change to a while loop instead of a do-while loop for this to be a haikubot. -- Kawigi

Oh~`Thanx,i did not notice that,i will change it,Thank you very much. -- iiley

Can you tell us what's going on here? Is it a linear aim of some sort? Sorry for messing with the indentation and such, but I had to to stand a chance to read the code. It's the semicolons that count anyway. =) -- PEZ


Robo Home | Changes | Preferences | AllPages
Edit revision 4 of this page | View other revisions | View current revision
Edited September 15, 2003 9:59 EST by PEZ (diff)
Search: