Age Of Kings Land Scenario Guide

Part 4: A.I.

For those of you who don't know what A.I. means, it stands for Artificial Intelligence. This is what controls the computer players. Believe it, you can create your own! Go to your favorite text editor and start typing! The A.I. In AOK is programmed in a language similar to C++, but it is unique to the game. It is made up of the following:

1. Comments  Comments are just plain text that the computer ignores. An example:
    ;this is a comment, it will be ignored

2. Constants  A constant is a value ( such as 67,45, 32, etc ). It can't be changed once declared.

3. Operators  Used within the conditions. Example

Less than -  <
Less or equal - <=
Greater than - >
Greater or equal - >=
Equal - ==
Not equal - !=

4. Facts  Facts are used in a condition. Facts are used to check to see if things can be built. Example:

(can-research ri-crossbow)
………….do stuff

5. And of course there are System Constants, Actions, Parameters, and Rules. Actions allow the A.I. To build something, Parameters are things we pass on as either actions or facts. Rules are what we use to combine all the components into something that works. Example:

(defrule
(game-time greater-than 30)
=>
(resign)
)

The => allows the list of actions to start the rule. In order to get an A.I working, you need to have a .per file and an .ai file. The .per contains all the text. Now lets get into creating an A.I.!
To build a building, type the following. It will only build one if there isn't one, and if destroyed will build another.

(defrule
(can-build castle)
(building-type-count castle ==0)
=>
(build-castle)
)

The ) checks if there is or isn't a castle over and over again. If you put in the (disable-self) it would only execute once.
previous                                                       next page

Part 1: Placing Units and Terrain
Part 2: Scenarios
Part 3: Triggers
Part 4: A.I.
Part 5: Tricks