Shrinking Hammer

Jump to navigation Jump to search

Got it down to 259. Just use robocode.util.Utils.normalRelativeAngle( (code here) ) instead of importing files, and don't initialize i1 to 0 (The default value is already 0!)

Natesurf (talk)20:43, 12 February 2017

I shrunk it to 253. Now I am using the thing you said about normalReativeAngle

It is 253 again =(


package dsekercioglu;

import robocode.*;

public class Hammer extends AdvancedRobot {

   public static int[] m = new int[10];
   public static int i1;
   public static String h = "��������������������������������������������������������������������������������������������";
   public void run() {
       setTurnRadarRightRadians(Double.POSITIVE_INFINITY);
   }
   public void onScannedRobot(ScannedRobotEvent e) {
       double be;
       setTurnRightRadians((be = e.getBearingRadians()) + 1.5707963267948966D);
       setAhead((m[(i1 / 15)] % 3 - 1) * 36);
       i1 = (i1 + 1) % 150;
       be += getHeadingRadians();
       int a = (int) Math.round(e.getVelocity() * Math.sin(be - e.getHeadingRadians())) + 8;
       h += (char) a;
       double d;
       int b = (int) ((d = e.getDistance()) / 14);
       int matchi = h.substring(0, h.length() - b).lastIndexOf(a);
       for (int i = 1; i < b; i++) {
           be -= (h.codePointAt(matchi + i) - 8) / d;
       }
       setTurnGunRightRadians(robocode.util.Utils.normalRelativeAngle(be - getGunHeadingRadians()));
       setFire(2);
       setTurnRadarLeftRadians(getRadarTurnRemaining());
   }
   public void onHitByBullet(HitByBulletEvent e) {
       m[(i1 / 15)] += 1;
   }
   public void onHitWall(HitWallEvent e) {
       onHitByBullet(null);
   }

}

Dsekercioglu (talk)18:49, 14 February 2017
 

You do not have permission to edit this page, for the following reasons:

  • The action you have requested is limited to users in the group: Users.
  • You must confirm your email address before editing pages. Please set and validate your email address through your user preferences.

You can view and copy the source of this page.

Return to Thread:Help talk:Code Shrinking/Shrinking Hammer/reply (4).