Codigo de super robot en robocode

download Codigo de super robot en robocode

of 2

Transcript of Codigo de super robot en robocode

  • 7/26/2019 Codigo de super robot en robocode

    1/2

    package jose.pp;import robocode.ScannedRobotEvent;import robocode.RateControlRobot;import java.awt.Color;import robocode.HitWallEvent;

    //import java.awt.Color;

    // API help : http://robocode.sourceforge.net/docs/robocode/robocode/Robot.html

    /*** Jose - a robot by (Jose Julian)*/

    public class Jose2 extends RateControlRobot {

    int turnCounter;public void run() {

    setBodyColor(Color.blue);setGunColor(Color.blue);setRadarColor(Color.blue);setScanColor(Color.green);setBulletColor(Color.red);

    turnCounter = 0;setGunRotationRate(15);

    while (true) {if (turnCounter % 64 == 0) {

    // Straighten out, if we were hit by a bullet and are turning

    setTurnRate(0);// Go forward with a velocity of 4setVelocityRate(4);

    }

    if (turnCounter % 64 == 32) {// Go backwards, fastersetVelocityRate(-6);

    }turnCounter++;execute();

    }}

    /*** onScannedRobot: What to do when you see another robot*/

    public void onScannedRobot(ScannedRobotEvent e) {

    if ((getEnergy()getEnergy())){

    setAhead(e.getDistance()-100);setTurnRight(e.getBearing());

    double superapuntar=getHeading()+e.getBearing();double apuntar=anguloRelNorm(superapuntar-getGunHeading(

    ));

  • 7/26/2019 Codigo de super robot en robocode

    2/2

    //Gira el caonif (Math.abs(apuntar)