Tuesday, September 15, 2009

Robot Strategies

Now that I've learned the basics to Robocode, there are also strategies to consider. What are some strategies out there that work and that can provide me with some insight to how a robot is successful in the battle field? I was assigned to look at the sample code provided in the Robocode directory. Here's what I found:
  • Walls
Movement
- The main strategy of this robot is to find the closest wall, and run around in straight lines.
It's one of the simplest and most effective strategies. Because when it goes to the side of the wall it covers a big area in which the robot can now no longer be hit.
The robot can only be hit at other are from 180 degrees. This is a dominant robot amongst the sample robots.
Targeting-Uses a boolean variable to scan when the robot is moving, but not when it's turning.
Firing-It shoots at anything it sees.
  • RamFire
Movement-This robot always moves toward the target. It wants to collide with robots to deal damage for a ram bonus.
Targeting-The first robot it sees.
Firing-It fires at any robot, but it does not shoot to kill. It wants to ram robots to death.
  • SpinBot
Movement-It turns right as much as it can during one turn.
Targeting-No targeting.
Firing-Fire if it sees another robot.
  • Crazy
Movement-It moves in an unpredictable fashion so a robot that uses a repetitive algorithm will not hit it twice at the same spot. It will also move crazy even when backing up.
Targeting-No targeting.
Firing-Fires on sight of any robot. It's the same fire power every time.
  • Fire
Movement-This robot moves a little and most of the strategy is in running away when it's been hit.
Targeting-It has really bad tracking. It's very ineffective since it doesn't keep it's gun trained on the target.
Firing-Fire power is determined by whether the target is 50 pixels away or within 50 pixels.
  • Sitting Duck
Movement-None. This robot is basically a target for all the robots.
Targeting-None
Firing-None
  • Corners
Movement-It goes to the corner. It also keeps battle data to determine whether to switch corners next round, if 75% of other robots are still alive at the time of it's death.
Targeting-Once it's at a corner, the robot turns it's gun around to search for targets.
Firing-Fire power is determined by the enemies distance away from it. The closer the target is, the stronger the bullet.
  • Tracker
Movement-It follows one target constantly. If it hasn't been seen for 11 turns, then it finds a new target.
Targeting-The gun is trained on the one target.
Firing-Constantly fires on the one target, since it's mostly in tracker's sights.

I learned that simplicity and a good idea can go a long way. The Wall robot for example was very successful in both avoiding bullets and dealing out damage to other robots. The Tracker on the other hand worked in a completely different way. It's main goal was to damage and destroy as many robots as possible. In that aspect it was successful, but in surviving it was not. When it stopped to shoot at its target, enemies had time to shoot back. Another aspect of the Wall robot strategy that was extremely effective was in using the wall as a shield. When you hug the wall the enemy knows where you are, but it cannot come from behind you.

Robocode has some realities to consider. Cover, speed, and nonstop movement is key. When other robots have a hard time hitting you, and you are hitting successfully the damage ratio amongst robots will be in your favor. Nonstop movement is important because I've only observed robots that shoot after they have found a target. If you were to constantly move, the chances are also in your favor.

All these elements are not unlike guerrilla warfare. You perform hit and run tactics, and take advantage your enemies weaknesses and avoid your own. This is my favorite part of the process of doing something competitive. I get to find the best ways to do something and look at my own capabilities.

No comments:

Post a Comment