Tuesday, September 15, 2009

RoboReviews

There are several sample robocode robots that are part of the robocode installation. These robots show different strategies and options that robots can use. The sample robots provide a good way for beginning robocode programmers to learn how to control robots they build. Each of the sample robots use different techniques for movement, targeting, and firing. I will discuss the strategies used for several of the sample robots.

Walls:
The walls robot continually moves along the outer edge of the battlefield. This robot keeps its gun facing in and fires at enemy robots with medium power when detected. If there is an enemy on the next wall to travel, Walls waits at the corner and fires down the line until the enemy moves or it is destroyed. Walls uses an avoidance strategy if a collision occurs. The walls robot moves to the opposite wall that it was moving down when the collision occurred. This robot uses a simple, but very effective strategy. It has a good balance of offense and defense.

RamFire:
When an enemy robot is scanned, Ramfire moves towards the enemy and attempts to ram it. This robot only fires after it rams the targeted enemy. It determines the power of its shot based on the amount of energy an enemy has remaining. The more energy an enemy has, the stronger the shot. RamFire continues to shoot an enemy with bullets until it is weak enough that it can destroy it by ramming. This robot attempts to gain bonus points by killing an enemy by ramming it rather than shooting it. This robot's strategy is offensive. While it can get bonus points if it is able to kill an enemy by ramming, a robot that can avoid being rammed can kill RamFire rather easily.

Spinbot:
Spinbot continuously moves in a clockwise circle and fires when an enemy is found. When this robot collides with another robot, it attempts to determine who's ramming into whom. If it determines that the collision was its own fault, it moves away from the enemy and continue its circular movement. If not, the robot fires at the enemy that collided with it. This robot always fires strongly regardless of an enemy's distance. This robot has a decent defensive strategy for avoiding bullets, but its targeting isn't that good.

Crazy:
Crazy uses an interesting strategy. It moves in an alternating arcing pattern. If a wall is hit or if it hits another robot, the robot reverses direction and continues with its arcing pattern. The Crazy robot fires weak bullets at scanned enemies. This robot mainly relies on its semi-unpredictable movement to avoid being shot. Attempting to make movements random seems to be a good defensive strategy.

Fire:
The Fire robot determines how much power to use when firing based on enemy distance and its own remaining life. If the enemy is within 50 pixels and it has more than 50% life, it fires a strong bullet, otherwise, it fires a weak bullet. The Fire robot sits still until it is hit by an enemy bullet. At that point, it changes its heading between -180 and 180 degrees based on its current heading and a scanned enemy's heading. Then, the Fire robot moves forward or backward a specified distance, alternating direction after each time it is hit. If the Fire robot is rammed by another robot, it faces its gun to the enemy and fires strong shots at it. This robot has a decent defense strategy to avoid enemy fire, however, its targeting of enemy robots is not that good.

Sitting Duck:
On the surface, the Sitting Duck robot seems to do nothing. However, it actually keeps track of how many rounds and battles it has been involved in. It displays this information in the console. This just shows you that you can't make assumptions about code based on behavior. You need to actually read the code to know what is happening.

Corners:
The Corners robot moves to a chosen corner, being careful not to crash into another robot while it is on its way. If Corners sees an enemy while it's on its way to a corner, it stops and fires at it. Once it gets to a corner, it turns its gun back and forth until an enemy robot to fire at is scanned. Corners determines the amount of power used based on its distance from the enemy and its own life. If the Corners robot is far away or its life is low, it fires a weak bullet. If Corners has a decent amount of life remaining, it increases its bullet power as an enemy gets closer. This robot uses a good strategy to determine the bullet strength used.

Tracker:
Tracker finds a target robot and attempts to follow it. If Tracker loses an enemy and cannot locate it within two turns, it searches by turning its gun to the left 10 degrees per turn. If it cannot find the enemy within five turns after losing it, it turns its gun right in increments of 10 degrees. If it still cannot find its enemy after ten turns, it looks for another enemy to target. Tracker attempts to get within 100 to 150 pixels of the target enemy. If it is too close, less than 100 pixels away, it backs up so it is within the 100 to 150 pixel range. Once a target is in range, it fires a strong bullet at it. If tracker collides with a different robot from the one already being tracked, the enemy robot that collided with it becomes its new target. Then, Tracker fires at it, and backs up a little. When Tracker wins a round, it does a victory dance. This robot employs a good tracking strategy. However, its defense is not that great because it can be getting shot by other robots that it is not tracking and it won't retaliate.

By reviewing the sample robots, many things about different strategies' strengths and weaknesses can be learned. Using the knowledge gained, I hope to incorporate the strategies that I found effective to build a competitive robot.

No comments:

Post a Comment