Difference between revisions of "SuperTrackFire"

From Robowiki
Jump to navigation Jump to search
(Add download link)
(Add infobox)
 
Line 1: Line 1:
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.  
+
{{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
 +
}}
  
[http://robocode-archive.strangeautomata.com/robots/supersample.SuperTrackFire_1.0.jar 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 ==
 
== Movement ==
Line 10: Line 21:
  
 
== Code ==
 
== Code ==
 
 
<syntaxhighlight>package supersample;
 
<syntaxhighlight>package supersample;
  
Line 16: Line 26:
 
import robocode.*;
 
import robocode.*;
 
import java.awt.*;
 
import java.awt.*;
 
  
 
/**
 
/**
Line 25: 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

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
	}
}