Robocode Print E-mail
Thursday, 27 April 2006

ImageRobocode is an application that allows robots (small tanks) to go to battle in an arena. You have to design the intelligence of your robot yourself. This is done in the Java programming language. A while back, I designed two simple robots. This page is dedicated to them. What's really cool about Robocode is that by implementing just a couple of methods, you can have immediate visual feedback (and gratification). My robots do a little more than implement the bare basics, but are in no way competitive with the worlds best. I think Robocode is a fun way of learning how to program (and particularly in Java). It's fun to compete with your buddies/colleagues.

Image

Dodger
This robot tries to dodge all bullets fired at it. At the same time, it tries to keep a great distance with its enemy (thus increasing the time between the fired bullet and possible impact).

A major weakness of this robot is the fact that it can get stuck in the corner of the arena quite easily. It's strength is the fact that you need more than a simple aim and fire algorithm to hit it.

ImageDeathsTooGood
This robot is more complex. It has three strategies, and it switches between them depending on its health level. The first mode is agressive. It homes in on its enemy and fires away. It tries to avoid bullets, but at close range, that can be a problem. When its health is below a certain point, it goes into defensive mode and behaves much like Dodger. Finally, when it's health is very low, it flees from its enemy. It stops firing hoping that its opponent runs out of ammo/health.

The robot keeps track of some statistics. It tries to determine which strategy is most effective. When battling many rounds, it will (after a couple of rounds) start using the most effective strategy straight away.

Even though DeathsTooGood is more advanced than Dodger, it will not win from it. DeathsTooGood, on the other hand, will win from many other robots, including many that Dodger will loose from.

ImageIn the end, I realiazed that programming a certain pattern of attack/defence is not the way to go. In order to create a great robot, you must learn from your mistakes. When playing 100 rounds, you'll 'know' (after some rounds) how your enemy behaves. You must adjust your strategy dynamically. You need artificial intelligence. Needless to say, code that does that is quite complicated.

Both robots can be downloaded from the download section. The available ZIP contains the two JAR files of the two robots that can be deployed directedly once you have Robocode installed. The JAR files contain the source code.

Image

Only registered users can write comments.
Please login or register.


Last Updated ( Tuesday, 09 May 2006 )
 
< Prev   Next >
2006 Vangilz.com. All Rights Reserved.