Sunday, September 7, 2008

CodeRuler

Objective

Taken from assignments page:

  • Become more familiar with the Eclipse IDE.
  • Begin to understand the complexities of working effectively with other people on a software project.
  • Have some fun!
What is CodeRuler?

Taken from the IBM Site:
"The game has a simple premise: You are the imperial ruler of your very own medieval kingdom. Your peasants and knights depend on your brilliant strategic thinking, agile adaptability, and superior Java programming skill to survive, increase, and prosper. Your objective as a player is to write Java code that simulates this ruler. The gaming simulator pits your ruler against up to six opponents' rulers (or the included sample rulers) and determines the winner."

For this assignment, I have collaborated with my partner, Daniel Arakaki. The scope of this program was somewhat small, so implementing a single class together was a little tight. We did find an elegant solution tho: we decided on one person to handle the peasants and another to handle the knights; since it takes both units to strategically win the game. Daniel was actually a really good partner; he had a significant amount of strategy and implementation ready a week prior to the deadline. Our only form of communication was through email, and yet, speedy replies and effective communication was in play. On the contrary, I do think that the assignment could have been handled individually, which could have taken away the stress and worry about your teammates end of the bargain.

Strategy

Things to keep in mind:
  • Peasants who can claim and work the land.
  • Knights who can fight battles and capture other rulers' peasants, knights, or castles.
  • A castle that can create more knights and peasants. The more land you have, the faster it creates them.
The strategy really is two part: Peasants and Knights.

Peasants
As far as peasants go, there isn't really much that they can do. Move and claim. How in the world do you come up with a strategy for such a brainless class? Initially looking at IBM's Code sample, I noticed the way that they randomly assigned directions for each of the peasants. I stopped and pondered if there is a better way. Maybe to migrate as a pact? Disperse? or optimize the random movement? I decided to take the last approach and restrict the peasants movement to reduce the amount of moves a peasant makes in its own claimed territory; making wiser directional choices will help increase the amount of land claimed in a smaller time frame.

Knights
I feel that knights have a lot to do with if you are going to win the game or not. Who do you attack first, the peasants? Other knights? Go strait for the castle? Daniel was the mastermind behind this one. Daniel went ahead and implemented a peasants > castle > knights precedence, which is somewhat effective in some cases.

Conclusion

As far as the Eclipse IDE experience, its only beginning to grow on me in a positive way. Some of the experiences include: the easy importing of jar files, import statements, auto-JavaDoc filling and generating, easy indentation edit, cascading function/variable name changes, I mean the list just goes on. I'm just excited to see what else it has in store for me.

As I took a look at the programming aspect of the assignment , I found the the way the classes were structured and coded were perfectly. The inheritance hierarchy made the object easy to interact with each other, as they held similar properties and functions that weaved this game together. Here is an illustrated example (taken from the IBM Site):



As you can see, shared functions through the IObject interface lace the individual instances of peasants, knights, and castles. The IObject coupled with the World.java class/functions make room for easy programming. Which brings me to my next point. A speed bump that I encounted in this assignment was to actually strategically think of how the best way to "rule the territory" was. Long story short, the coding is much easier than coming up with some type of strategy, but at the end of the day, I can easily say that this was a fun and engaging assignment.

Results

Our Score on the left, Computer on the right

v. migrate
508 - 14
582 - 16
390 - 4

v. gang up
135 - 436
140 - 433
182 - 399

v. split up
120 - 405
136 - 392
116 - 417



Source

JavaDoc

No comments: