CenterBot template


import robocode.*;

/**
 * CenterBot - a robot by J. Chung
 */
public class CenterBot3 extends Robot
{
   // Approach #3: Once you know the x,y coordinates of the center of
   // the arena, point robot in direction of center, compute distance
   // to center, move ahead to center.

   // Declare some robot variables here:
   private double centerX;
   private double centerY;
   
   
   /**
    * run: CenterBot's default behavior
    */
   public void run() {
      // Initialization of the robot should be put here
      // Compute x, y coordinates for center of field:
      centerX = getBattleFieldWidth() / 2;  
      centerY = getBattleFieldHeight() / 2;
      
      // Robot main loop
      while(true) {
         
         // Get my current heading:
         double currentHeading = getHeading();
         
         // Get my current x,y coordinates:
         double myX = getX();
         double myY = getY();
         
         // Compute angle between my coordinates and center:





         
         // Change my heading to point to center:





         
         // Compute my distance to center:
         




         // Go ahead to center:


         
      }
      
   }
   
}