I am creating a simple robot in Robocode. I have a function walls shown below:
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);
}
}
Note that see
and wallBool
are variables which have already been declared earlier in my code. In the while loop within the function, I call the turnRight();
method, which should automatically scan for other robots. However, my code does not run in my onScannedRobot
function, included below:
public void onScannedRobot(ScannedRobotEvent e) {
System.out.println("check");
if (see==true) {
System.out.println("check2");
scan();
}
if (wallBool==true) {
fire(2);
}
Check is never printed to the console. What's wrong?
Any help would be greatly appreciated...