makeall.dev
FRIDAY, MAY 15, 2026
VOL. III · EST. 2020
./make all
"BUILD SMALL. SHIP OFTEN."
INDIE PRESS · EST. 2020

Age of Empire II AI Expert System


This is an introduction to the AoE II DE AI Expert System. Most of the information is based on documentation that comes with the game located here:

<Install Location>\AoE2DE\Docs\All

AI Expert System

A rule based system that uses a LISP like script to define a series of rules which are tested to perform various actions by the AI player.

Rules

Rules are if-then-do statements. The predicate can be compounded and the action can be any number of things including a way to disable the rule itself from further processing.

(defrule
    (predicate)
    =>
    (action)
)
(defrule
(true)
 =>
(disable-self)
)

Facts

The AI Expert systems call these predicates, Facts. There are a lot of in-built facts that can be used to make scripting easier.

Actions

Actions are limited in a sense what a player can do in the game. Most of the actions are predefined as well.

Defconst

This lets you define constants so the code is more readable instead of having random numbers and strings everywhere.

Load

Helps you modularize the code and include files in the main AI script file. It also lets you load files randomly to build a more versatile AI player.

Preprocessors

C/C++ like preprocessors to conditionally load rules and files.

Conditional loading recognizes four directives:

system defined symbol list is present in the documentation

Predefined Stuff

AI Location

Location where the AI files are kept

<Installed Location>\AoE2DE\resources\_common\ai

File Structure

Continuous Development

Challenge

I am building an AI to play a custom scenario game that I myself play a lot just for fun. I call it Army Rush, 500 Pop, post-Imperial, all visible game with infinite resources played in Amazon Tunnel against five players. I have won with selected civs against Moderate AI. The goal is to see if I can create an AI which can handle Hard or Extreme AIs.

Resources