Welcome to my blog.

Monday, September 8, 2008

Lessons learned from Code Ruler

| 0 comments |

CodeRuler is an application provided by IBM <LINK> where one is challenged to create the best possible ruler using Java programming. The game premise is simple: you must battle other rulers for land and dominance. For each game you start off with one castle, ten knights, and ten peasants. You get points for claiming land and capturing other ruler's things. 

Team Members: 
Tyler Wolff
Daniel Tian

For this project I worked with Daniel Tian. He and I consulted a lot about what our strategy was going to be and it was ever evolving. We started with the basic code given on the IBM site and initially decided to optimize some basic things: 
  1. Command our castles to create more knights when knight count is low
  2. Program our peasants to capture land more effectively
  3. Program our knights to go after the closest enemy (other knight/castle) immediately in a large group. After all are gone, go after other peasants.
What we eventually created did in fact do all these things and more. However, we basically threw out all of the start up code from the IBM site and put in our own codes. We programmed out very efficient peasants who are constantly claiming new lands. We programmed intelligent castles to create what's needed most. Probably the most efficient thing we programmed was the knights. What the knights do is basically gang up on the nearest enemy, be it another enemy knight or castle. Normally it can take them all out. Then it goes for the left over peasants. More details can be found in the code javadoc. The source code and javadocs for our implementation can be found here [tylerwolff-daniel.f.tian.zip].

Evaluation Results


Opponent Name
Opponent Scoretwolff-daniel.f.tian scoreWinner
Split Up Ruler70788twolff-daniel.f.tian
split Up Ruler86797twolff-daniel.f.tian
Split Up Ruler58801twolff-daniel.f.tian
Migrate Ruler0864twolff-daniel.f.tian
Migrate Ruler0814twolff-daniel.f.tian
Migrate Ruler0639twolff-daniel.f.tian
Gang Up Ruler84712twolff-daniel.f.tian
Gang Up Ruler133739twolff-daniel.f.tian
Gang Up Ruler60809twolff-daniel.f.tian

As shown above, our ruler does super good against all of the built in sample rulers. It will always beat them in a one on one game. The hardest sample ruler, 'smart split up ruler' will always loses to our ruler. Even in a 6 player free for all match our ruler wins 70% of the time. What I found to be the hardest part in winning was making the 0.5 second time restraint per turn. If at any moment a turn took longer than that, our guys would freeze up due to a disqualification. I figured this had to do a little with my computer speed (2GHz intel core duo) since it almost always ran fine on Daniel's computer. When this didn't happen, it almost always ran smoothly and efficient.

Lessons Learned

Overall, working on this CodeRuler project was very new and insightful for me. On the one hand it dealt with gaming strategies, something I've never really been exposed to much. I tried my best to think like a gamer but I missed a lot of little things here and there. I was so grateful to have Daniel on my team because he is really interested in game development and he always had clever ideas for improving our ruler. I liked how we would push each other to make better and better code. I have a real good idea of what the best strategies are for codeRuler now. I could probably apply some of the concepts to other games.

Another thing that was new to me was working in a group for a programming project. This is the first time I've programmed something with another person and it was a lot different. Initially it was hard to coordinate times to meet up to work on the project since we both are very busy outside of school. However, we found that we could almost always reach the other somehow, either by phone, email, or IM. A hard thing too was trying to sync up our ideas, even if they were similar. In coding out what the peasants do, we were always throwing back ideas of how to change things to make it better and it was quite hard to come up with a final solution that worked for both of us. It was great working in a group though because it really took what I would have done to a whole other level. Our ideas were more refined working together and our code runs really well.

Using Eclipse for this project was a dream once again. It was my first time using it to create javadocs and it was so simple to do so! That really is a useful thing that can make it easier for anyone editing or adding to it. It was nice to have the application right there next to the raw code too. It made it incredibly easy to edit and test things. Doing this exercise also allowed me to get some experience in using collections. I never really messed around with it before and I really like how simple it can make things.

Sunday, August 31, 2008

Open Source Software Experience - blueMarine

| 0 comments |

OVERVIEW

My goal was to find, install, and evaluate a current Java-based open source software application. After searching sourceforge for sometime looking for something good, I found an application that looked very practical and useful. blueMarine is a Java based digital photo editing application that can load, show, edit, organize photos, and is able to generate web galleries. The version on sourceforge was v 0.8.6. However, after visiting the official blueMarine site, I saw they had a new v 0.9 beta. I decided to try out both.

Offical Project Page: http://bluemarine.tidalwave.it/

Prime Directive #1: Does this application successfully accomplish a useful task?

The blueMarine application seems to me a very, very useful program, similar to programs like iphoto or Apple Aperture, both of which cost lots of money. Almost everyone has a digital camera these days and people store thousands of photos on their computer. Organizing these photos can be very time consuming and complicated, depending on what sort of program you are using. I found the ideas behind the blueMarine system to be very intuitive and top-notch for organization (although not fully operational yet). 

  • TAGS - like many photo broswers, batches of photos can be tagged based on content with blueMarine. You can then view photos based on tags. Its quite simple. A cool feature of blueMarine is the use of location tags. If you travel, this is an amazing feature. In v0.9 you can actually set up 'trip' galleries, and then even view where your photos were taken on a map. I thought this was really cool.
tags based on location (click for larger view)
  • Photo Editing - Although this feature isn't fully implemented you can view stats on your photos quite easily, as well as look at the exif data. 

  • RATING: blueMarine employs a photo rating system which you can then use to view photos by.
  • SLIDESHOW: Both versions have a working slideshow function. However, the real trick is exiting this slideshow. I couldn't figure it out.
  • v0.9 BETA - This newer version not only employs a new gui, but gives the user more options for organization. The coolest thing for me with this version was the map view of your photos depending on your location tags.

Overall, I found this program definitely accomplishes a useful task. Although many said functions do not work yet (photo editing, web gallery generation, etc) the program functions quite well. If you travel or just have a lot of photos, it is very useful. 

Prime Directive #2: Can an external user successfully install and use the system?

This was actually the simplest part of the entire process. It literally took me under 2 mintues to download and instal the application (the mac version has drag & drop installation, very simple). There is a readme file that outlines installation but I did not need that. Both versions are available for OS X, Windows, and Linux. I would imagine installation on a windows machine might take a little longer than on a mac. Even so, this part of the software is made very simple and easy to understand.

Prime Directive #3: Can an external developer successfully understand and enhance the system?

The source package I got from sourceforge was laid out fairly simple in different categories. I went and explored the 'core' source files and I found build files as well as a javadoc directory. Everything is right there. I also went to the official website and found a great deal of easy to understand documentation on the developers page. If I were to actually start developing for this project I would probably return to the website often. There are coding guidelines and structure diagrams.

Overall, I think it would be challenging for me to modify and improve the system because it is such a large scale program. The good thing is that there are a lot of things that could be added to improve the overall application usability. One thing I would like to see would be the added functionality of a web gallery generation program. This would enable users to not only use the program on their computer, but back up all their photos on their personal server in an organized fashion. I plan on following the development of this program because it can only become a better system as people add to it. 

Tuesday, August 26, 2008

FizzBuzz Development in Eclipse

| 0 comments |

TASK & PURPOSE:
The task was to implement the FizzBuzz program: 

"A program that prints the numbers from 1 to 100. But for multiples of three print “Fizz” instead of the number and for the multiples of five print “Buzz”. For numbers which are multiples of both three and five print “FizzBuzz”."
For me this seemingly simple program was more than just an easy assignment, it was an exercise in using Java/Eclipse and an introduction into using JUnit. I decided to go about creating FizzBuzz using a test-driven development style, where the program is created through a series of small test case iterations. For each case, the code necessary to pass the test is implemented, and after all cases tested pass, the program becomes correct. This type of development style is really different for me as I usually go about things in the opposite way - the creation of code, then testing. Creating the FizzBuzz program was the perfect chance for me to try it out through the use of JUnit.

Using Eclipse again was a dream. I forgot how much it simplifies things and how much more efficient it makes programming on a whole. It took me around 15 minutes from the startup of the program to complete the FizzBuzz program. Although that might sound long for a small program like this, the actual code for FizzBuzz flowed swiftly and smoothly. What took the most time was setting up the test cases in JUnit. Since it was new technology for me, I inevitably ran into some problems. 

PROBLEMS:
The main problem I ran into while doing this was creating the program using the test case development style described earlier. I had a hard time linking the test class up to the FizzBuzz class. It would not recognize my getValue() function and it was confusing me.

SOLUTIONS:
I finally realized the simple solution to my problem was to use 'FizzBuzz.getValue()' instead of just 'getValue()'. This also brought upon another error that was fixed (using hints from eclipse!) by inserting 'import static org.junit.Assert.*;' Eclipse is wonderful.

CONCLUSION
For me doing this program was a nice little refresher into programming again in java. It also was really nice to go in and use the JUnit test case development in Eclipse. Although test-driven development is a bit overkill for a simple program like FizzBuzz, I can see how on a larger scale this development system could be really efficient. It would be easier to solve a large problem by first testing out and solving smaller problems. I like the simplicity of this. It seems like it would lead to less bugs and smoother overall development.

The creation of FizzBuzz has shown me that this class (ICS413) is going to be very practical and fun. I am excited to learn about tools that real software engineers use as well as concepts they use in creating software. I feel more motivated to learn about this sort of thing as it will make me a better programmer. Overall, I am looking forward to the class.

SOURCE CODE:
FizzBuzzTest.java

import static org.junit.Assert.*;
import org.junit.Test;

public class FizzBuzzTest {

@Test
public void testFB() {

assertEquals("Test 1", "1", FizzBuzz.getValue(1));
assertEquals("Test 3", "Fizz", FizzBuzz.getValue(3));
assertEquals("Test 5", "Buzz", FizzBuzz.getValue(5));
assertEquals("Test 15", "FizzBuzz", FizzBuzz.getValue(15));
assertEquals("Test 100", "Buzz", FizzBuzz.getValue(100));

}

}


FizzBuzz.java

/**
* A Simple program that runs through the numbers 1 - 100,
* printing either "Fizz" for multiples of 3, "Buzz" for
* multiples of 5, "FizzBuzz" for multiples of both, or just
* the number itself for all others.
*
* @author Tyler Wolff
*/

public class FizzBuzz {

public static String getValue(int iNum) {

if ((iNum % 3 == 0) && (iNum % 5 == 0)) {
return "FizzBuzz";
} else if (iNum % 3 == 0) {
return "Fizz";
} else if (iNum % 5 == 0) {
return "Buzz";
} else {
return String.valueOf(iNum);
}
}

public static void main(String[] args) {

for (int i = 1; i <= 100; i++) { System.out.println(getValue(i));
}

}

}