Tuesday, October 25, 2011

Five Important Lessons Learned In Software Engineering

1. Why should software developers always keep the three prime directives in mind?
    The three prime directives ensures that a software system is a well developed and easily maintainable code. The three prime directives are found here.

2. The FizzBuzz program makes use of the assertEquals jUnit test cases, what would be an example test case for this program?
    Since the FizzBuzz program tests for number cases with, FizzBuzz being printed if n is divisible by 3 or 5. Fizz printed if n is divisible by 3 and Buzz if n is divisible by 5. We could use the test case assertEquals("Test for FizzBuzz", "FizzBuzz", 15) for example.

3. Before committing changes to a project hosted on google code which ant target should be run?
    The verify target should pass to ensure the next person working on the project that it is a working version of the code.

4. What kind of bugs would Checkstyle find that PMD wouldn't?
    Checkstyle would find coding standard errors while PMD would find errors that deals with the code. Such as Bugs, dead code, suboptimal code, overcomplicated expressions, and duplicate code.

5. Of the three review methods, which has the fastest turnaround?
    Walkthroughs have the fastest turnaround, minimal overhead. With little/no preparation and no formal process. The other review methods include technical reviews and inspections. Technical reviews' goals include defect discovery and ambiguity resolution. Inspections attempt to detect and remove all defects.

Thursday, October 20, 2011

Google Code Project Hosting

I've been working with hosting my Robocode robot on Google Code's project hosting site. So far my experience with it has been most satisfactory, as I was able to successfully host my distribution on Google Code and sync it with my SVN client.  I've tested the SVN capabilities by uploading all the files for my project onto the truck portion of my project webpage. The most difficult thing I had to troubleshoot was the formatting of the wiki pages to adhere to my liking. I was most surprised with the quality of hosting projects on Google Code. It was very easy to create a page and start uploading and creating wiki pages. Plus the fact that other developers are able to join the project by just adding their email makes Google Code very simple.

A link to my robocode robot I've been developing is here. Overall I look forward to using the Google Code project hosting site to work on future projects, since it is a great free option for developers. 

Tuesday, October 11, 2011

One robot to rule them all

Alas, my robot project has come to an end. However there is still one more act in this play, the epilogue of my journey of which is called robocode. The name of my competitive robot is called RobotDevil because just like the real devil, you never know what (s)he is going to do, or not do... The inspiration of my robot was the idea of a snowflake. They say that no two snowflakes are alike, and I would like to believe that when a user runs RobotDevil, no two instances will behave the same. Without further ado, whose cuisine robot will reign supreme?

If I asked you to pick a number between 1-10 and use that number as some sort of 'random' generated output, how 'random' would that be? The same theory applies to what I had attempted in my robocode project. I had set out to try create a robot that ideally will not win 100% of the time yet not lose 100% of the time either. A rudimentary coin flip of a robot would be my esoteric description. In essence I opted to build a robot that would display 'random' movement behavior, an optimal firing scheme and sophisticated tracking logic.

Movement: Movement is the heart and soul of RobotDevil, since our movement paradigm is limited to the battlefield and 360 degrees of turning options, the 3 factors in movement for RobotDevil was the degree of the turn, length of the turn, and condition of a hit wall. The general strategy for moving the robot was to create unpredictable behavior, since most advance robots will attempt to predict RobotDevil's next movement. The only downside to this approach is that RobotDevil may not make the most logical decisions, such as moving towards an enemy bullet or walls.

Targeting: Targeting is relatively simple in the design of RobotDevil, once an enemy robot has been scanned by our robot, the robot will adjust the firepower to either the MAX_BULLET_POWER or 1. RobotDevil continuously sweeps the area by rotating the radar and gun 360 degrees.

Firing: Firing is simple since once RobotDevil sees another robot it either fires a weak bullet or the strongest bullet. The measure taken to anticipate the movement of an enemy robot was not taken since our movement is not predictable.

Results (Out of 100 rounds)
RobotDevil 2606 (14%) V.S. Walls 16575 (86%)
RobotDevil 17549 (52%) V.S. RamFire 16466 (48%)
RobotDevil 1867 (10%) V.S. SpinBot 17423 (90%)
RobotDevil 10136 (59%) V.S. Crazy 6993 (41%)
RobotDevil 20612 (68%) V.S. Fire 9593 (32%)
RobotDevil 15093 (51%) V.S. Corners 14241 (49%)
RobotDevil 2664 (12%) V.S. Tracker 19446 (88%)
RobotDevil 18020 (100%) V.S. SittingDuck 0 (0%)

As the results show, RobotDevil performed horribly against Tracker, SpinBot and Walls. Partly due to the fact that these robots stay at a distance and attack rather than approach other robots. I suppose one design improvement RobotDevil could use is a better tracking system. 

Majority of the testing was done to ensure that the movement of RobotDevil was truly random. So jUnit tests to check between two length in distances traveled are not the same. It is suffice to say that the tests were a good indicator of random movement but this brings me back to my original question of how random is random.

Lessons Learned
I felt that this robocode development experience provided myself with invaluable experience in jUnit and simple software development principals. It was a great introduction in testing practices such as behavior in code. Perhaps after seeing some of the robots developed by my fellow software developers, it will provide me with inspiration on possible future implementations in RobotDevil.