Difference between revisions of "SuperTracker"
Jump to navigation
Jump to search
m |
(Add infobox) |
||
(5 intermediate revisions by 5 users not shown) | |||
Line 1: | Line 1: | ||
− | + | {{Infobox Robot | |
+ | | author = [[CrazyBassoonist]] | ||
+ | | extends = [[AdvancedRobot]] | ||
+ | | targeting = [[Linear Targeting]] | ||
+ | | movement = [[Aggressive Movement]] | ||
+ | | current_version = 1.0 | ||
+ | | license = Public domain | ||
+ | | download_link = http://robocode-archive.strangeautomata.com/robots/supersample.SuperTracker_1.0.jar | ||
+ | | isOpenSource = yes | ||
+ | | isMelee = no | ||
+ | | isOneOnOne = yes | ||
+ | }} | ||
+ | SuperTracker is a part of the [[Super Sample Bots]] set by [[CrazyBassoonist]]. It is intended to provide new robocoders with a new challenge after beating all of the [[Sample Bots|sample robots]]. | ||
== Movement == | == Movement == | ||
SuperTracker moves close to an enemy, then circles them perpendicularly. | SuperTracker moves close to an enemy, then circles them perpendicularly. | ||
− | |||
== Targeting == | == Targeting == | ||
− | SuperTracker uses a reduced linear gun for targeting. | + | SuperTracker uses a reduced [[Linear Targeting|linear gun]] for targeting. |
− | |||
== Code == | == Code == | ||
− | < | + | <syntaxhighlight> |
− | package | + | package supersample; |
import robocode.*; | import robocode.*; | ||
Line 36: | Line 46: | ||
setAdjustGunForRobotTurn(true); // Keep the gun still when we turn | setAdjustGunForRobotTurn(true); // Keep the gun still when we turn | ||
turnRadarRightRadians(Double.POSITIVE_INFINITY);//keep turning radar right | turnRadarRightRadians(Double.POSITIVE_INFINITY);//keep turning radar right | ||
− | + | } | |
/** | /** | ||
Line 64: | Line 74: | ||
} | } | ||
} | } | ||
+ | |||
public void onHitWall(HitWallEvent e){ | public void onHitWall(HitWallEvent e){ | ||
moveDirection=-moveDirection;//reverse direction upon hitting a wall | moveDirection=-moveDirection;//reverse direction upon hitting a wall | ||
} | } | ||
+ | |||
/** | /** | ||
* onWin: Do a victory dance | * onWin: Do a victory dance | ||
Line 76: | Line 88: | ||
} | } | ||
} | } | ||
− | } | + | }</syntaxhighlight> |
− | + | ||
+ | [[Category:Bots]] | ||
+ | [[Category:Super Sample Bots]] |
Latest revision as of 11:11, 4 September 2017
SuperTracker | |
Author(s) | CrazyBassoonist |
Extends | AdvancedRobot |
Targeting | Linear Targeting |
Movement | Aggressive Movement |
Current Version | 1.0 |
Code License | Public domain |
Download |
SuperTracker is a part of the Super Sample Bots set by CrazyBassoonist. It is intended to provide new robocoders with a new challenge after beating all of the sample robots.
Movement
SuperTracker moves close to an enemy, then circles them perpendicularly.
Targeting
SuperTracker uses a reduced linear gun for targeting.
Code
package supersample;
import robocode.*;
import java.awt.*;
/**
* SuperTracker - a Super Sample Robot by CrazyBassoonist based on the robot Tracker by Mathew Nelson and maintained by Flemming N. Larsen
* <p/>
* Locks onto a robot, moves close, fires when close.
*/
public class SuperTracker extends AdvancedRobot {
int moveDirection=1;//which way to move
/**
* run: Tracker's main run function
*/
public void run() {
setAdjustRadarForRobotTurn(true);//keep the radar still while we turn
setBodyColor(new Color(128, 128, 50));
setGunColor(new Color(50, 50, 20));
setRadarColor(new Color(200, 200, 70));
setScanColor(Color.white);
setBulletColor(Color.blue);
setAdjustGunForRobotTurn(true); // Keep the gun still when we turn
turnRadarRightRadians(Double.POSITIVE_INFINITY);//keep turning radar right
}
/**
* onScannedRobot: Here's the good stuff
*/
public void onScannedRobot(ScannedRobotEvent e) {
double absBearing=e.getBearingRadians()+getHeadingRadians();//enemies absolute bearing
double latVel=e.getVelocity() * Math.sin(e.getHeadingRadians() -absBearing);//enemies later velocity
double gunTurnAmt;//amount to turn our gun
setTurnRadarLeftRadians(getRadarTurnRemainingRadians());//lock on the radar
if(Math.random()>.9){
setMaxVelocity((12*Math.random())+12);//randomly change speed
}
if (e.getDistance() > 150) {//if distance is greater than 150
gunTurnAmt = robocode.util.Utils.normalRelativeAngle(absBearing- getGunHeadingRadians()+latVel/22);//amount to turn our gun, lead just a little bit
setTurnGunRightRadians(gunTurnAmt); //turn our gun
setTurnRightRadians(robocode.util.Utils.normalRelativeAngle(absBearing-getHeadingRadians()+latVel/getVelocity()));//drive towards the enemies predicted future location
setAhead((e.getDistance() - 140)*moveDirection);//move forward
setFire(3);//fire
}
else{//if we are close enough...
gunTurnAmt = robocode.util.Utils.normalRelativeAngle(absBearing- getGunHeadingRadians()+latVel/15);//amount to turn our gun, lead just a little bit
setTurnGunRightRadians(gunTurnAmt);//turn our gun
setTurnLeft(-90-e.getBearing()); //turn perpendicular to the enemy
setAhead((e.getDistance() - 140)*moveDirection);//move forward
setFire(3);//fire
}
}
public void onHitWall(HitWallEvent e){
moveDirection=-moveDirection;//reverse direction upon hitting a wall
}
/**
* onWin: Do a victory dance
*/
public void onWin(WinEvent e) {
for (int i = 0; i < 50; i++) {
turnRight(30);
turnLeft(30);
}
}
}