Wednesday, August 29, 2007

Code Ruler Result

I finished the Code Ruler program with my partner, Zhong Rong Lao (Jon Lao). The zip file of the source code can be found in here.

As for the strategy evaluation, since I implemented the strategy as competing with all three other rulers, it turned out to be a little surprising when I did the one-on-one competition with each ruler for the homework. Nevertheless, I am still satisfied with the result, here is a table showing the score of each run:



Test Run: 1st run 2nd run 3rd run
jliao-rong/migrate 570/0 616/5 623/17
jliao-rong/gang up 461/167 523/120 544/104
jliao-rong/split up 58/563 264/412 417/190

The strategy I used is quite simple: at the beginning of the match, move the peasant to the center of the map, then span out from there. This gives me a faster way to cover 124 squares, which is the minimum to produce more units. Also at the same time, I move my knights towards other castles and try to capture them. If there are enemy peasants or knights on the way, capture them as well, but the castles are always the primary targets. This strategy seems to be working a lot better when there are more than two rulers competing. Even though the strategy is simple, but implement it is not very easy. There are still minor errors, such as the rarely-happen overtime. However, due to the time constrain and programming ability, we are unable to fix these minor bugs.

On the other hand, I learned a lot from this assignment. First of all, I am very happy to see how eclipse has helped me to find out many typo-kind mistakes, such as the missing semicolon. Also, the debugger along with the break-point is very handy, and it helped me solved many errors that were hard to notice by simply running the program. Secondly, the Code Ruler is a very funny game. Trying to implement a strategy to beat up the computer is not only a great pleasure, but also is a very challenging task. Java has played an important role here. The javadoc of Code Ruler is very clear, which helped me to understand the program faster. Lastly, working with another person is a great experience. I had worked in teams before, in my opinion, communication is the most important thing for the success of the team. With good communication, a team works as one person, but performs better than one person; with bad communication, a team works as more than one person, but perform worse than one person.

Saturday, August 25, 2007

OSS Experience: Dancing Sudoku

The software I chose to download is Dancing Sudoku. As a popular riddle game, Sudoku has a fairly simple rule, yet its fun is easily addicting, just like the Tetris. The goal of Dancing Sudoku is to become a very fast and easy to use Java tool for generating and solving Sudoku puzzles. It includes 4x4, 9x9, and 16x16 dimensional Sudoku. The secret to create and solve all these different Sudokus is the usage of Donald Knuths exact cover algorithm.

As for the first prime directive, Dancing Sudoku has done a good job: create and solve Sudokus for the users. There are many Sudoku games available in books, newspaper, or some other paper medium. However, they can only provide limited amount of games to the users, whereas Dancing Sudoku can easily create as many games as the users want. Also, the Dancing Sudoku has a save/load functionality which allows the user to save different Sudoku games and load them to continue playing anytime they want.

Although Dancing Sudoku has done a good job for first prime directive, it sort of fails on the second prime directive. Unzipping the package is easy, yet to install and run the software is a little tricky, especially for people who have no experience with java or batch file. There is no real installation required to run the software because it is already packed up into one single jar file, which is an executable file, but this is not known to many people. Luckily the batch file is named "run", which is a big clue for starting up the application. The batch file basically executes a command to pack up all the class files into a jar file, yet the purpose of this batch file is uncertain for me, since the jar file is already provided. After starting up the application, it is quite easy to use. The interface is clearly layout, and there should be no difficulty for people who know how to play Sudoku to run the application.

Lastly for the third prime directive, since Dancing Sudoku is an open source project, its source code can be easily obtained from SourceForge website. However, I think the developer could have done a better job for providing more technical documentation, such as a list for the classes and functions. There is a PDF file which I think is served as the documentation, but it mainly contains the discussion of the algorithm for creating and solve the Sudoku-like problem. It is more of an academic paper. Despite the lack of a detailed documentation, this application is actually very small, and it only contains five source java files. An experience programmer who understands the algorithm it used should be able to modify and improve the application quickly.

Thursday, August 23, 2007

CodeRuler: It Runs!

Well, I downloaded the CodeRuler zip file, and tried to follow the instruction on that requirement page, and somehow it turned out to be a little misleading. I have "c:\eclipse" as the directory in which the Eclipse is installed, and I ended up creating another eclipse folder inside it to hold the unzip files. It took me a while to figure out that all I really have to do is just unzip the two jar files into the plugins folder which is under the original eclipse folder. :(

Anyways, so then I could create a game project for the CodeRuler. Then I simply copied and pasted some code that controls the peasants from the article "
Conquer medieval kingdoms with CodeRuler", since I just want to test if the game runs, the article has enough code to do that.

After a few small modifications to the code, my CodeRuler finally runs! Oh well, it didn't even score 300 though. However, it's a good start. Next, I will be reading through the article and try to add some tricks to my CodeRuler. :)


By the way, my eclipse takes literally about 1 minute to start up, anyone has a similar case or know how to make it faster? (my laptop is a Dell XPS M1210, which I believe is quite a fast laptop)

FizzBuzz Program

Ok, so I finally got the FizzBuzz program down. Here is the code:

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



It took me about 20 minutes to finish this program, including the time I spent for the "hello world" tutorial in eclipse. The process went smoothly. Even though I haven't been programming in Java for quite a while, with the ease of eclipse, I did not encounter much difficulties.

Programming in eclipse reminds the first time I tried to use an IDE like VS.net, which I found it is really hard and unnecessary to to do my school programming work in a such gigantic monster-like software. What in the world is build? Why is to debug but not run? The simple "code-compile-run" method using in the notepad has already coined into my mind firmly. Until one time I saw one of my former professors to debug my program using the VS.net, then I finally notice the power of an IDE. Automatically complete the repeated code, setting break point and step forward in the program, open multiple windows to compare similar code sessions, etc. There are just so much more things we can do in IDE, and we can do them so much better, easier, and faster.

Thereafter, I strongly feel that if someone ever wants to do some serious programming, using an IDE is the only way to go. There is simply no reason to go back to notepad. Not at all.