0% found this document useful (0 votes)
24 views

Código de Robocode

The document contains code for a robot named Velez in the Robocode programming game. The code defines the basic behaviors for the robot, including moving ahead, turning, backing up, and firing when other robots are scanned. It also includes comments explaining the functions and placeholders for the programmer to add their own behaviors. The programmer is asking for understanding and collaboration from their professor as they are unable to compile the code directly in the game.

Uploaded by

brandon mateus
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views

Código de Robocode

The document contains code for a robot named Velez in the Robocode programming game. The code defines the basic behaviors for the robot, including moving ahead, turning, backing up, and firing when other robots are scanned. It also includes comments explaining the functions and placeholders for the programmer to add their own behaviors. The programmer is asking for understanding and collaboration from their professor as they are unable to compile the code directly in the game.

Uploaded by

brandon mateus
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Código de robocode

Cordial saludo

Profe no sé cómo compilarlo desde el juego así que adjunto el código en este Word

Agradezco de su comprensión y colaboración

package Vz;

import robocode.*;

//import java.awt.Color;

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

/**

* Velez - a robot by (your name here)

*/

public class Velez extends Robot

/**

* run: Velez's default behavior

*/

public void run() {

// Initialization of the robot should be put here

// After trying out your robot, try uncommenting the import at the top,

// and the next line:

// setColors(Color.red,Color.blue,Color.green); // body,gun,radar

// Robot main loop

while(true) {

// Replace the next 4 lines with any behavior you would like
ahead(300);

turnGunRight(360);

back(200);

turnGunRight(360);

/**

* onScannedRobot: What to do when you see another robot

*/

public void onScannedRobot(ScannedRobotEvent e) {

// Replace the next line with any behavior you would like

fire(500);

/**

* onHitByBullet: What to do when you're hit by a bullet

*/

public void onHitByBullet(HitByBulletEvent e) {

// Replace the next line with any behavior you would like

back(30);

/**

* onHitWall: What to do when you hit a wall

*/

public void onHitWall(HitWallEvent e) {

// Replace the next line with any behavior you would like

ahead(1000);
}

Adjunto pantallazos de evidencia

You might also like