我正在 Robocode 中创建一个简单的机器人。我有如下所示的功能墙:
public void walls() {
see = false;
wallBool = true;
double maxMove = Math.max(getBattleFieldWidth(), getBattleFieldHeight());
turnLeft(getHeading() % 90);
ahead(maxMove);
see = true;
turnRight(90);
turnGunRight((getHeading() - getGunHeading())+ 90);
while (getEnergy() <= 115) {
wallBool = true;
see = true;
ahead(maxMove);
see = false;
turnRight(90);
}
}
请注意,see
andwallBool
是我的代码前面已经声明过的变量。在函数内的 while 循环中,我调用了该turnRight();
方法,该方法应自动扫描其他机器人。但是,我的代码没有在我的onScannedRobot
函数中运行,包括如下:
public void onScannedRobot(ScannedRobotEvent e) {
System.out.println("check");
if (see==true) {
System.out.println("check2");
scan();
}
if (wallBool==true) {
fire(2);
}
支票永远不会打印到控制台。怎么了?
任何帮助将不胜感激...