Thread history

From Help talk:Code Shrinking
Viewing a history listing
Jump to navigation Jump to search
Time User Activity Comment
00:02, 12 February 2017 Dsekercioglu (talk | contribs) New thread created  
20:34, 12 February 2017 Natesurf (talk | contribs) New reply created (Reply to Shrinking Hammer)
20:43, 12 February 2017 Natesurf (talk | contribs) New reply created (Reply to Shrinking Hammer)
20:44, 12 February 2017 Natesurf (talk | contribs) Comment text edited  
18:49, 14 February 2017 Dsekercioglu (talk | contribs) New reply created (Reply to Shrinking Hammer)
18:51, 14 February 2017 Dsekercioglu (talk | contribs) New reply created (Reply to Shrinking Hammer)

Shrinking Hammer

Anyone with an idea?

Dsekercioglu (talk)00:02, 12 February 2017

Doesn't look like it could be shrunk much more from here without sacrificing features . . Not sure. There's some software on the internet though which might help.

Natesurf (talk)20:34, 12 February 2017
 

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
 

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