Tags
Age Of Empires II AI Algokit Algorand Angular Blockchain Blog CC Certification Challenge cryptocurrencies CSS ctf Cybersecurity Data Django Docker Ebooks HackTheBox Homebrew HTML Hugo ISC2 Modding Playstation PostgreSQL Project Ps2 Purevolume Python python R scripts SOC TryHackMe Walkthrough Website Windows
323 words
2 minutes
Age of Empires II - AI Scripting.
01/04/2024
This is a brief introduction to AI scripting in Age Of Empires II. In the following resources you may find an in depth overview of the tools and relevant settings.
Resources:
- interlepus YouTube Playlist (English)
- arandi YouTube Playlist (English)
- AI Game Junction YouTube Playlist (English)
- Igor Hernández YouTube Playlist (Spanish)
- UserPatch AI Scripters
- AoK Heaven Games - World of AI Scripting Chapter 1
- Microsoft’s Computer Player Strategy Builder Guide Documentation
- AI Scripting Encyclopedia by airef
- AI Scripters Discord Link
.per and .ai files:
- AIs files come in pairs: name.ai and name.per (name’s must be identical).
- This files should be located:
— AoE II DE: C:\Program Files (x86)\Steam\steamapps\common\AoE2DE\resources\_common\ai\
— Classic AoE II: \Age Of Empires II\AOE II - The Conquerors\AI
Scripting Language Overview:
- AoE II scripting language is based on CLIPS (C Language Integrated Production System).
- Defining rules involves
defrule
instruction with facts and actions. - Facts trigger actions as long as they remain true unless disabled.
- Example:
(defrule (true) => (chat-to-all "Hi, let's play AoE II!") (disable-self) ;Disable after executed once. )
Programming Levels:
- There are five levels of AoE II programming:
- Defrules, defconsts, timers…
- Random generator, conditional (file) loading, goals
- Strategic Numbers
- Userpatch commands
- Direct Unit Control
Scouting the Map:
- Level 3 programming involves strategic numbers (SN) for adjusting AI parameters.
- SN adjust AI behavior and can be changed throughout the game.
- Default values are important to understand AI behavior fully.
Setting Strategic Numbers:
(defrule (true) => (set-strategic-number strategic-number number) (disable-self) )
Example:
(defrule (true) => (set-strategic-number sn-cap-civilian-explorers 0) (set-strategic-number sn-total-number-explorers 0) (disable-self) )
Units and Buildings IDs:
- IDs list: Unit/Building ID list
- Define constants using
(defconst constant-name constant-value)
.
Example:
(defconst livestock-class 958) (unit-type-count livestock-class > 0)
Conditionals:
- Use
#load-if-defined
to check civilization. - Example:
#load-if-defined BRITON-CIV (defconst text-my-civ "I'm Britons, will make Longbows") #else (defconst text-my-civ "I'm not Britons, will not make Longbows") #end-if
Training Villagers:
- Use fact-checkers like
can-train
to avoid bugs. - Example:
(defrule (can-train villager) => (train villager) )
Miscellaneous:
- Use space with relative operators like
>= 5
. - Prefix types with TypeOp (only for level 4 and 5).
- Example:
(defconst starting-vills-on-sheep 6) (defrule (true) => (chat-to-all "I need %d villagers on sheep" c: starting-vills-on-sheep) (disable-self) )
- Building conditions:
can-build
checks if the building is available.sn-initial-exploration-required
: Change default from 2 to 0.(housing-headroom < 4)
: Example condition for housing.