[Home]CircularLinearVulnerabilityTester

Robo Home | Changes | Preferences | AllPages

No diff available--this is the first major revision. (no other diffs)
By Dummy and Kuuran.

Kuuran wrote: PEZ, I've modified Dummy's NanoCircularLinearPredictor? a bit, run the following code against Tityus (0.3 - PEZ's remark) and watch the debug window:

public class Circular_Linear_Vulnerability_Tester extends AdvancedRobot
{
	static double lastEnemyHeading;
	static double radarturn=1;
	int hits = 0, fires = 0;
	static int pershits = 0, persfires = 0;

	public void run()
	{
		do
		{
			if(getDistanceRemaining() == 0)
				setAhead(Math.random() * 400 - 200);
			setTurnRadarRightRadians(radarturn);	
			if(fireBullet(1) != null)
			{
				fires++;
				persfires++;
			}
		}while(true);
	}

	public void onScannedRobot(ScannedRobotEvent e)
	{
		radarturn=-radarturn;
		double w=e.getHeadingRadians()-lastEnemyHeading;
		lastEnemyHeading=e.getHeadingRadians();
		double absbearing=e.getBearingRadians()+getHeadingRadians();
		double eX=e.getDistance()*Math.sin(absbearing);
		double eY=e.getDistance()*Math.cos(absbearing);

		double db=0;
		double ww=lastEnemyHeading;
		do
		{
			db+=17;
			double dx=e.getVelocity()*Math.sin(ww);
			double dy=e.getVelocity()*Math.cos(ww);
			ww+=w;
			eX+=dx;
			eY+=dy;
		}while (db< Point2D.distance(0,0,eX,eY));

		setTurnGunRightRadians(Math.asin(Math.sin(Math.atan2(eX, eY) - getGunHeadingRadians())));
		setTurnRightRadians(e.getBearingRadians() + .5*Math.PI);
	}

	public void onBulletHit(BulletHitEvent e)
	{
		hits++;
		pershits++;
	}

	public void onDeath(DeathEvent e)
	{
		System.out.print("Round Hit rate: ");
		System.out.print((double)hits/(double)fires * 100);
		System.out.println("%");
		System.out.print("Overall Hit rate: ");
		System.out.print((double)pershits/(double)persfires * 100);
		System.out.println("%");
	}

	public void onWin(WinEvent e)
	{
		System.out.print("Round Hit rate: ");
		System.out.print((double)hits/(double)fires * 100);
		System.out.println("%");
		System.out.print("Overall Hit rate: ");
		System.out.print((double)pershits/(double)persfires * 100);
		System.out.println("%");
	}
}

So what this means is that Tityus is vulnerable to full linear aim? I have sort of figured that out already. But it's good to have a test bot that I can use to make sure the next version isn't. Thanks! -- PEZ

Be wary that as posted it uses low power bullets (fire(1)) so don't expect 8% or less hitrates - it's a very simple modification to change that, though. DT 1.91 in challenge mode gets about 11.6% hitrate against from this gun, and that results in no wins for the linear tester. -- Kuuran


Robo Home | Changes | Preferences | AllPages
Edit text of this page | View other revisions
Last edited September 12, 2003 14:00 EST by PEZ (diff)
Search: