Thursday, 18 October 2012

Great programming analogies No.2. Age of Empires. Part 2

This is the second in a series of posts where I plan to describe my favourite analogy. Age of Empires. I find this analogy very useful when teaching Object Oriented Programming - OOP. In this post, I will describe the game that my analogy is based on. Age of Empires II - Age of Kings.
You can read the first part of this series here.
Age of Empires II is a game of empire building and conquest.

HTML5 player

The game is set roughly in the Dark, Middle and Renaissance ages. In fact one of your objectives is to advance through the ages. As you do so, new technologies and troop types become available.
You begin with a town hall and some villagers whom you should put to work immediately.
The villagers are able to harvest resources such as food, wood, stone and gold. They are also able to construct various buildings.

Resources are important to the game. You need food to sustain your troops. More food means you can recruit new troops and villagers.
Troops are recruited at special buildings such as Archery ranges and Barracks. To construct these buildings, you must put your Villagers to work with resources that they have already gathered.
Troops not only cost you food, they also cost gold which represents the cost of arming and training them.
Your growing population all need somewhere to live so you must ensure that the villagers are kept busy building enough houses.

Some buildings are used for research in addition to or instead of producing troops. For example. With a Barracks, you can recruit Axemen as well as research newer types such as Spearmen.
Smiths do not produce any troops but allow you to research better types of armour.

As you continue to research and construct new buildings, more types of troop become available. When you research enough technologies and construct enough of the appropriate buildings, you will progress to the next age whereupon all of your buildings take on a more 'up to date' appearance. The next age will also make new buildings and troop types available.

This no doubt sounds like a town planner's or academic's paradise.
Need I remind you that you are not alone? There is a point to all of this constructing, harvesting and researching. That is to build up armies to "go forth and conquer". The reason you are recruiting troops is so that they can go off and fight your opponent’s troops in the hope of winning. The reason that you are researching better weapons and armour is so that your troops are better equipped than you opponent's troops and therefore more likely to win.
If you have played any kind of strategy game, you will no doubt "get the picture".

Hopefully, you will understand the principles enough to follow this series of posts that walk you through the fundamentals of Object Oriented Programming - OOP and C# programming.
If you haven't played this game, then I urge you to find a copy as soon as you can and get playing. It's great fun.

Please forgive the excessive use of bold in this post, I wanted to emphasise those terms I considered important to the analogy going forward.
My intention is to produce a series of short videos to accompany each post to illustrate various concepts, so make sure you look out for them.
You will need to bear with me however as this will take some time to organise and there are other demands on my time. In addition to my day job, there is the family life, horse riding lessons, hobby farming AND did I mention that I have less than two months to finish my dissertation!

Flash player

See you soon

Phil Stirpé
"I don't do average!"