# UbaRamLT

Robo Home | Changes | Preferences | AllPages

Difference (from prior major revision) (minor diff, author diff)

Changed: 74c74
 if(e.getDistance() < 200)
 //if(e.getDistance() < 200)

 Okay, improvement made! It really helped, so thanks. I just used the code in BackAsFront. Plus, it killed Dookious in a 10 round match (which doesn't mean much b/c it's only 10 rounds, but it means I'm improving!) --Bayen

This bot is based almost completely off the WaveSurfing Challenge bot B. I just wanted to make it quick so I copied someone else's LT gun. Sorry. --Bayen
```
package bayen;

import java.awt.geom.Point2D;

import robocode.ScannedRobotEvent;
import robocode.util.Utils;

public void run(){
do{
} while(true);
}

public void onScannedRobot(ScannedRobotEvent e){
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) * (8) < 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()));
deltaTime = 0;
predictedX = enemyX;
predictedY = enemyY;
double turnAmt = theta;
double moveAmt = Double.POSITIVE_INFINITY;
moveWithBackAsFront(moveAmt, turnAmt);
while((++deltaTime) * (11) < 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;
}
}
theta = Utils.normalAbsoluteAngle(Math.atan2(predictedX - getX(), predictedY - getY()));
//if(e.getDistance() < 200)
fire(3);
}
void moveWithBackAsFront(double distance, double bearing) {
double turnAngle = Math.atan(Math.tan(angle));
int direction = angle == turnAngle ? 1 : -1;
}

}
```

The first improvement I should do, is to do something like BackAsFront. Instead of sometimes turning more than 90 degrees at start, you then take the shortest path to where you want to go. -- GrubbmGait

Okay, improvement made! It really helped, so thanks. I just used the code in BackAsFront. Plus, it killed Dookious in a 10 round match (which doesn't mean much b/c it's only 10 rounds, but it means I'm improving!) --Bayen

Robo Home | Changes | Preferences | AllPages