Tuesday, October 11, 2011

An Exercise in Frustration and Futility

We cannot always win.  That is a perfectly true statement.  Oh sure, we may have winning streaks here and there, but we will inevitably meet with opposition which defeats us.  Sometimes, it can seem almost as if we cannot even manage to win at all.  That is how I felt with regards to my personal competition robot for the robocode system.

To be completely honest, I am frustrated, disappointed, and depressed by the fact that my robot is horrible.  My robot, which I called "Tankadin" as a nod to my appreciation of paladins, could not consistently beat a single test robot that shot back at it.  That is correct, I could beat most of the sample robots in robocode some of the time, but never one of the others all of the time.  That is, aside from the "SittingDuck" robot, as well as "Target" or any other robots that never shot at me.

Where did I go wrong?  Most likely it was due to the fact that I wanted to implement a movement strategy that utilized one of my favorite methods from my robocode kata robots, the method that allowed my robot to move to any specific location on the map.  Unfortunately, the best use that I could think of for this ability was to send my robot to various corners of the map.  But I wanted to be able to use that movement over and over during an engagement, so I developed a method that allowed me to randomly move to any of the 4 corners of the battlefield.  As I left it, the robot moves to random corners when it hits a wall or another robot.  I had implemented dodging capabilities and on-bullet-hit behaviors that were subsequently removed due to ineffectiveness or conflicts with targeting mechanics.

I soon realized that whilst my robot was in transit, it was not firing and often got pummeled to death en-route to its destination.  I had also wanted to utilize my tracking ability to follow enemy robots with the gun so that most shots would land.  What I managed to end up with was a less-than mediocre robot.  Although, my robot does track and fire consistently when at rest. 

I also wanted to implement some decent test cases, but I spent so much time changing behaviors, adding new movement strategies, removing them, and eventually settling for a disappointment that I didn't have time to implement them.

There were a few changes along the way that would beat one robot, but then lose consistently with all the others.  Thus, I found myself trying new strategies only to have to remove the code for those strategies because they impeded on previously successful behaviors.

I have learned a great deal in the process of building "Tankadin".  I realized that either movement or firing should be simple.  Trying to implement tracking and fancy movement can often have bad side-effects such as interfering with the ability to dodge incoming shots, or to be able to consistently track your opponent.  Also, as far as testing is concerned it would be best to settle on a particular strategy such that you can develop test cases right away to help determine effectiveness rather than trying to "fix" behavioral flaws in the robot as you see new situations arise with different opponents.  Also, being able to devote more time towards development would greatly aid in the evolution process.  I believe that would have allowed me to generate a decent level of performance in my robot.

No comments:

Post a Comment