robocode
If you want to download a distribution of my robot you can find it on my site:
Robot Distribution
The creation of this robot was inspired by a upcoming Robocode competition among some of my fellow classmates, I wish them well.. but I believe that the GreenMachine will do well given the short amount of time given for development of robots for the competition. The GreenMachine is a robocode robot that extends only the robot class, not the junior robot or advanced robot, which means that there are a lot less built in methods to utilise. Most of my robot is composed of original code except for one method I use to linear target robots that move in 90 degree angles, (such as sample.walls). the design ideas that I implemented are as follows:
Movment:
For my movement I could not think of a good way to avoid being hit except to be unpredictable... so what better way to be unpredictable then to use sporadic sudo random movements. For my movement method I use a built in Java random number generator and generate a random degree between 0-300 and a distance between 75-100 pixels. I chose to move such a short maximum distance per turn because moving in one way for any extended time will give an opponent a chance to preform linear targeting on my robot. This movement seems to evade a lot of shots, but we will see how it preforms in competition. A way to improve on this move method (I didn't have the time to) was to eliminate the possibility of moving directly towards or away from the enemy, as this would not change you retaliative bearing in comparison to the enemy.
Targeting/Firing:
For my targeting I continuously scan the field between moves and acquire a target. Once my target is acquired I will shoot a bullet at their bearing with power retaliative to their distance from my robot (farther away less power). If a shot hits its target then the overridden method onBulletHitEvent will immediately fire a mid-power bullet to the same X any Y coordinates that the first bullet struck the enemy, it does this after it moves just in case the enemy fire a retaliation shot in the direction it was struck by my bullet. In the event that my robot comes close to the enemy, within 100 pixels, the GreenMachine will charge its enemy full speed and on contact with the enemy fire a shot with maximum power, this method of close combat seems to work great. In the event that a robot is moving in 90 degree angles like sample.walls, GreenMachine will change its behaviour and use linear targeting to make shots that try and intercept the enemies future location. This behaviour was used from
walls killer
and was the only code in my robot that I did not write. Finally in the event my robot is hit by the enemies bullet I immediately fire a retaliation shot in the direction it came from then move.
Results of my Labor:
GreenMachine can beat most of the sample bots reliably including Walls, RamFire, Crazy, Fire, Corners, Tracker, SittingDuck. It does have some trouble with SpinBot because it does not have a method for dealing with circular predictive targeting, therefore it wins about half the time against SpinBot. To improve on this I need to create a way of identifying robots that move in circles and devise a way to track them.
Lets Take a Look: I suggest watching it expanded and in HD on YouTube.
Testing:
For my testing methods, I used Junit tests to judge my robots progress by having 10 round battle results quickly evaluated for each of the sample robots. This allowed me to quickly see the effect of any change I mad to my robot. In addition to these battle simulations I also tested different methods of my robot such as my firing techniques and my robots responses to events such as impact with another robot and impact with walls. I also utilised JaCoCo to see the coverage of my tests.
Lessons Learned:
I learned a lot from this project, I learned about creating a more advanced robot and how complicated robots can get. I also learned a lot of valuable skill on how to use Junit tests to test a program as well as guide the progress of software development. Throughout this experience I was utilising the Ant build system and therefore became very familiar with how the Ant and .xml files used in ant work. Towards the end of the development of GreenMachine I was utilizing Ant + Ivy in an efficient way. It has also become very clear to me the value of using a build system when developing software among multiple software developers. From a software perspective I would become very familiar with my build system before writing any code, and from a Robocode developer perspective I would search every nook and cranny of the Robocode API before beginning development to save on time and effort. I found that writing Junit tests after I began this project was difficult, If I could do it over again I would like to try the approach of writing my Junit tests before the code they are meant to test.
No comments:
Post a Comment