Я пытаюсь скомпилировать робота на робокоде, но он сказал, что «статический импорт доступен только при уровне источника 1,5 или выше»
Я не понял, что это значит.На других форумах я видел, что это может быть обновление Java, но на моем компьютере уже установлена последняя версия Java.Что я могу сделать?
Это код, который я пытался скомпилировать:
package blir.dev;
import robocode.*;
import java.awt.Color;
import static robocode.util.Utils.*;
/**
* Blixi - a robot by Travis Bruce
*/
public class Keen_Stalker extends AdvancedRobot {
//the direction we're moving
private int dir = 1;
//are we close to a wall? : are we close to a robot?
private boolean wall = false, rbt = false;
//enemy's energy
private double en = 100D;
/**
* run: Blixi's default behavior
*/
public void run() {
setColors(Color.BLACK, Color.DARK_GRAY, Color.DARK_GRAY);
setAdjustRadarForRobotTurn(true);
setAdjustGunForRobotTurn(true);
setAdjustRadarForGunTurn(true);
//if (bshot1 != 0) out.println("Main Gun Accuracy: " + (double) bhit1 / bshot1);
for (;;) {
if (getRadarTurnRemaining() == 0) {
//should only happen if we lose track of them, which should never happen
setTurnRadarRight(Double.POSITIVE_INFINITY);
}
//check if we're too close to the wall (50 pixels)
wall = cw(50, true);
execute();
}
}
/**
* onScannedRobot: What to do when you see another robot
*/
public void onScannedRobot(ScannedRobotEvent e) {
//check if we're too close to the other robot (150 pixels)
rbt = d(e.getDistance());
//absolute bearing
double absBear = getHeadingRadians() + e.getBearingRadians();
//track them with our radar
double radarTurn = normalRelativeAngle(absBear - getRadarHeadingRadians());
radarTurn += (radarTurn < 0 ? -1 : 1) * Math.atan(36.0 / e.getDistance());
setTurnRadarRightRadians(radarTurn);
//fire power the enemy used
double enemyPower = en - e.getEnergy();
if (enemyPower <= 3 && enemyPower > 0 && !cw(75, false)) {
//they seem to have fired
cd();
}
//record new energy
en = e.getEnergy();
//circle around them if we're close enough, move away if we're too close
setTurnRightRadians(normalRelativeAngle(e.getBearingRadians() + Math.PI / 2D));
setTurnGunRightRadians(normalRelativeAngle(absBear - getGunHeadingRadians() -
Math.asin(e.getVelocity() * Math.sin(Math.PI - absBear + e.getHeadingRadians()) / Rules.getBulletSpeed(Rules.MAX_BULLET_POWER))));
//fire!
setFire(Rules.MAX_BULLET_POWER);
//all power ahead!
setAhead(dir * 32);
}
public void onHitWall(HitWallEvent e) {
//out.println("Ahh! A wall!");
cd();
}
private boolean d(double d) {
if (d < 150) {
//we're close to the robot (within 150 pixels)
if (!rbt) {
//we're not already escaping the robot, so let's change direction
cd();
}
return true;
}
return false;
}
private boolean cw(int d, boolean cw) {
if (getX() < d || getY() < d || getBattleFieldWidth() - getX() < d || getBattleFieldHeight() - getY() < d) {
//we're close to the wall
if (!wall && cw) {
//we're not already escaping the wall, so let's change direction
cd();
}
return true;
}
return false;
}
private void cd() {
dir = -dir;
}