Talk:Assertive

From Robowiki
Jump to navigation Jump to search

Where can I see the source? Awesomeness 21:13, 1 May 2009 (UTC)

Decompile it if you like. It seem that HUNRobar has confused on how to pack the source in .jar. » Nat | Talk » 05:51, 2 May 2009 (UTC)

Okay. Awesomeness 13:46, 2 May 2009 (UTC)

In case you can't find the decompiler, here it is:

package robar.nano;

import robocode.*;
import robocode.util.Utils;

public class Assertive extends AdvancedRobot {
    static double direction = 1D;
    static StringBuffer history = new StringBuffer("00000000000000000000000000000");
    static final double APPROACHANGLE = -Math.toRadians(20D);
    static final double NINTYDEG = Math.PI/2;
    static final double FIREPOWER = 2.5D;
    static final double BULLETVEL = 12.5D;
    static final int PATTERN_DEPTH = 30;

    public void run()
    {
        setAdjustGunForRobotTurn(true);
        setAllColors(java.awt.Color.red);
        setTurnRadarRight(Double.POSITIVE_INFINITY);
    }

    public void onScannedRobot(ScannedRobotEvent e)
    {
        setTurnRightRadians(Utils.normalRelativeAngle(e.getBearingRadians() + NINTYDEG + APPROACHANGLE * direction));
        if(getDistanceRemaining() == 0.0D)
        {
            direction = -direction;
            setAhead(Math.random() * 144D * direction);
        }
        double dist = e.getDistance();
        double absB = e.getBearingRadians() + getHeadingRadians();
        int matchLenght = PATTERN_DEPTH;
        history.insert(0, (char)(int)(Math.sin(e.getHeadingRadians() - absB) * e.getVelocity()));
        int index;
        while((index = history.toString().indexOf(history.substring(0, matchLenght--), 1)) < 0) ;
        matchLenght = index - (int)(dist / BULLETVEL);
        do
            absB += Math.asin((double)(byte)history.charAt(index--) / dist);
        while(index >= Math.max(0, matchLenght));
        setTurnGunRightRadians(Utils.normalRelativeAngle(absB - getGunHeadingRadians()));
        setFire(FIREPOWER);
        setTurnRadarLeft(getRadarTurnRemaining());
    }
}

This is much like the original one yet difference from decompiled one since the decompiler can't preserve the use of static final field inside function. » Nat | Talk » 13:54, 2 May 2009 (UTC)

There are no threads on this page yet.