Showing posts with label AI. Show all posts
Showing posts with label AI. Show all posts

Wednesday, September 8, 2010

Age of Empires 2 TC AI Startup and Code Help- AI Creation

The Startup:

This link gives you a Enhanced AI Editor for AOC 2 TC. http://www.sourceforge.net/projects/eaie

All you need to do have these files in the AI folder in the Age of Empires root folder, doesn't matter whether they are filled or empty. So create them now and worry later about filling them.

For example, TemperD is an AI, you need to have TemperD.ai and TemperD.per in the AI folder. Then you can put as many sub folders as you need and give the information in TemperD.per file.

Code help:

This link gives you files for an over all idea of how the code and AI is. https://sites.google.com/site/pcgamehelper/TemperD.zip?attredirects=0&d=1

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.