Circular Targeting

(Redirected from CircularTargeting)

Description

A method of targeting which assumes that the target will continue moving with the same turn rate and at the same speed.

Example

This is the code used in WaveSurfing Challenge Bot C:

```//Add import robocode.util.* for Utils and import java.awt.geom.* for Point2D
//This code goes in your onScannedRobot() event handler

double bulletPower = Math.min(3.0,getEnergy());
double myX = getX();
double myY = getY();
double enemyX = getX() + e.getDistance() * Math.sin(absoluteBearing);
double enemyY = getY() + e.getDistance() * Math.cos(absoluteBearing);
double enemyVelocity = e.getVelocity();

double deltaTime = 0;
double battleFieldHeight = getBattleFieldHeight(),
battleFieldWidth = getBattleFieldWidth();
double predictedX = enemyX, predictedY = enemyY;
while((++deltaTime) * (20.0 - 3.0 * bulletPower) <
Point2D.Double.distance(myX, myY, predictedX, predictedY)){
if(	predictedX < 18.0
|| predictedY < 18.0
|| predictedX > battleFieldWidth - 18.0
|| predictedY > battleFieldHeight - 18.0){

predictedX = Math.min(Math.max(18.0, predictedX),
battleFieldWidth - 18.0);
predictedY = Math.min(Math.max(18.0, predictedY),
battleFieldHeight - 18.0);
break;
}
}
double theta = Utils.normalAbsoluteAngle(Math.atan2(
predictedX - getX(), predictedY - getY()));

fire(3);```

v  d  e
Quick
Statistical
Log-Based
Heuristics
Hybrid
Firing Angle
Energy
Terms
Related