[Home]Machete/Code

Robo Home | Machete | Changes | Preferences | AllPages

   package jk.nano;
   import robocode.*;
   import robocode.util.*;
   import java.awt.geom.*;
   import java.awt.*;
   
   
    public class Machete extends AdvancedRobot{
      final static int STICK = 144;
      static double move = STICK;
      static double lastEnemyEnergy;
      static int deaths;
      // double x;
      // double y;
   	
   	
       public void run(){
         turnRadarRightRadians(Double.POSITIVE_INFINITY);
      }
       public void onScannedRobot(ScannedRobotEvent e){
         double absbearing;
         double tempmove;
         double goAngle = Math.PI/2 + (tempmove = move)/500 + (absbearing = getHeadingRadians() + e.getBearingRadians());
         if(deaths > 5){
            if(Math.random()  <  30.0/e.getDistance())
               move = -tempmove;
            setAhead(tempmove);
         }
            
         if((lastEnemyEnergy - (lastEnemyEnergy = e.getEnergy())) > 0 )
            setAhead(tempmove/3.0);
            
         while(!new Rectangle2D.Double(18,18,764,564).
         // contains(x = getX() + tempmove*Math.sin(goAngle-= tempmove*0.0001),y = getY() + tempmove*Math.cos(goAngle)));
         contains(getX() + tempmove*Math.sin(goAngle-= tempmove*0.0001),getY() + tempmove*Math.cos(goAngle)));
      
         setTurnRightRadians(Utils.normalRelativeAngle(goAngle - getHeadingRadians()));
      
         setTurnGunRightRadians(Utils.normalRelativeAngle(e.getVelocity()*Math.sin(e.getHeadingRadians() -absbearing)/13*Math.random() + absbearing - getGunHeadingRadians()));
      
         setFire(getEnergy()/16);
         setTurnRadarLeft(getRadarTurnRemaining());
      }
   
       public void onDeath(DeathEvent e){
         deaths++;
      }
      //  public void onPaint(java.awt.Graphics2D g) {
   //       g.setColor(Color.green);
   //       g.drawOval((int)(x),(int)(y),
   //             2,2);
   //    }
   }

Robo Home | Machete | Changes | Preferences | AllPages
Edit text of this page | View other revisions
Last edited January 14, 2008 13:41 EST by Skilgannon (diff)
Search: