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.

Wednesday, August 29, 2007

Code Ruler Results

Our objective was to design and code a bot for Code Ruler. The strategy I decided to use involved a commonly used AI technique where scores are given for various conditions and moves are decided to achieve the highest score. Many specifics are used for scoring including proximity to enemies and allies. Although the 0.5 second per turn timer limited my look-ahead capabilities, the bot performs quite well. The details of my implementation are available in the javadoc generated from my code. The zip containing my source file and javadocs is available Here.

The scores for the test runs versus the sample bots are as follows:

Game 1: bkarsin VS Split Us
bkarsin wins 823 to 60

Game 2: bkarsin VS Gang Up
bkarsin wins 780 to 172

Game 3: bkarsin VS Migrate
bkarsin wins 831 to 0

Game 4: 4 team free for all!
bkarsin: 1112
Smart Split Up: 120
Capture Castle: 112
Gang Up: 56

The rest of my runs are available in the javadocs.

It is clear from these results that my bot performs rather well when faced with these very simple samples. Hopefully it will do well in the tournament as well.

What I Learned:
Since I have previously done some AI work and enjoy it, I got to practice some of those skills. I had never heard of CodeRuler prior to this class so I had to learn all the rules and strategies. I enjoyed the designing the program and strategy for this project. Any practice with games and code is always useful.

I became much more comfortable with Eclipse and Java just in this exercise. This was a good refresher for Java syntax. My first time using javadocs took a little while but I now see how to use it and how useful it can be. I think my code is much more readable and well structured because of this simple tool.

Sunday, August 26, 2007

Assignment 2: OSS Experience

For this assignment we were to find an open-source Java program, install it, use it, and rate it based on The Three Prime Directives.

The program I chose is a rather complex 3D modeling and rendering tool called Art of Illusion.

Sourceforge Download URL: http://sourceforge.net/projects/aoi.

Website: http://www.artofillusion.org.

Objectives of this program: Art of Illusion is an extensive 3D modeling and rendering program. It enables users to create and manipulate 3D models. Support for advanced users includes creating plugins and scripts.



Prime Directive 1:
This system does, indeed, accomplish a useful task. Users can create anything from the simplest 3D models to very detailed and beautiful 3D images and animations. Users can draw out their shapes with many tools, add textures, define materials, and even animate their models. I think the fact that the system is open-source and well maintained allows for constant feedback and input users.

Prime Directive 2:
Art of Illusion was very simple to install and run. There are versions available for Windows, Mac, and Linux. The only requirement to run the downloaded executable is that JRE (Java Runtime Environment) be installed. The Art of Illusion homepage contains detailed installation instructions. I was able to download and run Art of Illusion within 2 minutes.

There is a great deal of user-end documentation available both for download and on the website. I followed one of the many tutorials and was able to create a rather nice (yet simple) image in 30 minutes:


Prime Directive 3:
Being an open-source, community supported system, Art of Illusion provides a large amount of documentation for the advanced user and developer. This system provides support for user created plugins and scripts to be incorporated into the system. Detailed instructions on the use of the Art of Illusion plugin API are available on the website. By simply placing a jar file into the plugin directory, a developer can introduce many new features and capabilities.

Overall I think Art of Illusion is a very well written, maintained, and documented system. In the future I may continue to use it for 3D modeling and rendering.

Friday, August 24, 2007

Program 1: FizzBuzz

The objective of the first program of this course was quite simple. The program simply had to output every integer from 1 to 100, replacing multiples of 3 with "Fizz", multiples of 5 with "Buzz", and multiples of 3 and 5 with FizzBuzz.

Once I downloaded and opened eclipse (approx. 20min download and 2min unzip), it took very little time to get this program running correctly.

10:05pm - Started new project and began by opening one of my old Java programs to refresh myself on all of the basic syntax (it has been over a year since I've written any java.)

10:19pm - Finished program. It is running correctly and Eclipse was rather easy to use for a program this simple. Here is the very simple and short code:

public class FizzBuz {
public static void main(String [] args)
{
int i;
for(i=1; i<=100; i++)
{
if(i%3==0 && i%5==0)
{
System.out.println("FizzBuzz");
}
else if(i%5==0)
System.out.println("Buzz");
else if(i%3==0)
System.out.println("Fizz");
else
System.out.println(i);
}
}
}

The only Java coding I have previously done was with Notepad (sorry to admit). Even in this sort amount of time I can see many nice features in Eclipse. I particularly like the method listing when you type out a class (like Visual Studios). I will continue to play around with it to get used to some of the features of Eclipse.