Shrinking Hammer
Jump to navigation
Jump to search
Revision as of 14 February 2017 at 17:51.
The highlighted comment was created in this revision.
The highlighted comment was created in this revision.
Anyone with an idea?
Dsekercioglu (talk)
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.
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!)
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)
I have a question. I used byte instead of int(without any extra casting) it increased the code size 1 byte.
Dsekercioglu (talk)