title: Need Help To Make A Good Robocode Robot
body: <p>I came to ask about Robocode robots. I have a code for my robots and against 26 of my friends it came 11th. However, I want to try to make it better. I have looked over websites and adjusted my code so it can move unpredictably. This helped it come 1st once in ten rounds. Could you please give me some ideas and tips to help improve this robot please? I can then edit my robot and see how it does. I want the robot to remain in extends Robot though.</p>
  
  <pre><code>package aaa;
  import robocode.*;
  //import java.awt.Color;
  
  // API help: http://robocode.sourceforge.net/docs/robocode/robocode/Robot.html
  
  /**  
   *Epictron - a robot by ASHAR ASLAM!!!
   */
  public class Epictron extends Robot
  {
      /**
       * run: Epictron's default behavior
       */
      public void run() {
          // Initialization of the robot should be put here
          // After trying out your robot, try uncommenting the import at the top,
          // and the next line:
          // setColors(Color.blue,Color.blue,Color.grey,Color.red,Color.green); // body,gun,radar
          // Robot main loop
          while(true) {
              // Replace the next 4 lines with any behavior you would like
              double distance = Math.random()*300;
              double angle = Math.random()*45;
              turnRight(angle);
              ahead(distance);
              ahead(100);
              turnGunRight(90);
              back(100);
              turnGunRight(90);
          }
      }
  
      /**
       * onScannedRobot: What to do when you see another robot
       */
      public void onScannedRobot(ScannedRobotEvent e) {
          // Replace the next line with any behavior you would like
          double distance = e.getDistance();
  
          if(distance&lt;200)
          {
             fire(3.5);
          }
          else if(distance&lt;500)
          {
             fire(2.5);
          }
          else if(distance&lt;800)
          {
             fire(1.5);
          }
          else
          {
             fire(0.5);
          }
      }
  
      /**
       * onHitByBullet: What to do when you're hit by a bullet
       */
      public void onHitByBullet(HitByBulletEvent e) {
          // Replace the next line with any behavior you would like
          back(10);
      }
  
      /**
       * onHitWall: What to do when you hit a wall
       */
      public void onHitWall(HitWallEvent e) {
          // Replace the next line with any behavior you would like
          back(20);
      }   
  }
  </code></pre>