Shrinking Hammer

Jump to navigation Jump to search

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 (2).

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
 

I have a question. I used byte instead of int(without any extra casting) it increased the code size 1 byte.

Dsekercioglu (talk)18:51, 14 February 2017