Competitive Robot Testing

When running our Robocode robots, we may find that they don’t exactly work according to our design. We can run acceptance tests, behavioral tests, and unit tests on our robots to make sure that they run to our specifications. These tests do not just provide benefit to the current robot, but future robots as well. They provide regression testing so we are able to revert to an earlier version that performed better.

Acceptance tests with JUnit provide a clear benefit to robocode testing. Normally you would have to start the Robocode GUI and run a match between two robots. Since the specification is that the robot must beat 8 robot types, having acceptance tests to make sure that the robot wins is necessary. My current robot, EasyKillBot, has passed on average 3 of the acceptance tests, where the goal is to win 10 out of 10. While creating a robot that can win against these robots each time is unlikely, these tests provide a gold standard to aim for.

The behavioral tests are where I put most of the effort in testing. I created tests which tested the robot’s accuracy and the states which would be detrimental to the robot’s functionality. The detrimental states that I tested for are hitting a wall(lose energy), disabled(a sitting Duck that can’t do anything), and robot collisions(both robots lose life). I didn’t test movement because the EasyKillBot is currently set to move in a circle and can be seen with the “eye test.”

The current state of the EasyKillRobot doesn’t have any unit tests. The reason is that the code coverage for the current robot behavior consists mostly of methods with no arguments and no return values. Eventually when I modularize the code and include methods such as the included method, public double distanceFromCircle(distanceFromCircle(Point2D myLocation, double maxRadius), I will include unit testing for the proper functionality.junit-robocode-eclipse

I also was able to test my build within Eclipse with the instructions here.  It removes one less hassle so I wouldn’t have to keep switching between Eclipse and command-line to test.  One issue I ran into was  that I had to set up the VM run configurations for each test.

I found great value in creating code to test robots and testing in general. In the Robocode GUI, the “eye test” only gives so much information. I also found enjoyment in creating behavioral tests for my robot. The behavioral tests make sure that the robot lives up to certain expectations that the designer chooses to impart upon it. The main benefit of the JUnit testing is that I have become a bit more proficient in JUnit, which will help in future projects I undertake.

My Robocode Kata Experience

Robocode is a programming tank game where you compete in a 2D arena against other players. The term Kata doesn’t refer to the Japanese term for Katas, rather a term Code Katas coined by Dave Thomas. Code Katas are exercises that are used to improve your skills through repetition. My Kata experience in Robocode began with an assignment I was given.
a13img
The goal of the assignment was to design simple robots that could do various tasks in moving, turning, tracking, and firing. Each robot built upon the last. Each robot taught basic programming for tanks such as moving or firing or built upon existing skills learned such as moving in a circle or firing at a specific target.

The task may look easy, but it requires attention to detail and trigonometric knowledge. One of the hardest parts I had difficulty grasping was the tank “heading.” The angle orientation used is set with North starting at 0 degrees and angle increments in clockwise notation rather than the Cartesian coordinates starting at the East in counterclockwise notation.

Overcoming this is still troubling for me, but I know it will help with Robocoding in the long run. Also I ran into problems such as figuring out how to use the methods of Robot. I overcame this with the code given in the Robocode wiki and the lessons provided to assist new Robocoders. I completed all the simple Robots and they seemed to be working properly. I did require some helpful coding examples for beginners for assistance.

I also learned about Robocode tank behaviors. Most of the fighting capable behaviors stem from how the robots are tracked and found with the radar. My next task will be develop an effective Robocode robot. I have some general ideas of how to make an effective robot. I hope to include machine learning to predict the next action a robot will take, decision trees to determine the next action to take, predictive bullet algorithms to dodge bullets, as well as effective turn management.

Code Katas are excellent tools in Software Engineering. In a previous post, I mentioned the benefit of following Malcolm McDonald’s idea that it takes 10,000 hours to master a skill. While we won’t have 10,000 hours to master Robocoding we will be more experienced with the basic tasks to handle more difficult ones.

Art of Illusion: Is it Open Source at its finest or just a magic trick?

Open Source Projects are everywhere and many of them are a pain to develop and get involved with. Art of Illusion is a project that not only provides one of the few free 3D animation modeling studios, but also is very easy for developers to contribute. Art of Illusion is an open-source development studio developed by Peter Eastman. It allows for 3D modeling and rendering that can be used in animations. We will look into why this open source project is great by showing how it aligns with the “The Three Prime Directives of Open Source Software Engineering.”

The project site can be found here.

The SourceForge download can be found here.

Prime Directive #1: The system successfully accomplishes a useful task.
The project can do simple to complex tasks.   For example, I have created a simple 3D ball animation by clicking the ball mesh and following the documentation on the main site.

pd2p0

Besides the GUI, it also allows for scripting which enable objects and animations to be developed quickly.

Prime Directive #2: An external user can successfully install and use the system.
Installation of the software requires having Java 5 or later installed and downloading a pre-built package for Mac OS X, Linux, and Windows. The downloaded file will install upon opening. Unix and other systems require a little more work for installation. The instructions and packages can be found here. The following window appears:

pd2p1
The user has to follow the instructions at each step till the end and then the installation is complete. Installation is also very quick as it requires less than 10 MBs of disk space.

Prime Directive #3: An external developer can successfully understand and enhance the system.
The source code can be found here. The compilation of the can be done with ant. A developer would have moderate difficulty changing the functionality of the main program mostly because the naming conventions are not all in English. The other way to enhance the system is much simpler which is to extend the functionality of the program with plugins. Art of Illusion has many third party developed plugins and scripts that have been gathered here. The plugin tutorial is found here.

Art of Illusion not only provides a great development environment, but also is great for beginners as well.  I have used Blender, another open source 3D modelling and rendering studio, and while it does have a lot more functionality for animations, content creation, and more 3D mesh modelling capabilities than Art of Illusion, the learning curve and ease of navigation for Art of Illusion is much easier.