package exe; import robocode.*; import baseRobot.*; import java.awt.Color; /** * @author Fumi Iseki * * 演習用 Level-n ロボット * */ public class Level_n extends BaseRobot { private double xMax, yMax; public void run() { setColors(Color.yellow, Color.yellow, Color.yellow); xMax = this.getBattleFieldWidth(); yMax = this.getBattleFieldHeight(); double wa; double xx = this.getX(); double yy = this.getY(); if (xx < xMax/2) { if (yy < yMax/2) { if (xx < yy) wa = 270.; else wa = 180.; } else { if (xx < yMax-yy) wa = 270.; else wa = 0.; } } else { if (yy < yMax/2) { if (xMax/2-xx < yy) wa = 90.; else wa = 180; } else { if (xMax/2-xx < yMax-yy) wa = 90.; else wa = 0.; } } double kd = getRelAngle(wa, getHeading()); turnRight(kd); while(true) { turnGunRight(3600); } } public void onScannedRobot(ScannedRobotEvent e) { fire(3); } }