Robocode was one of the iconic projects that I did back in a previous course ICS 413 which is detailed here. Once again I tackle the katas of Robot creation in order to create a competitive robot. Hopefully, this time around I can get hung up upon the intricacies of the Robocode API rather than Java primitives such as double…
Introduction to Robocode
Robocode, which was originally developed at IBM, is an open source tank-base fighting game. Although the Robocode API is available in both .Net and Java flavors, Java was the language of choice once more. The main challenge in Robocode is to create a custom robot which will battle to the death in an predefined arena. In order to access the inner workings of a Robocode robot, the Robot class or its child classes must be extended.
One of the more interesting aspects of the Robocode robots is the blocking versus non-blocking methods. When I read of blocking versus non-blocking, I immediately thought of Apache Tomcat’s HTTP connectors where a client-server connection can persist beyond a request. But in the case of Robocode, blocking commands ensure that a robot’s action must execute before proceeding to the next command while a non-blocking command means that a robot’s action waits until the execute method is called. Although this detail may not seem significant, non-blocking methods allows a robot to freely maneuver around the battle arena such as in arcs through turning and moving at the same time. For the upcoming competitive robot implementation, I am definitely sticking with AdvancedRobot to take advantage of the non-blocking methods.
My Experience with the Robocode Katas
I completed all 13 katas in a short amount of time. Honestly, most of my time was dedicated to composing and unit testing a trigonometry helper class. After that class was written, create robots to fulfill the katas boiled down to the order of which the Robocode methods were executed. Without JUnit to test my trigonometry, I probably would not have completed my robot’s as quickly as I had.
Although the assignment guidelines stated that we should create simple Robots, I could not conceive how to implement robot number 6, CircleTheWagonsRobot, as a simple Robot. On the other hand, writing an AdvancedRobot made so much sense with access to the non-blocking methods.
The other day in class, the discussion of class composition versus inheritance in regards to Robocode methods made me reevaluate the code I had written thus far. In the case of Robocode, it was easy to see that class composition is the best way of sharing a bunch of helper methods rather than inheritance. Let’s hope I can actively remember composition versus inheritance in the midst of developing software.
Looking back at my previous robot, it shined in massive battles because it stuck to one side of the battlefield and shot bullets in the opposite direction. Although effective at all out melees, one-on-one battles as it could not properly dodge bullets with its back to the wall.
Thinking upon my past experience, my goal is to create a robot that is able to fluidly dodge bullets. My robot will stick towards the outside of the battle field to enable me to track only the opposite side of the battle field but still allow the robot to maneuver away from the enemy.