Wednesday, September 8, 2010

Age of Empires 2 TC AI Algorithm Writing and Strategy Making - AI Creation

Writing an AI in age of empires is very simple if you are a novice programmer of any language viz C, C++ or JAVA.

First thing in writing a program is making an algorithm. Write the algorithm perfectly and you can make the program much simpler to look and execute. And writing an algorithm for Age of Empires, the game which you might have played for ages is much more simpler. Your strategy itself is your algorithm.

I will try to explain my algorithm or my strategy. I do the things I wrote below,


  1. First of all, once the game starts, you create 4 villagers.
  2. Build a house with a villager or two.
  3. Then you make the three idle villagers collect the food.
  4. The next thing is making the scout explore.
  5. .....
  6. ..
These are the few things you need to write down before you write the AI.

The following code gives you more information on my AI TemperD.

(defrule
(population > 2)
(can-build house)
=>
(build house)
)

(defrule
(unit-type-count-total villager < 26)
=>
(train villager)
)

(defrule
(not(can-train villager))
=>
(research ri-loom)
)

(defrule
(building-type-count-total barracks == 0)
(current-age == feudal-age)
(can-build barracks)
=>
(build barracks)
)

(load "TemperD/TemperD-Resources")
(load "TemperD/TemperD-Strat")
(load "TemperD/TemperD-War")
(load "TemperD/TemperD-Research")

(defrule
(unit-type-count-total villager > 25)
(can-research feudal-age)
=>
(research feudal-age)
)

(defrule
(can-research castle-age)
=>
(research castle-age)
)

(defrule
(current-age == feudal-age)
(unit-type-count-total villager < 108)
=>
(train villager)
)

You can  get more information on how to write this in further posts.

No comments:

Post a Comment