在Robocode里面加入一中方法要怎么样用啊?
比如要把对
public void run() {
    while(true) {
        setTurnRightRadiansOptimal(adjustHeadingForWalls(0));
        setAhead(100);
        execute();
    }
}
这个东西加入到程序当中去,要怎么样加啊?
谢谢各位高手指导哈哦。

解决方案 »

  1.   

    你自己写一个机器人,然后把自己的class路径加入robocode运行环境,然后选择自己的机器人坦克
      

  2.   

    package student;
    import robocode.*;
    //import java.awt.Color;/**
     * No40801342 - a robot by (your name here)
     */
    public class No40801342 extends Robot
    {
    /**
     * run: No40801342's default behavior
     */
    public void run() {
    // After trying out your robot, try uncommenting the import at the top,
    // and the next line:
    //setColors(Color.red,Color.blue,Color.green);
    while(true) {
    // Replace the next 4 lines with any behavior you would like
    ahead(200);
    turnGunRight(210);
    back(100);
    turnGunRight(270);
    }
    } /**
     * onScannedRobot: What to do when you see another robot
     */
    public void onScannedRobot(ScannedRobotEvent e) {
    fire(3);
    } /**
     * onHitByBullet: What to do when you're hit by a bullet
     */
    public void onHitByBullet(HitByBulletEvent e) {
    turnLeft(90 - e.getBearing());
    }

    }
    以上这个是一个源程序,我想把
    public void run() { 
        while(true) { 
            setTurnRightRadiansOptimal(adjustHeadingForWalls(0)); 
            setAhead(100); 
            execute(); 
        } 

    加到里面去,我不熟悉这个啊,你能帮忙加进去吗?没加之前编译那些都没有问题