Tuesday, April 27, 2010

Age of Empires 2: AI Scripting


This last month I've been tackling AI scripting for Age of Empires 2. I was actually feeling the need for some old fashioned RTS play and while loading up AoE2, stumbled across some help guides for creating computer player AI files.

First off, the community that still revolves around this 10 year old game astounds me. The most active locale of the community seems to be Age of Kings Heaven. It's really awesome to have a community like that to answer the riduclous and mundane questions. I would not have stuck to these AI files if it wasn't for their inspiration and aid.

The language to implement the AI in AoE2 is interesting. The general flow of it is similar to the BG2 scripting language where it simply reads through a bunch of rules that have conditions followed by actions. If the conditions are met, the actions are carried out, otherwise the rule is skipped until the next pass through. The language lacks numerical operations (+, -, *, /), normal variable functionality, and the programmer doesn't directly control the actions the AI takes. I'm speculating that these standard tools were left out to ensure AIs could not break the game or hog system resources. The rule block structure and lack of normal tools requires the programmer to use plenty of heuristics and creativity.

If I had the ability of direct control, these houses would have been lined up to double as a wall.

I created two AIs. The first one is an all-around player that I built with the purpose of learning the language and just getting a functioning AI up. The second is a helper AI that provides resources to his allies. Both of these AIs were created with some parallel intelligence as promoted by Steve Grand. They can handle game-shipped opponents, but I doubt they would stand to many of the better home-brewed AIs out there.


I may share some more details and examples of the AoE AI building, but I just wanted to get up an overview of what I've been doing this last month.

Update: AI files now linked in the side bar and below.
Econ Byzantine
Staple Frank