Wednesday, September 16, 2009

Robocode Strategy Analysis - Preparing For Battle

“To be prepared is half the victory.”
- Miguel de Cervantes Saavedra

One of the main objectives of building Robocode robots is to program robots for competitions. Thus far, my Robocode experience has consisted of programming basic robots that often do not attempt to attack enemy robots in any way, shape or form. Now, I have embarked upon the first steps in the process of building a competitive robot.

The Robocode download includes fifteen sample robots that make use of a wide variety of strategies. I looked at some of these robots while completing my thirteen basic robots for class, but for the most part, they were robots that I could include in a field to test anything that was supposed to track and/or fire at enemies. So today, I examined eight of the sample robots, and looked at their approaches to the following elements of robot operation:
  • Movement: How does the robot move? Does it have an avoidance or following strategy?
  • Targeting: How does it find a target to fire?
  • Firing: What is its criteria for firing?
What follows are my observations on the robots that I studied.



Walls
"Moves around the outer edge with the gun facing in"
Movement: Generally ignores enemies during movement. If it collides with an enemy it moves away from the enemy slightly, before continuing its usual pattern of movement.
Targeting: Moves along outer wall in a regular pattern; fires at any enemy robot when scanned
Firing: Fires at any enemy

Overall observations: This seems to be a good way for a robot to stay alive, but it does not appear to be very efficient in killing other robots because the robot has very few opportunities to shoot at any one robot.



RamFire
"Drives at robots, trying to ram them. Fires when it hits them."
Movement: RamFire tries to ram into robots, which earns bonus points.
Targeting: It does not fire until it is hitting a robot. It does not track any enemy in particular.
Firing: It fires at any enemy, once it rams into the enemy. It uses a low enough power that the target will not die, so that RamFire can continue to ram into the enemy.

Overall observations: This seems to be a very effective way to earn bonus points in battle.



SpinBot
"Moves in a circle, firing hard when an enemy is detected"
Movement: Turns continuously in a circle; neither follows nor avoids enemies, although if it rams into another robot, it moves off to the side before resuming circling, thus giving it a slight avoidance technique.
Targeting: It continuously turns in a circle, searching for enemies.
Firing: Fires at any enemy spotted, with the maximum bullet power.

Overall Observations: This seems to be a good way to inflict a high amount of damage on enemies, but I'm not sure that it's a good idea to always use the highest possible power when firing at any enemy. It seems to have good evasion tactics against other robots, since it's more difficult for a robot to aim at SpinBot.



Crazy
"Moves around in a crazy pattern"
Movement: Does exactly as its name says; swerves left and right, reversing if it hits walls or robots. Moves away from robots it hits, so somewhat of an avoidance strategy, although it isn't proactive.
Targeting: Just looks for anything that crosses its path.
Firing: Fires indiscriminately at any enemy it sees.

Overall Observations: This robot really lives up to its name! It seemed to do reasonably well in combat, but I really couldn't follow what it was doing and a lot of what it succeeded in doing appeared to be luck, since it moves around randomly until it happens to hit something.



Fire
"Sits still. Spins gun around. Moves when hit."
Movement: Moves only when hit by a bullet.
Targeting: Spins its gun slowly, aiming at everything it detects.
Firing: Takes health into account while firing. Fires larger bullets if the target is healthy and nearby close. Otherwise, fires using power 1.

Overall observations: This is a simple robot that still attacks with some strategy.



Sitting Duck
"Sits there and provides a target until dead."
Movement: Does not move at all.
Targeting: Does not target at all.
Firing: Does not fire at all.

Overall observations: A good robot to use while testing, but it definitely does not have any strategies that I would want to make use of in combat.



Corners
"Moves to a corner, then swings the gun back and forth. If it dies, it tries a new corner in the next round."
Movement: Runs into a wall, turns left, and hits a corner. If it sees a robot, it stops and aims at it.
Targeting: Pans back and forth from the corner, targeting the first robot it sees.
Firing: Fires using more powerful bullets the closer the target is to itself.

Overall Observations: Corners seems rather vulnerable to other robots because it sits in one place for the entire round. Any robot that picked a specific target to attack would probably have a huge advantage against Corners.



Tracker
"Picks one robot, follows it to a certain distance, and attacks it until it's dead."
Movement: Scans the area, not moving until a robot is spotted. Once a target is spotted, Tracker follows it within 80 pixels or so, attempting to maintain this distance. It does not move if it loses it's target.
Targeting: Targets a single robot, and fires upon it until it's dead.
Firing: Fires with a power of 3 at the target robot no matter what.

Overall Observations: Tracker does what its name says very well. However, it doesn't seem like this is an effective single strategy for battle.



Overall, this exercise was useful because I was able to see the full range of possible strategies I could have my robots adapt. The one main idea that seemed to work was to have the robot keep moving - SittingDuck and Corners both were very unsuccessful in killing enemy robots. I think that I am beginning to formulate some ideas as to what strategies I would have a competitive robot implement, but the one thing that this exercise has shown me is that testing will be a big part of perfecting whatever plan I do decide to work on.

No comments:

Post a Comment