Robocode : Competitive Robot

Downloads :
Source Results

Please refer back to my previous blog entry for more details about robocode.

Overview :
Design and implement a single robot that can reliably beat as many of the following eight sample robots as possible: Walls, RamFire, SpinBot, Crazy, Fire,  Corners, Tracker, SittingDuck.

Design :
Basically the robot, WallRunner, moves to the left or right edge of the battle field, depending on whichever is closer, then continues to to move up and down the screen. This movement is based upon the strategy that WallRunner will never have to worry about scanning behind itself in order to stress focus towards the center of the battlefield. WallRunner relocates itself at the edge, the bullets that do not hit the target of original intent has a greater probability of hitting another robot compared to if WallRunner shot from the center of the battle field.

For the targeting logic, WallRunner will shoot at the closest enemy robot it can find relative to its location. But one problem arise from targeting only one robot since it only searches for the closest robot. In the case that the closest robot is killed, WallRunner will continue to search for the one that was killed. To remedy this, one must assume that if WallRunner had locked on to an opponent that it would try to continuously shoot at the robot. Thus, if WallRunner does not shoot for a short time, it will return to scanning mode once again to find a new target.

Both the targeting and firing logic are interloped due to the distance factor. Due to WallRunner shooting at the closet enemy, the bullet firepower is directly related to the battle field width with respect to the distance between the the robot and the enemy. There are two catches to this exception. If the robot’s energy is less than 10 and the distance is greater than 20 pixels, then fire power is set to 1.0 to conserve energy.

Now this other condition is unique to the problem when WallRunner competes with another wall moving robot. The latter problem appeared when competing against the robocode sample robot, Walls. Since WallRunner fire power relates to distance, the firepower would be weaker than the Walls robot depending on the distance between the robots. If the Walls robot was directly above or below WallRunner while it was moving away from Walls, the Walls robot would exterminate my robot due to the fire power difference. Whenever this weakness is exploited as soon as the onScannedRobot event is called, WallRunner will head directly for the attacker and shoot it will a fire power of 7.0.

Results :
These are the average percentage of wins out of five matches. As noted before, the Walls robot exploits WallRunner’s weakness. Inorder to remedy this, WallRunner would need better detection of the enemy robots based upon a certain angle threshold. Currently WallRunner is only checking if the enemy robot is 0 degrees of 180 degrees of its location, so if WallRunner checked between 350 degrees to 0 degrees and 190 degrees to 180 degrees, then better results may appear.

SittingDuck 100%
Fire 95.6%
Crazy 92.3%
Corners 80.4%
Tracker 79.4%
RamFire 71.8%
SpinBot 70%
Walls 60.8%

Lessons Learned :
Usually for smaller assignment, I usually do not physically write down my design, but rather tend to store it within my mind. But this assignment really called for all my attention to the minuscule details so writing down my algorithms aided me in visualizing the robot’s movements and the complete objective. Through this method I was able to successfully code my robot with little testing while still being able to destroy all the robots. The test stage is the time when I visually grasped the weakness of my robot. The first time against the Walls robot, I would only will around 30% of the time. Finally, this assignment taught me about the importance of first design then implementation rather than implementation and designing together.
table.borderAll { border-top :1px solid black; border-left :1px solid black; border-collapse:collapse; } table.borderAll td { border-right : 1px solid black; border-bottom : 1px solid black; padding : 3px 5px;

Advertisements