[Home]Icarus

Robo Home | Changes | Preferences | AllPages

Difference (from prior major revision) (no other diffs)

Added: 5a6
The random movement is quite Raiko inspired. With an idiots way of doing what the MusashiTrick does for smarter bots. The gun is semi-linear. Sometimes I use blocking calls making it do some more unpredictable things. =)

Changed: 17c18
// $Id: Icarus.java,v 1.3 2004/08/25 11:34:03 peter Exp $
// $Id: Icarus.java,v 1.4 2004/08/25 16:51:40 peter Exp $

Changed: 21,22c22,23
static int timer;
static double[] reversies = { 0.0, 7.0, 14.0 };
static double bulletVelocity = -3;
static double distance;

Changed: 30,38c31,33
int stopOrGo? = 1;
double d = e.getDistance() / 10;
if (timer++ > d) {
stopOrGo? = 0;
}
if (timer > d * 1.35) {
timer = 0;
}
if (Math.random() < reversies[hits % 3] / e.getDistance()) {
distance = e.getDistance();
double v = 0.6 * bulletVelocity / distance;
if (hits > 3 && Math.random() > Math.pow(v, v)) {

Changed: 41,42c36,37
setAhead(direction * 20 * stopOrGo?);
setTurnRight?(e.getBearing() + 90 - direction);
setAhead(direction * 15);
setTurnRight?(normalizeDegrees(e.getBearing() + 90 - direction));

Changed: 45,46c40,41
setTurnGunRightRadians?(Utils.normalRelativeAngle(enemyAbsoluteBearing? + e.getVelocity() * Math.sin(e.getHeadingRadians() - enemyAbsoluteBearing?) * (Math.random() / (8.0 + getRoundNum?())) - getGunHeadingRadians?()));
setFire(e.getDistance() < 140 ? 3.0 : 1.9);
setTurnGunRightRadians?(Utils.normalRelativeAngle(enemyAbsoluteBearing? - getGunHeadingRadians?() + e.getVelocity() * Math.sin(e.getHeadingRadians() - enemyAbsoluteBearing?) / 13.0));
setFire(distance < 140 ? 3.0 : 1.9);

Changed: 52c47,53
direction = -direction;
if (hits < 4) {
turnRight(normalizeDegrees(e.getBearing() - 100));
ahead(100);
}
else {
direction = -direction;
}

Added: 55a57
bulletVelocity = e.getVelocity();

Added: 57a60,63

double normalizeDegrees(double angle) {
return Math.toDegrees(Utils.normalRelativeAngle(Math.toRadians(angle)));
}

A NanoBot by PEZ

Probably as lousy as all my other nano attempts...

Download it from http://www.robocoderepository.com/BotDetail.jsp?id=2353

The random movement is quite Raiko inspired. With an idiots way of doing what the MusashiTrick does for smarter bots. The gun is semi-linear. Sometimes I use blocking calls making it do some more unpredictable things. =)

Source

package pez.nano;
import robocode.*;
import robocode.util.Utils;

// This code is released under the RoboWiki Public Code Licence (RWPCL), datailed on:
// http://robowiki.net/?RWPCL
//
// Icarus, by PEZ. - Something small
// http://robowiki.net/?Icarus
// $Id: Icarus.java,v 1.4 2004/08/25 16:51:40 peter Exp $

public class Icarus extends AdvancedRobot {
    static int direction = 7;
    static double bulletVelocity = -3;
    static double distance;
    static int hits;

    public void run() {
	turnRadarRightRadians(Double.POSITIVE_INFINITY);
    }

    public void onScannedRobot(ScannedRobotEvent e) {
	distance = e.getDistance();
	double v = 0.6 * bulletVelocity / distance;
	if (hits > 3 && Math.random() > Math.pow(v, v)) {
	    direction = -direction;
	}
	setAhead(direction * 15);
	setTurnRight(normalizeDegrees(e.getBearing() + 90 - direction));

        double enemyAbsoluteBearing = getHeadingRadians() + e.getBearingRadians();
	setTurnGunRightRadians(Utils.normalRelativeAngle(enemyAbsoluteBearing - getGunHeadingRadians() + e.getVelocity() * Math.sin(e.getHeadingRadians() - enemyAbsoluteBearing) / 13.0));
	setFire(distance < 140 ? 3.0 : 1.9);

	setTurnRadarLeftRadians(getRadarTurnRemaining());
    }

    public void onHitWall(HitWallEvent e) {
	if (hits < 4) {
	    turnRight(normalizeDegrees(e.getBearing() - 100)); 
	    ahead(100);
	}
	else {
	    direction = -direction;
	}
    }

    public void onHitByBullet(HitByBulletEvent e) {
	bulletVelocity = e.getVelocity();
	hits++;
    }

    double normalizeDegrees(double angle) {
	return Math.toDegrees(Utils.normalRelativeAngle(Math.toRadians(angle)));
    }
}

Comments?


Robo Home | Changes | Preferences | AllPages
Edit text of this page | View other revisions
Last edited August 25, 2004 18:54 EST by PEZ (diff)
Search: