[Home]RaikoNano

Robo Home | Changes | Preferences | AllPages

package wiki.nano;
import robocode.*;
import robocode.util.Utils;
import java.awt.geom.Rectangle2D;

public class RaikoNano extends AdvancedRobot {
	static double direction = 1, bulletVelocity;
	
	public void run() {
		setTurnRadarRight(Double.POSITIVE_INFINITY);
	}
	
	public void onScannedRobot(ScannedRobotEvent e) {
		double v1, v2, offset = 2;
		
		setTurnGunRightRadians(Utils.normalRelativeAngle((v1 = getHeadingRadians() + e.getBearingRadians()) + 
			Math.random() * e.getVelocity() / 13 * Math.sin(e.getHeadingRadians() - v1) - getGunHeadingRadians()));
		
		while(!new Rectangle2D.Double(18,18,764,564).
			contains(getX() + 160 * Math.sin(v2 = v1 + direction * (offset -= .02)), getY() + 160 * Math.cos(v2)));
		
		setFire(Math.min(1100 / (v1 = e.getDistance()), getEnergy()/6));
		if(Math.random() > Math.pow(v1 = 0.5952 * bulletVelocity / v1, v1) || offset < 0.7) {
			direction = -direction;
		}
		
		setAhead(1000 * Math.cos(v2 -= getHeadingRadians()));
		setTurnRightRadians(Math.tan(v2));
		setTurnRadarLeft(getRadarTurnRemaining());
	}
	
	public void onHitByBullet(HitByBulletEvent e) {
		bulletVelocity = e.getVelocity();
	}
}

This could be what you get if you try to shrink Raiko into a NanoBot (248 bytes). I put it into the wiki package because nearly everything is borrowed from Raiko, thus I didn't want to release it. So Jamougha, you can release it if you think it is worth it ;-) -- rozu

Lol - when I saw this I thought I was in a time warp - RaikoNano was supposed to be tomorrows's release. ;-) But this is much more beautiful than my implementations. I would never have thought of using onHitByBullet? to get the opponent's firepower, for sure! So why not, let's release it as a wiki bot. Seeing as you created it, do you want to pick a new name for it? :-) -- Jamougha

By the way, I think direction = -direction is smaller than direction *= -1. And I detect I think that it would use the musashi trick until it got hit (because the velocity would be 0)? -- Kawigi

Which wouldn't be the MusashiTrick. But still avoid head-on fire a while and very much like what I do in dev T. Was it by intention you implemented head-on-avoidance rozu? -- PEZ

@ PEZ, no it wasn't by accident, but it isn't so useful at the moment. Before "bulletVelocity" has not been static to use head-on-avoidance, but this is a problem against bots with better guns.

@ Jamougha, it is a nano version of Raiko, so... but if you want to release tomorrow a bot with the same name it surely should be changed (but I have no ideas for a name). If you will not release it, it should of course keep this name to stay in relation with its bigger brothers.

@ Kawigi, just change it if you now how to make the code smaller (with Jamougha permission it's now a wiki bot) -- rozu

rozu, well in that case I think it's probably the worthiest nano-contender to the Raiko name. :-) My attempts have ranged from nano pattern matchers over Raiko movement to nano-adaptive movers, but this is certainly closer to Raiko. I'll release it tonight.

Kawigi, thanks and changed. :-) -- Jamougha

I just updated this bot because I could find some bytes. I didn't really know where to spend them so I put them into EnergyManagement. -- rozu

Hey, nice one, you managed to push it past TAoW?! 100th place exactly. -- Jamougha


Robo Home | Changes | Preferences | AllPages
Edit text of this page | View other revisions
Last edited October 10, 2007 2:52 EST by Voidious (diff)
Search: