Wednesday, September 5, 2007

CodeRuler Redux

After reading through my classmates’ codes, I found a few interesting and useful strategies and tried them on my codes. But I don’t see any significant improvement on the results, so I switched back to focusing on improving the strategies on Marcius and mine original code instead.

The major changes are firstly, instead of having two groups that attack the castle and knights separately. I added a third, smaller group that attacks only the peasants. That is because killing a peasant is way easier than killing a knight. To win code-ruler, we don’t necessary have to capture all castles but to acquire the highest score. Since killing a peasant is easier with a score similar to that of killing a knight, it is rewarding to put in some labors into hunting after the peasants.

Also, my peasants are quite good at claiming lands and I see that I don’t need too many of them. Therefore, after a specific number of peasants, the castles would just concentrate on producing knights to attack others. Besides, this would be good for scoring point as each knight counts twice the point as the peasants at the end of the game.

Lastly, thanks to the review of Jianfei and Jeffrey, I have found and corrected all the java standard violations in the code. I also kept in mind to follow the java standard when inserting and modifying code, hopefully, this program will not contain any violations.

The revised source code can be found here.

Knowing that there is the “Big Match” in class tomorrow, I tested my code against 4 instead of just 1 sample ruler to see how it did. I did 4 test runs and it wins three of the matches. I hope that was not just a coincidence and that it will continue to do well in the match tomorrow.

No comments: