[Home]Smogg

Robo Home | Changes | Preferences | AllPages

package cx.femto;
import robocode.*;
/**
 *-----------------------------------------------------------------
 * @author:iiley (iiley@hotmail.com)
 * https://www.robochina.org
 * When i miss her,I fish out a cigarat,smoking deeply,missing deeply....
 * I spit a circle smog,I see she was smileing there
 * 1.0: Smog's femto version.Maybe it can did better than Smog?(codesize:186)
 * future:let me smoke some first!
 *------------------------------------------------------------------
 * Thanks to the following:
 * dummy 
 * Daniel Pereira
 * robotobo
 * kawigi
 * and a general thanks to all NanoBot developers for being so creative
 */
public class Smogg extends AdvancedRobot
{
	private static double e_energy;
	public void run( ) {
		turnRadarRight(Double.POSITIVE_INFINITY);
	} 
    // -------------------- function for event handle ---------------
   	public void onScannedRobot( ScannedRobotEvent e ) {
		double enemyDir=e.getDistance();  //enemyDir is distance now
		if(e_energy!=(e_energy=e.getEnergy()) && getDistanceRemaining()==0){    
				setAhead(Math.sin(getTime()/8)*enemyDir*1.5);
		}
		//these code is used to around my rival prefer distance 140
		//220=0.5*Math.PI*140,140 is the prefer distance
        enemyDir=220/enemyDir;
		setTurnRightRadians(e.getBearingRadians()-(getVelocity()>0?enemyDir:(Math.PI-enemyDir)));
		setTurnGunLeftRadians(Math.asin(Math.sin(getGunHeadingRadians()-(enemyDir=e.getBearingRadians()+getHeadingRadians())-Math.asin(e.getVelocity()*Math.sin(e.getHeadingRadians()-enemyDir)/11)*(1+Math.random()*(0.4-Math.abs(e.getVelocity())/10)))));
		setFire(e_energy/4d);
		setTurnRadarLeft(getRadarTurnRemaining());
	}
}

Robo Home | Changes | Preferences | AllPages
Edit text of this page | View other revisions
Last edited September 15, 2003 2:09 EST by Iiley (diff)
Search: