Spitfire

From Robowiki
Revision as of 20:07, 19 February 2013 by Skotty (talk | contribs) (add a new stub page with a few details)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Spitfire is a robot that only uses bullet shielding. It provides an interesting point of reference for the technique, and also serves as a base for the bullet shielding mode in my robot XanderCat. It is based on my Xander Framework.

Top Level Code

The main robot class; short and sweet:

public class Spitfire extends AbstractXanderRobot {

	@Override
	protected void configure(Configuration configuration) {
		configuration.setAutoFireOnDisabledOpponents(false);
	}

	@Override
	protected void addComponents(ComponentChain componentChain) {
		componentChain.addDefaultComponents(new BasicRadar(45, 3));
		BulletShieldingFactory.addBulletShieldingComponentsAlwaysApplies(componentChain, 0.1d);	
	}
}

Above, the call setAutoFireOnDisabledOpponents seems a little backwards, as Spitfire does fire on disabled opponents. The Xander Framework auto-fire functionality (which this setting turns on and off) is set up to fire a head-on shot immediately on a disabled opponent. However, with Spitfire, it needs to be sure that all opponent shots have been shielded before firing on a disabled opponent. For now, I just handle this in the bullet shielding gun. In the future, I may update the framework to make this a little more configurable to handle either approach.

Below, a look at the BulletShieldingFactory method for setting up the bullet shielding components:

public static void addBulletShieldingComponentsAlwaysApplies(ComponentChain chain, double maxAdjustedFirePower) {
	BulletShieldingDrive bulletShieldingDrive = new BulletShieldingDrive();
	BulletShieldingController bulletShieldingController 
		= new BulletShieldingController(bulletShieldingDrive, 7);
	BulletShieldingGun bulletShieldingGun = null;
	if (maxAdjustedFirePower < RCPhysics.MIN_FIRE_POWER) {
		bulletShieldingGun = new BulletShieldingGun(bulletShieldingController);
	} else {
		bulletShieldingGun = new BulletShieldingGun(bulletShieldingController, maxAdjustedFirePower);
	}
	Scenario bulletShieldingScenario = new Scenario() {
		@Override
		public boolean applies() {
			return true;
		}
	};
	chain.addComponents(bulletShieldingScenario, bulletShieldingDrive, bulletShieldingGun);		
}

My current design uses a "controller" to deal with tracking shots, and it serves as an intermediary between the drive and gun. The gun requests waves from the controller, and the controller tells the drive what to do and lets the gun know when it's okay to fire.

For v1.0, I'm not utilizing the max adjusted fire power functionality. I just always use 0.1 shots. If I ever turn it on, it will vary the fire power up to the given amount in an attempt to improve the shielding overlap.

The parameter 7 sent to the controller is the number of ticks needed to prep for and shield an opponent shot. This is higher than I'd like, and I hope to make some improvements in the future to reduce that number.