Friday, February 10, 2006


Name: Robocode
Author: Mathew Nelson
License: Open-Source Freeware

This is the fifth and final entry in my programming logic games series. This week's entry is on Robocode. In this game, you have to program a robot in Java. You program how it moves and turns. You program how it hunts for opponent robots. You program how it turns its gun and fires. Your program can be simple or as complicated as the Java Virtual Machine allows.

The Robocode API is quite rich. There are movement commands like ahead() and turnRight(). There are weapon commands like turnGunLeft() and fire(). There are routines to help you track the other robots such as turnRadarLeft() and getRadarHeading(). There are also events such as onHitByBullet() and onScannedRobot() which allow you to send special instructions to your robot when these events happen. And there are many, many more. Here is a very simple Robocode robot program.

Once your robot is ready. You can start a battle to see how it fares in competition. Robocode comes with several sample robots to compete against. You select which robots are to battle and let them go at it. Here JimmyBot is about to do some damage to TrackFire. You get to see in a very visual way how well or poorly your program is doing.

Obviously, there is steep learning curve to Robocode. First, you have to learn Java if you do not already know it. Second you have to learn the Robocode API. And to do well, you have to learn the physics of the Robocode world: how fast do robots turn and move, how fast bullet fly, and how often can you fire. So, this game will not appeal to everyone, but if you have done some programming or would like to learn, I think Robocode is well worth trying.

With some practice, you can program a robot which can beat all of the sample robots which come with the game. If you need a little help, there are several on-line resources available. One of the best is the RoboWiki. The on-line Robocode following is tremendous. Once the sample robots lose their challenge, you can move on to robots written by other humans, look in the Robocode Repository for some. And if you get really good, you can try your hand at some competitions. My one hint to Robocode newbies is to use setColor() to change the color of your robot when it enters different parts of your program. I found this helps with the debugging.

There are two aspects to Robocode which I really like. One is that it encourages writing efficient coding. If you waste time doing some complicated computation, the other robots are going to eat you up. The other is to program a top notch robot, you have to use some sophisticated math and computer science techniques.

There is one thing about Robocode which I do not like: the built in editor. It is fine for changing a line or two, but not for any heavy duty coding. I wish there was a way to use a real editor, like emacs, within the game.

Robocode is really just the latest version of a series of progamming robot games dating back to the days when I had hair. In the 80s, there was c-robots and then p-robots in which you had to program your robots in C and Pascal respectively. I do not know if these are still playable today, but remember spending a lot of time with p-robots. More recently (the 90s), C++-robots came along. I am willing to bet that if do a search for foo-robots where foo is your favorite programming language, you will probably find it.

There is one last game which I want to mention, Robot Battle. This is very similar to Robocode. It was made freeware a couple of years and has a strong following. I have not spent much time playing with it, but it looks pretty good.

One last thing (really!!), Electronic Arts is sponsoring a contest to program the AI for their Tank Wars game. It kind of looks like EA is trying to get people to do their programming for them for free. Philosophically, I would suggest people work on open-source projects, but this might be a way to get yourself noticed.


At 8:48 AM, Anonymous kamagra said...

This is a complete challenge for me because I consider I'm a gamer, but I've never played a game like this where I have program a robot in Java, so that's perfect because I'm gonna improve my skills to reach it.m10m


Post a Comment

<< Home