Friday, August 31, 2007

Review of CodeRuler lauramat-lisachen

The first thing I noticed when I opened up CodeRuler lauramat-lisachen was its simplicity and clarity. This was some of the easiest to understand code I had ever read. Within a couple of minutes I understood the entire strategy and implementation.

The code was constructed in a very clean way and it followed the conventions from "The Elements of Java Style" quite closely. Most of the convention violations were in the sections code that were taken from our sample CodeRuler. Overall the code was very neat and concise.

I was very surprised by the simplicity of the strategy used by lauramat-lisachen. The most complex aspect involved sending individual knights to do certain things and use the remaining knights in a pack. This was an interesting strategy that worked quite well for capturing castles. I may incorporate a similar strategy into my own CodeRuler and see how well it works.

Despite the simplicity of the code, the bot performs pretty well against the samples. I think, however, that adding a slightly more complex AI to the peasants will help. Random peasant movements do not claim an optimal amount of land and allow enemy knights to easily capture them. With this slight addition the bot will be quite formidable.

The few convention violations I managed to find are listed in the following table.

FileLinesViolationComments
MyRuler.java6, 121EJS-34&50Use of "This is" in comments
MyRuler.java14EJS-39Undocumented member variable
MyRuler.java14,129,130EJS-9r, np, and dir not meaningful names.
MyRuler.java45,125In ClassLine over 100 characters long
MyRuler.java118,146EJS-56No pre/post conditions
MyRuler.java42,118,146EJS-55No examples on usage in comments.


Overall I could not find many violations. I am sure the table of violations for my code will be much longer. This is a nice example of simple, clean code that easy to read. I am interested to see it with a nice peasant AI.

No comments: