Friday, August 31, 2007

CodeRuler Review

I have reviewed Ben Karsin's code of CodeRuler from His AI strategy and algorithm is fantastic and his code is well written. His score system in direction decision is a very good idea. However, it seems a little bit too intelligent.
The first obvious problem is that his peasant will go up and down in a couple of fields when nearby fields are all claimed. It can be fixed simply by adding a random mechanism when all directions score the same.
The second problem is a bug that when his knight trace chased enemies' peasant to the world's angle, it will stop a block away from the target without attacking it. I don't know what's going wrong in the algorithm. This bug needs to be fixed.
The third one, which I think is most important, is a question about knight strength. In Ben Karsin's Ruler, knight runs away when its strength goes down to a degree. This strategy does protect knight from being killed, but it significant reduces the usable power of knight. Because when a knight runs for live when its strength goes below, for example, 10%, that means only 90% of a knight's power is usable. Although run-away knights can go to capture enemy knight, it makes enemies' knight able to attack anything as they wish, such as castle. In my opinion, warrior is honored to die in the battlefield bravely. So I don't agree in run-away strategy. Maybe let one or two knights go to capture enemies' peasant when strength gets low is OK, but most of the knight should fight to death.

Following is the summary of violations in the code.

Summary of violations

MyRuler.java16,29,30,*ICS-SE-Eclipse-2Code indented 3 spaces or tab, not 2 throughout.
MyRuler.java16,29,138,*EJS - 7 Lack of space between operations and parenthesis.
MyRuler.java104,106EJS - 76 Use experssion instead of block statement.
MyRuler.java114,116EJS - 5 '{' in a new line, not in the last of upper line.
MyRuler.java181,182,183EJS - 6 Lines too long.
MyRuler.java142,196,276EJS - 9 Do not use a meaningful name.
MyRuler.java74,81,90,*EJS - 37 Used C-sytle comments to explain implementation, not one-line comments
MyRuler.java250N/AThe first if statement contains a blank expression, though is not prohibited by the rules, it made me somewhat confused.
MyRuler.java224,50,54,*EJS - 7 no blank lines to seperate each member of the class

Wednesday, August 29, 2007

Code Ruler Results

Member: Shaoxuan Zhang

Source Code:

- Castle produce to maintain a certain proportion between knights and peasants.
- Peasants claim the land that isn't belongs to the rule and avoid being attacked. Otherwise, it move to a random direction.
- Knights are grouped into two, one assault team one castle capture team.
-- Castle capture team capture castle one by one, and destroy enemies' target around its way or near the castle.
-- Assault team capture castles only, do not attack any other enemy units. If no castles remain, they will wait in the center of the map for orders.

Test results:
Test 1 Test 2 Test 3
sz vs. Migrate 820:0 784:0 797:0
sz vs. Gang Up 780:60 796:78 785:42
sz vs. Split Up 773:54 844:56 749:54

Lessons learnt:
CodeRuler: I now have understand some strategy of CodeRuler. Most of them have been implemented into my Ruler. Both my peasants and knights have advantage.
Peasant: Instead of move randomly, my peasants now know to move and claim an unclaimed land first. It is significant to accelerate the speed of claimming land, and contributes to mine beating Migrate Ruler to 0 points. In most of the test, my ruler claimed as much as 4000 land which means 85% of the world! In test of more player, this number can reach 4602, which just 6 fewer than the world. I think it is strong enough. Some intelligent strategy may farther improve this one, but the improvement will not worth the expense in calculation.
Another advantage is to avoid enemies' knight. The peasant will move away from the enemy knight if it is near. This feature not only make my peasants more safe, but also waste enemies' force to pursue the peasants. Sometimes, we can see other ruler's knight running after my peasants across over the world. Though my peasant sacrifices at last, it win me lot of time to capture the ruler's defendless castle.
Knight: The idea of spliting into two teams comes from the sample Split Up ruler, and it prove to be useful. The assault team can usually find and capture a empty castle.
However, the most important idea is to sweep out the way to the target castle, especially in one on one game when both rulers' knight is moving to others. When raiding not only capture enemy unit on the way, but also near the way, it will act as defending when attacking, especially for the knight that newly created from the castle. I think this idea is the most important one to help me win.
Castle: Castle's strategy is simple, just manage the proportion between knights and peasants and stop creating knights when enemy runs few.

Java, Eclipse and Programming: Actually, I did not get much new in Eclipse, just get more used to it. For Java, this assignment is a very good exercise of writing javadoc. After I generate my javadoc files, I do consider it helpful! I think I will continue practise and use it the future.
Then I would like to talk about programming. I got two experiences: the first is to design well before writing code, the second is to write more methods to group up the functions. Both these two are fundamental indeed, but now I have fully realized them. I have writen the ruler twice. The first time I wrote it without carefully design. So my ruler cannot even beat the Gang Up Ruler. The second time I rewrote it with careful design and used more nested method calling, that prove to be very helpful when lately I want to modify my strategy.

Working with another person? I worked alone in this project, so... no experience in this aspect.

Sunday, August 26, 2007

Areca Backup -- an Open Soucre Software Experience

Areca Backup is an open source software, you can see its project in
Areca Backup is a file backup tool written in java. It supports data compression & encryption, incremental backup, file history explorer and many other features. Areca Backup also includes a transaction mechanism which guarantees your backups' integrity. --the description is copied from the link above.
Now, we come and see if this OSS satisfy the 3 Prime Directives.

Prime Directive 1. The system successfully accomplishes a useful task.
Areca Backup does do a good job in its task. It provides a very powerful and facilitative backup function. We can easily create a target of folder(s) and backup it. The archives will be save in the defined location and can be managed within the target. Also, targets can be grouped that makes us easier to manage them. When backup a second time, it will compare the existing files with the backup files, only the changes will be saved into the new archive. In recovering, we can either recover the whole folder or select some of the files to recover, that makes daily backup fast. What is more, we are able to choose in with archive we want to recover from. It is really a very helpful backup software.

Prime Directive 2. An external user can successfully install and use the system.
It installation is very easy, just need to run the install package and click next till finish.
However, the guide for new starter is deficient. There is no any guide of what to do to make the first backup archive, even in help website online. It took me several minutes to find out how to start and what a target means. But after beginning, it is easy to use. By adding a initial guide, the familiar time will be shorten from decades of minutes to couples of minutes.

Prime Directive 3. An external developer can successfully understand and enhance the system.
Though there is a source available in download, unfortunately, I did not find any develop-level documentation. I am able to create a project with the downloaded src, and the code is well organized. But it is difficult to read into it without guiding documentation. So I cannot do anything with the project. Thus, I think this Areca fails Prime Directive 3.

Areca Backup is a useful software. It can help us in daily backup procedure. But as an open source package, it is not friendly to external developers. However, considering its value in future use, the investment will prove its worth. Maybe the package will be more developer friendly with some further information from the project admin.

Tuesday, August 21, 2007


As an assignment, I just finished the FizzBuzz in Java on Eclipse. It took me 35min to do so. Since learning java for not so long time and not writing codes in java for month, I have totally forget even the basic syntax structure such as where the program begins and how to output a word. It took me most of the time to getting the memory back by searching in java's doc, but get nothing. At last, I found the answers in the "helloworld" tutorials... After that, I just spend several minutes to finish the program.
Fundamental is of most importance because you can nothing without it. Just like the beginning of my programming, I have all the idea even the codes in my brain in C++, but I don't know how to write the correct code in java. Maybe the basic elements of java & C++ are almost the same, but just almost, to program right, we need the exactly right one. Though much of basic codes can be generate by the platform automatic, it did not provide me one. Therefore, be familiar with the programming language is all the time important.

Following is the codes of my FizzBuzz:

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

I have just read all others blog associated with FizzBuzz. I found that they all (i%15) to find out the case when we need a "FizzBuzz". But in my codes, there is not an (i%15) because the "FizzBuzz" is composed by "Fizz" and "Buzz". "Fizz" comes from (i%3) and "Buzz" comes from (i%5), so no (i%15) is needed. Meanwhile, as both (i%3) and (i%5) will be executed in any case, I cannot simply use a else to cover the remaining cases. So there comes to be an (i%3!=0 && i%5!=0) . In this FizzBuzz case, my implementation needs 4 compare statment while the other just take 3. But when the factor increase, such as FizzBuzzDozz(3,5,7), my way increase 2 compare statment every new factor while the other increase by P(n+1,2)-P(n,2)=n. That will be huge when factor become more. And, some of the item will easily be forgotten.
However, it looks like the algorithmic thing rather than the software engineering one... Anyway, just left it here :)

Monday, August 20, 2007

Frist log

The beginning of the Blog....