Difference between revisions of "XanderFramework"
m (→OrbitalDrive: updated info on OrbitalDrive) |
(updated with code example for robot using Xander framework) |
||
Line 13: | Line 13: | ||
This gun is for targeting opponents that drive in circles. If the opponent does not appear to be going in circles, this gun will not fire on the target. | This gun is for targeting opponents that drive in circles. If the opponent does not appear to be going in circles, this gun will not fire on the target. | ||
==== StatGun ==== | ==== StatGun ==== | ||
− | This gun is a "guess factor" gun that relies on statistics to determine how to aim. If will not fire until there are sufficient stats to make a good guess. It relies on a Segmenter to determine how to categorize the statistics it collects ( | + | This gun is a "guess factor" gun that relies on statistics to determine how to aim. If will not fire until there are sufficient stats to make a good guess. It relies on a Segmenter to determine how to categorize the statistics it collects (Segmenter is a separate interface). |
==== CompoundGun ==== | ==== CompoundGun ==== | ||
Combines two or more other guns. Compound gun delegates gunning to other guns based on the order they were added to the compound gun. Compound gun will check the guns in order until it finds a gun that claims it can fire on the designated target, and then allows that gun to fire. | Combines two or more other guns. Compound gun delegates gunning to other guns based on the order they were added to the compound gun. Compound gun will check the guns in order until it finds a gun that claims it can fire on the designated target, and then allows that gun to fire. | ||
Line 23: | Line 23: | ||
==== AvoidanceDrive ==== | ==== AvoidanceDrive ==== | ||
This drive relies exclusively on "inverse gravity bullet avoidance" to control movement. Not really meant for real combat, this drive was created to test various aspects of bullet avoidance. | This drive relies exclusively on "inverse gravity bullet avoidance" to control movement. Not really meant for real combat, this drive was created to test various aspects of bullet avoidance. | ||
+ | |||
+ | == Example Xander Robot == | ||
+ | As an example of how the Xander framework is used, below is the source for the main robot class of XanderCat 2.0. | ||
+ | <pre> | ||
+ | /** | ||
+ | * 1-on-1 robot built on the Xander framework. Also suitable for melee. | ||
+ | * | ||
+ | * @author Scott Arnold | ||
+ | */ | ||
+ | public class XanderCat extends AbstractXanderBot { | ||
+ | |||
+ | @Override | ||
+ | protected Level getLogLevel() { | ||
+ | return Log.Level.INFO; | ||
+ | } | ||
+ | |||
+ | @Override | ||
+ | protected Radar createRadar() { | ||
+ | return new BasicRadar(this, 45, 5); | ||
+ | } | ||
+ | |||
+ | @Override | ||
+ | protected Drive createDrive() { | ||
+ | return new OrbitalDrive(this, 200, 40, 0.5f); | ||
+ | } | ||
+ | |||
+ | @Override | ||
+ | protected Gun createGun() { | ||
+ | FiringProfile firingProfile = new FiringProfile( | ||
+ | 1.0d, 500d, 3.0d, 150d, 0.5d, 450d, 700d); | ||
+ | Segmenter segmenter = new CompoundSegmenter( | ||
+ | new BulletTravelTimeSegmenter(getName(), 12, getBattlefieldBounds()), | ||
+ | new RelativeDirectionSegmenter(10)); | ||
+ | return new CompoundGun( | ||
+ | new StatGun(this, firingProfile, 1000, 10, 30, segmenter, true), | ||
+ | new CircularGun(firingProfile), | ||
+ | new LinearGun(firingProfile)); | ||
+ | } | ||
+ | |||
+ | } | ||
+ | </pre> |
Revision as of 06:25, 25 May 2011
The Xander framework is an AdvancedRobot framework that makes it easy to build new bots by combining different guns, radars, and drives. It is based on an abstract class named AbstractXanderBot that extends AdvancedRobot. For a gun, drive, or radar to be used in the Xander framework, it has to implement the corresponding interface Gun, Drive, or Radar.
Below is a list of pluggable components I've built so far. I have more planned.
Contents
Xander Radars
BasicRadar
Basic radar scan the field, and locks onto the first target it finds. Target can switch if another robot happens to be closer and drives through the scan beam.
Xander Guns
LinearGun
This gun is for targeting opponents that drive in a straight line. It fires on the opponent based on the opponents current speed and heading. It does not attempt to determine whether the target is actually moving in a straight line or not.
CircularGun
This gun is for targeting opponents that drive in circles. If the opponent does not appear to be going in circles, this gun will not fire on the target.
StatGun
This gun is a "guess factor" gun that relies on statistics to determine how to aim. If will not fire until there are sufficient stats to make a good guess. It relies on a Segmenter to determine how to categorize the statistics it collects (Segmenter is a separate interface).
CompoundGun
Combines two or more other guns. Compound gun delegates gunning to other guns based on the order they were added to the compound gun. Compound gun will check the guns in order until it finds a gun that claims it can fire on the designated target, and then allows that gun to fire.
Xander Drives
OrbitalDrive
This drive approaches the target using linear targeting and then, when it range, orbits around the target, changing direction periodically. It also uses "inverse gravity bullet avoidance"; this is currently somewhat experimental, and at present assumes the opponent is using either head-on or linear targeting (probably not a good idea agaist published robots who are likely mostly using guess factor guns).
AvoidanceDrive
This drive relies exclusively on "inverse gravity bullet avoidance" to control movement. Not really meant for real combat, this drive was created to test various aspects of bullet avoidance.
Example Xander Robot
As an example of how the Xander framework is used, below is the source for the main robot class of XanderCat 2.0.
/** * 1-on-1 robot built on the Xander framework. Also suitable for melee. * * @author Scott Arnold */ public class XanderCat extends AbstractXanderBot { @Override protected Level getLogLevel() { return Log.Level.INFO; } @Override protected Radar createRadar() { return new BasicRadar(this, 45, 5); } @Override protected Drive createDrive() { return new OrbitalDrive(this, 200, 40, 0.5f); } @Override protected Gun createGun() { FiringProfile firingProfile = new FiringProfile( 1.0d, 500d, 3.0d, 150d, 0.5d, 450d, 700d); Segmenter segmenter = new CompoundSegmenter( new BulletTravelTimeSegmenter(getName(), 12, getBattlefieldBounds()), new RelativeDirectionSegmenter(10)); return new CompoundGun( new StatGun(this, firingProfile, 1000, 10, 30, segmenter, true), new CircularGun(firingProfile), new LinearGun(firingProfile)); } }