Difference between revisions of "SuperTrackFire"
Jump to navigation
Jump to search
(SuperTrackFire) |
(Add infobox) |
||
(4 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
− | + | {{Infobox Robot | |
+ | | author = [[CrazyBassoonist]] | ||
+ | | extends = [[AdvancedRobot]] | ||
+ | | targeting = Inaccurate [[Head-On Targeting]] | ||
+ | | movement = [[Random Movement|Random]] [[Pattern Movement]] | ||
+ | | current_version = 1.0 | ||
+ | | license = Public domain | ||
+ | | download_link = http://robocode-archive.strangeautomata.com/robots/supersample.SuperTrackFire_1.0.jar | ||
+ | | isOpenSource = yes | ||
+ | | isMelee = no | ||
+ | | isOneOnOne = yes | ||
+ | }} | ||
+ | SuperTrackFire 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 == | == Movement == | ||
SuperTrackFire uses a random oscillating movement. It's movement is quite bad, it will run into walls alot. This should be one of the easiest [[Super Sample Bots]] to beat. | SuperTrackFire uses a random oscillating movement. It's movement is quite bad, it will run into walls alot. This should be one of the easiest [[Super Sample Bots]] to beat. | ||
− | |||
== Targeting == | == Targeting == | ||
SuperTrackFire locks its gun on and then jiggles it just a little bit so that it does not always fire exactly head-on. | SuperTrackFire locks its gun on and then jiggles it just a little bit so that it does not always fire exactly head-on. | ||
− | |||
− | |||
== Code == | == Code == | ||
+ | <syntaxhighlight>package supersample; | ||
− | + | import robocode.util.*; | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | import robocode.util. | ||
import robocode.*; | import robocode.*; | ||
import java.awt.*; | import java.awt.*; | ||
− | |||
/** | /** | ||
Line 31: | Line 34: | ||
public class SuperTrackFire extends AdvancedRobot { | public class SuperTrackFire extends AdvancedRobot { | ||
int dir=1;//Which way we want to move | int dir=1;//Which way we want to move | ||
+ | |||
/** | /** | ||
* TrackFire's run method | * TrackFire's run method | ||
Line 54: | Line 58: | ||
double maxEscapeAngle = Math.asin(8.0/(20 - (3 *Math.min(3,getEnergy()/10))));//farthest the enemy can move in the amount of time it would take for a bullet to reach them | double maxEscapeAngle = Math.asin(8.0/(20 - (3 *Math.min(3,getEnergy()/10))));//farthest the enemy can move in the amount of time it would take for a bullet to reach them | ||
double randomAngle = randomGuessFactor * maxEscapeAngle;//random firing angle | double randomAngle = randomGuessFactor * maxEscapeAngle;//random firing angle | ||
− | double firingAngle = | + | double firingAngle = Utils.normalRelativeAngle(absoluteBearing - getGunHeadingRadians()+randomAngle/3);//amount to turn our gun |
setTurnLeftRadians(-90-e.getBearingRadians()*dir);//Turn perpendicular to them | setTurnLeftRadians(-90-e.getBearingRadians()*dir);//Turn perpendicular to them | ||
setTurnGunRightRadians(firingAngle);//Aim! | setTurnGunRightRadians(firingAngle);//Aim! | ||
setAhead(100*Math.random()*dir); | setAhead(100*Math.random()*dir); | ||
setFire(getEnergy()/10);//Fire, using less energy if we have low energy | setFire(getEnergy()/10);//Fire, using less energy if we have low energy | ||
− | setTurnRadarRightRadians( | + | setTurnRadarRightRadians(Utils.normalRelativeAngle(absoluteBearing-getRadarHeadingRadians()));//lock on the radar |
if(Math.random()>.9){ | if(Math.random()>.9){ | ||
dir=-dir;//randomly changing move and turn direction | dir=-dir;//randomly changing move and turn direction | ||
Line 67: | Line 71: | ||
dir=-dir;//change direction when we hit the wall | dir=-dir;//change direction when we hit the wall | ||
} | } | ||
− | } </ | + | }</syntaxhighlight> |
+ | |||
+ | [[Category:Bots]] | ||
+ | [[Category:Super Sample Bots]] |
Latest revision as of 11:35, 4 September 2017
SuperTrackFire | |
Author(s) | CrazyBassoonist |
Extends | AdvancedRobot |
Targeting | Inaccurate Head-On Targeting |
Movement | Random Pattern Movement |
Current Version | 1.0 |
Code License | Public domain |
Download |
SuperTrackFire 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
SuperTrackFire uses a random oscillating movement. It's movement is quite bad, it will run into walls alot. This should be one of the easiest Super Sample Bots to beat.
Targeting
SuperTrackFire locks its gun on and then jiggles it just a little bit so that it does not always fire exactly head-on.
Code
package supersample;
import robocode.util.*;
import robocode.*;
import java.awt.*;
/**
* TrackFire - a Super Sample Bot by CrazyBassoonist, based on TrackFire Mathew Nelson and maintained by Flemming N. Larsen
* <p/>
*Random oscillating movement with slightly random Head-On Targeting
*/
public class SuperTrackFire extends AdvancedRobot {
int dir=1;//Which way we want to move
/**
* TrackFire's run method
*/
public void run() {
// Set colors
setAdjustRadarForGunTurn(true);
setAdjustGunForRobotTurn(true);
setBodyColor(Color.pink);
setGunColor(Color.pink);
setRadarColor(Color.pink);
setScanColor(Color.pink);
setBulletColor(Color.pink);
turnRadarRightRadians(Double.POSITIVE_INFINITY);//turnRadarRight
}
/**
* onScannedRobot: We have a target. Go get it.
*/
public void onScannedRobot(ScannedRobotEvent e) {
double absoluteBearing = getHeadingRadians() + e.getBearingRadians();//robot's absolute bearing
double randomGuessFactor = (Math.random() - .5) * 2;
double maxEscapeAngle = Math.asin(8.0/(20 - (3 *Math.min(3,getEnergy()/10))));//farthest the enemy can move in the amount of time it would take for a bullet to reach them
double randomAngle = randomGuessFactor * maxEscapeAngle;//random firing angle
double firingAngle = Utils.normalRelativeAngle(absoluteBearing - getGunHeadingRadians()+randomAngle/3);//amount to turn our gun
setTurnLeftRadians(-90-e.getBearingRadians()*dir);//Turn perpendicular to them
setTurnGunRightRadians(firingAngle);//Aim!
setAhead(100*Math.random()*dir);
setFire(getEnergy()/10);//Fire, using less energy if we have low energy
setTurnRadarRightRadians(Utils.normalRelativeAngle(absoluteBearing-getRadarHeadingRadians()));//lock on the radar
if(Math.random()>.9){
dir=-dir;//randomly changing move and turn direction
}
}
public void onHitWall(HitWallEvent e){
dir=-dir;//change direction when we hit the wall
}
}