cs175:adjustfirebot_template
AdjustFireBot2 template
import robocode.*;
// API help : http://robocode.sourceforge.net/docs/robocode/robocode/Robot.html
/**
* AdjustFireBot2 - a robot by (your name here)
*/
public class AdjustFireBot2 extends Robot
{
// Declare instance variables for this robot here:
private double height; // field height
private double width; // field width
private double maxDist; // Max distance = distance from one corner of the
field to the opposite corner
/**
* run: AdjustFireBot2's default behavior
*/
public void run() {
// (Note: It's illegal to call getBattleFieldHeight() and getBattleFieldWidth()
// before the run() method, so must call those methods in here.)
height = getBattleFieldHeight();
width = getBattleFieldWidth();
maxDist = /* You compute maxDist here. */;
// Robot main loop
while(true) {
// Don't have to change this:
ahead(100);
turnGunRight(360);
back(100);
turnGunRight(360);
}
}
/**
* onScannedRobot: What to do when you see another robot
*/
public void onScannedRobot(ScannedRobotEvent e) {
// 1 - Get distance to other robot:
// 2 - Call the adjustFire method with distance from 1 as input:
}
/**
* adjustFire: Fire cannon with power adjusted by distance to target
*/
public void adjustFire(double distance) {
// 1 - Compute fire power based on value of distance:
// 2 - Fire cannon using fire power from 1:
}
}
cs175/adjustfirebot_template.txt · Last modified: by jchung
