Pages

Sunday, January 16, 2011

Starting with Robocode

Another project in here.. Robocode...
Have you heard about it?? The famous line "Build the best - destroy the rest!"... It's actually coding or developing a tank or a robot tank I guess that you will send into the battle field with other robot tanks, probably a sample robot or your friends own robots too.. It's programming language is Java and I think there's another one but I'm not so familiar with it.. If you wanna check more about it just visit its site.. http://robocode.sourceforge.net/

Hmm.. this is our Individual project from our Software Engineering class. And I just have to start it right now or I won't have much time for it by next weeks... So first thing first.. I opened Robocode's editor and try to see its template.. and here it goes..

package LadyCid;
import robocode.*;
import java.awt.Color;

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

/**
 * RoboBot_Ver1_00 - a robot by (your name here)
 */
public class RoboBot_Ver1_00 extends Robot
{
/**
* run: RoboBot_Ver1_00'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:
// Robot main loop
while(true) {
// Replace the next 4 lines with any behavior you would like
ahead(100);
turnGunRight(360);
back(100);
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(1);
}

/**
* 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(10);
}
/**
* onHitWall: What to do when you hit a wall
*/
public void onHitWall(HitWallEvent e) {
// Replace the next line with any behavior you would like
back(20);
}
}

I didn't remove the comments for everyone's happiness (lol)..
I named the package by my initials "LadyCid" and named my very first robot as "RoboBot_Ver1_00"
I can't think of any name for now so for the mean time just version 1.00

0 comments:

Post a Comment