
IMPORTANT: There must be two copies of the file in the AI folder, one that is *.per and another that is *.ai. It is not actually important what is in the *.ai file, but the game needs for there to be an AI file in order to load the PER file. (Some of you have gotten error messages because there were not two copies of the file.)
You will need to give the player some starting resources and some resources on the map nearby to see healthy results.
; SAMPLE AOK AI FILE
; 12 October 1999
; ES DeathShrimp
; This sample AI file is used for Teutons on a non-water map that start in the Feudal Age. It can easily be adapted for other civs and ages.
; ============== GROUPS - most of these will work for any file
(defrule ; ============== ATTACK GROUPS - changing percent attack soldiers will make an AI weak or tough (defrule ; ================== RESIGNING - resigns if it can't train villagers (defrule (defrule ; ============== COMPUTER CHEATING - In long games, a CP can run out of resources. This magically gives him more. Delete if you don't like your AI to cheat. (defrule (defrule ; ============== ATTACKING - The AI will attack once at 1100 seconds and then again every 1400 sec, provided it has enough defense soldiers. (defrule (defrule ; ============== BUILD LISTS (defrule ;maintain housing ;maintain a town center (defrule (defrule (defrule (defrule (defrule (defrule (defrule (defrule (defrule (defrule (defrule (defrule (defrule (defrule ; ============== MILITARY UNITS (defrule (defrule (defrule (defrule ; ============== ADVANCING IN AGE ; Feudal to Castle (defrule (defrule (defrule (defrule ;getting needed food ; advance to castle age if possible. ; Castle to Imperial (defrule (defrule (defrule (defrule ;getting needed food ; advance to imperial age if possible. ; ========================== UPGRADES - I usually use the same rules for upgrades for all civs. If the AI has a certain number of units, it tries to upgrade them. There are no rules for Hand Cannons or Bombards below. ; problem with escrow - give up (defrule ; sets initial goal for escrow to make sure there are villagers (defrule (defrule ; sets escrow (defrule ; ///////////////////////////////////////////////////// (defrule (defrule (defrule (defrule (defrule (defrule (defrule (defrule (defrule (defrule (defrule (defrule (defrule (defrule (defrule (defrule (defrule (defrule (defrule ;DOCK UNITS (defrule (defrule (defrule (defrule ; ////////////////////////WEAPONS////////////////// (defrule (defrule (defrule ;ARCHER UPGRADES -- cost food/gold (defrule (defrule (defrule (defrule (defrule (defrule (defrule (defrule (defrule (defrule (defrule (defrule (defrule ; /////////////////////SIEGE RESEARCH ITEMS/////////////////////////// (defrule ;FORTRESS UPGRADES
(true)
=>
(set-strategic-number sn-minimum-boar-hunt-group-size 4)
(set-strategic-number sn-maximum-town-size 25)
(set-strategic-number sn-camp-max-distance 30)
(set-strategic-number sn-mill-max-distance 30)
(set-strategic-number sn-percent-enemy-sighted-response 100)
(set-strategic-number sn-enemy-sighted-response-distance 25)
(set-strategic-number sn-blot-exploration-map 1)
(disable-self)
)
(true)
=>
(set-strategic-number sn-task-ungrouped-soldiers 1)
(set-strategic-number sn-percent-attack-soldiers 70)
(set-strategic-number sn-number-explore-groups 1)
(disable-self)
)
(building-type-count town-center less-than 1)
(unit-type-count-total villager <
(not (can-train villager) )
=>
(resign)
(disable-self)
)
; ============== VILLAGER ASSIGNMENT - most of these will work for any file
(true)
=>
(set-strategic-number sn-percent-civilian-explorers 0)
(set-strategic-number sn-percent-civilian-builders 15)
(set-strategic-number sn-percent-civilian-gatherers 85)
(set-strategic-number sn-cap-civilian-explorers 0)
(set-strategic-number sn-cap-civilian-gatherers 100)
(set-strategic-number sn-food-gatherer-percentage 35)
(set-strategic-number sn-gold-gatherer-percentage 40)
(set-strategic-number sn-stone-gatherer-percentage 0)
(set-strategic-number sn-wood-gatherer-percentage 25)
(set-strategic-number sn-maximum-gold-drop-distance 20)
(set-strategic-number sn-maximum-stone-drop-distance 20)
(set-strategic-number sn-maximum-food-drop-distance 20)
(disable-self)
)
(true)
=>
(enable-timer 4 3600)
(disable-self)
)
(timer-triggered 4)
=>
(cc-add-resource food 700)
(cc-add-resource wood 700)
(cc-add-resource gold 700)
(disable-timer 4)
(enable-timer 4 2700)
)
(game-time >
=>
(attack-now)
(enable-timer 7 1100)
(disable-self)
(chat-local-to-self "first attack")
)
(timer-triggered 7)
(defend-soldier-count >
=>
(attack-now)
(disable-timer 7)
(enable-timer 7 1400)
(chat-local-to-self "other attacks")
)
(unit-type-count-total villager less-than 30)
(can-train villager)
=>
(train villager)
(chat-local-to-self "villager")
)
(defrule
(housing-headroom less-than 4)
(population-headroom greater-than 0)
(can-build house)
=>
(build house)
(chat-local-to-self "house")
)
(defrule
(game-time greater-than 45)
(building-type-count town-center less-than 1)
(can-build town-center)
=>
(build town-center)
)
(building-type-count-total barracks less-than 1)
(can-build barracks)
=>
(build barracks)
(chat-local-to-self "barracks")
)
(building-type-count-total archery-range less-than 1)
(can-build archery-range)
=>
(build archery-range)
(chat-local-to-self "range")
)
(building-type-count-total stable less-than 1)
(can-build stable)
=>
(build stable)
(chat-local-to-self "stable")
)
(building-type-count-total blacksmith less-than 1)
(can-build blacksmith)
=>
(build blacksmith)
(chat-local-to-self "blacksmith")
)
(building-type-count-total market less-than 1)
(can-build market)
=>
(build market)
(chat-local-to-self "market")
)
(building-type-count-total university less-than 1)
(can-build university)
=>
(build university)
(chat-local-to-self " university ")
)
(building-type-count-total monastery less-than 1)
(can-build monastery)
=>
(build monastery)
(chat-local-to-self " monastery ")
)
(defrule
(building-type-count-total castle less-than 1)
(can-build castle)
=>
(build castle)
(chat-local-to-self "castle")
)
(building-type-count-total siege-workshop less-than 1)
(can-build siege-workshop)
=>
(build siege-workshop)
(chat-local-to-self "siege workshop")
)
(building-type-count-total farm less-than 4)
(can-build farm)
=>
(build farm)
)
(food-amount less-than 100)
(building-type-count-total farm less-than 12)
(can-build farm)
=>
(build farm)
)
(resource-found wood)
(building-type-count-total lumber-camp <
(dropsite-min-distance wood >
(can-build lumber-camp)
=>
(build lumber-camp)
(chat-local-to-self "wood place")
)
(resource-found gold)
(building-type-count-total mining-camp <
(dropsite-min-distance gold >
(can-build mining-camp)
=>
(build mining-camp)
(chat-local-to-self "gold place")
)
(resource-found stone)
(building-type-count-total mining-camp <
(dropsite-min-distance stone >
(can-build mining-camp)
=>
(build mining-camp)
(chat-local-to-self "rock place")
)
(building-type-count-total mill less-than 1)
=>
(build mill)
(chat-local-to-self "mill")
)
(unit-type-count-total knight-line <
(can-train knight-line)
=>
(train knight-line)
(chat-local-to-self "knight")
)
(unit-type-count-total militiaman-line <
(can-train militiaman-line)
=>
(train militiaman-line)
(chat-local-to-self "infantry")
)
(unit-type-count-total scout-cavalry-line <
(can-train scout-cavalry-line)
=>
(train scout-cavalry-line)
(chat-local-to-self "scout")
)
(not (town-under-attack))
(unit-type-count-total battering-ram-line <
(can-train battering-ram-line)
=>
(train battering-ram-line)
(chat-local-to-self " I want to ram something")
)
(unit-type-count-total villager >
(current-age == feudal-age)
=>
(set-goal 16 98)
(disable-self)
)
(goal 16 98)
(wood-amount greater-than 600)
(can-sell-commodity wood)
=>
(chat-local-to-self "selling wood for castle gold")
(sell-commodity wood)
)
(goal 16 98)
(stone-amount greater-than 500)
(commodity-selling-price stone greater-than 50)
(can-sell-commodity stone)
=>
(chat-local-to-self "selling stone for castle gold")
(sell-commodity stone)
)
(goal 16 98)
(food-amount greater-or-equal 1100)
(can-sell-commodity food)
=>
(chat-local-to-self "selling food for castle gold")
(sell-commodity food)
)
(defrule
(goal 16 98)
(gold-amount greater-or-equal 1000)
(commodity-buying-price food less-than 200)
(can-buy-commodity food)
=>
(chat-local-to-self "buying castle food")
(buy-commodity food)
)
(defrule
(goal 16 98)
(can-research-with-escrow castle-age)
=>
(release-escrow wood)
(release-escrow food)
(release-escrow gold)
(release-escrow stone)
(research castle-age)
(chat-local-to-self "rising to castle")
(set-goal 16 0)
)
(unit-type-count-total villager >
(current-age == castle-age)
=>
(set-goal 16 99)
(disable-self)
)
(goal 16 99)
(wood-amount greater-than 600)
(can-sell-commodity wood)
=>
(chat-local-to-self "selling wood for imperial gold")
(sell-commodity wood)
)
(goal 16 99)
(stone-amount greater-than 500)
(commodity-selling-price stone greater-than 50)
(can-sell-commodity stone)
=>
(chat-local-to-self "selling stone for imperial gold")
(sell-commodity stone)
)
(goal 16 99)
(food-amount greater-or-equal 1100)
(can-sell-commodity food)
=>
(chat-local-to-self "selling food for imperial gold")
(sell-commodity food)
)
(defrule
(goal 16 99)
(gold-amount greater-or-equal 1000)
(commodity-buying-price food less-than 200)
(can-buy-commodity food)
=>
(chat-local-to-self "buying imperial food")
(buy-commodity food)
)
(defrule
(goal 16 99)
(can-research-with-escrow imperial-age)
=>
(release-escrow wood)
(release-escrow food)
(release-escrow gold)
(release-escrow stone)
(research imperial-age)
(chat-local-to-self "rising to imperial")
(set-goal 16 0)
)
(or
(or
(escrow-amount wood >
(escrow-amount food >
)
(or
(escrow-amount gold >
(escrow-amount stone >
)
)
=>
(release-escrow wood)
(release-escrow food)
(release-escrow gold)
(release-escrow stone)
(set-goal 16 0)
)
; ////////////////////////////////////////////////////
(true)
=>
(set-goal 16 50)
(disable-self)
)
(unit-type-count villager >
=>
(set-goal 16 0)
(disable-self)
)
(true)
=>
(set-escrow-percentage wood 40)
(set-escrow-percentage food 40)
(set-escrow-percentage gold 40)
(set-escrow-percentage stone 40)
)
;UNIT UPGRADES
(goal 16 0)
(can-research-with-escrow my-unique-unit-upgrade)
=>
(release-escrow wood)
(release-escrow food)
(release-escrow gold)
(release-escrow stone)
(research my-unique-unit-upgrade)
(chat-local-to-self "research elite uniques")
)
(goal 16 0)
(unit-type-count militiaman >
(can-research-with-escrow ri-man-at-arms)
=>
(release-escrow wood)
(release-escrow food)
(release-escrow gold)
(release-escrow stone)
(research ri-man-at-arms)
(chat-local-to-self "research man-at-arms")
)
(goal 16 0)
(unit-type-count man-at-arms >
(can-research-with-escrow ri-long-swordsman)
=>
(release-escrow wood)
(release-escrow food)
(release-escrow gold)
(release-escrow stone)
(research ri-long-swordsman)
(chat-local-to-self "research long swordsman ")
)
(goal 16 0)
(unit-type-count long-swordsman >
(can-research-with-escrow ri-two-handed-swordsman)
=>
(release-escrow wood)
(release-escrow food)
(release-escrow gold)
(release-escrow stone)
(research ri-two-handed-swordsman)
(chat-local-to-self "research two-handed-swordsman")
)
(goal 16 0)
(unit-type-count two-handed-swordsman >
(can-research-with-escrow ri-champion)
=>
(release-escrow wood)
(release-escrow food)
(release-escrow gold)
(release-escrow stone)
(research ri-champion)
(chat-local-to-self "research champion")
)
(goal 16 0)
(unit-type-count-total spearman >
(can-research-with-escrow ri-pikeman)
=>
(release-escrow wood)
(release-escrow food)
(release-escrow gold)
(release-escrow stone)
(research ri-pikeman)
(chat-local-to-self "research pike")
)
(goal 16 0)
(unit-type-count-total scout-cavalry >
(can-research-with-escrow ri-light-cavalry)
=>
(release-escrow wood)
(release-escrow food)
(release-escrow gold)
(release-escrow stone)
(research ri-light-cavalry)
(chat-local-to-self "research light-cavalry")
)
(goal 16 0)
(unit-type-count-total camel >
(can-research-with-escrow ri-heavy-camel)
=>
(release-escrow wood)
(release-escrow food)
(release-escrow gold)
(release-escrow stone)
(research ri-heavy-camel)
(chat-local-to-self "research heavy camel")
)
(goal 16 0)
(unit-type-count-total knight >
(can-research-with-escrow ri-cavalier)
=>
(release-escrow wood)
(release-escrow food)
(release-escrow gold)
(release-escrow stone)
(research ri-cavalier)
(chat-local-to-self "research cavalier")
)
(goal 16 0)
(unit-type-count-total cavalier >
(can-research-with-escrow ri-paladin)
=>
(release-escrow wood)
(release-escrow food)
(release-escrow gold)
(release-escrow stone)
(research ri-paladin)
(chat-local-to-self "research paladin")
)
(goal 16 0)
(unit-type-count archer >
(can-research-with-escrow ri-crossbow)
=>
(release-escrow wood)
(release-escrow food)
(release-escrow gold)
(release-escrow stone)
(research ri-crossbow)
(chat-local-to-self "research crossbow")
)
(goal 16 0)
(unit-type-count crossbowman >
(can-research-with-escrow ri-arbalest)
=>
(release-escrow wood)
(release-escrow food)
(release-escrow gold)
(release-escrow stone)
(research ri-arbalest)
(chat-local-to-self "research arbalest")
)
(goal 16 0)
(unit-type-count cavalry-archer >
(can-research-with-escrow ri-heavy-cavalry-archer)
=>
(release-escrow wood)
(release-escrow food)
(release-escrow gold)
(release-escrow stone)
(research ri-heavy-cavalry-archer)
(chat-local-to-self "research heavy-cavalry-archer")
)
(unit-type-count-total skirmisher >
(can-research-with-escrow ri-elite-skirmisher)
=>
(release-escrow wood)
(release-escrow food)
(release-escrow gold)
(release-escrow stone)
(research ri-elite-skirmisher)
(chat-local-to-self "research elite skirmisher")
)
(goal 16 0)
(unit-type-count scorpion >
(can-research-with-escrow ri-heavy-scorpion)
=>
(release-escrow wood)
(release-escrow food)
(release-escrow gold)
(release-escrow stone)
(research ri-heavy-scorpion)
(chat-local-to-self "research heavy-scorpion")
)
(goal 16 0)
(unit-type-count battering-ram >
(can-research-with-escrow ri-capped-ram)
=>
(release-escrow wood)
(release-escrow food)
(release-escrow gold)
(release-escrow stone)
(research ri-capped-ram)
(chat-local-to-self "research capped ram")
)
(goal 16 0)
(unit-type-count capped-ram >
(can-research-with-escrow ri-siege-ram)
=>
(release-escrow wood)
(release-escrow food)
(release-escrow gold)
(release-escrow stone)
(research ri-siege-ram)
(chat-local-to-self "research siege-ram")
)
(goal 16 0)
(unit-type-count mangonel >
(can-research-with-escrow ri-onager)
=>
(release-escrow wood)
(release-escrow food)
(release-escrow gold)
(release-escrow stone)
(research ri-onager)
(chat-local-to-self "research onager")
)
(goal 16 0)
(unit-type-count onager >
(can-research-with-escrow ri-siege-onager)
=>
(release-escrow wood)
(release-escrow food)
(release-escrow gold)
(release-escrow stone)
(research ri-siege-onager)
(chat-local-to-self "research siege onager")
)
(defrule
(goal 16 0)
(unit-type-count galley >
(can-research-with-escrow ri-war-galley)
=>
(release-escrow wood)
(release-escrow food)
(release-escrow gold)
(release-escrow stone)
(research ri-war-galley)
(chat-local-to-self "research war-galley")
)
(goal 16 0)
(unit-type-count war-galley >
(can-research-with-escrow ri-galleon)
=>
(release-escrow wood)
(release-escrow food)
(release-escrow gold)
(release-escrow stone)
(research ri-galleon)
(chat-local-to-self "research galleon")
)
(goal 16 0)
(or
(unit-type-count galleon >
(unit-type-count war-galley >
)
(can-research-with-escrow ri-cannon-galleon)
=>
(release-escrow wood)
(release-escrow food)
(release-escrow gold)
(release-escrow stone)
(research ri-cannon-galleon)
(chat-local-to-self "research cannon-galleon")
)
(goal 16 0)
(unit-type-count-total fire-ship >
(can-research-with-escrow ri-fast-fire-ship)
=>
(release-escrow wood)
(release-escrow food)
(release-escrow gold)
(release-escrow stone)
(research ri-fast-fire-ship)
(chat-local-to-self "research fast-fire-ship")
)
(goal 16 0)
(unit-type-count demolition-ship >
(can-research-with-escrow ri-heavy-demolition-ship)
=>
(release-escrow wood)
(release-escrow food)
(release-escrow gold)
(release-escrow stone)
(research ri-heavy-demolition-ship)
(chat-local-to-self "research heavy-demolition-ship")
)
(goal 16 0)
(can-research-with-escrow ri-forging)
=>
(release-escrow wood)
(release-escrow food)
(release-escrow gold)
(release-escrow stone)
(research ri-forging)
(chat-local-to-self "research forging")
)
(goal 16 0)
(can-research-with-escrow ri-iron-casting)
=>
(release-escrow wood)
(release-escrow food)
(release-escrow gold)
(release-escrow stone)
(research ri-iron-casting)
(chat-local-to-self "research iron-casting")
)
(goal 16 0)
(can-research-with-escrow ri-blast-furnace)
=>
(release-escrow wood)
(release-escrow food)
(release-escrow gold)
(release-escrow stone)
(research ri-blast-furnace)
(chat-local-to-self "research blast-furnace")
)
(defrule
(goal 16 0)
(can-research-with-escrow ri-fletching)
=>
(release-escrow wood)
(release-escrow food)
(release-escrow gold)
(release-escrow stone)
(research ri-fletching)
(chat-local-to-self "research fletching")
)
(goal 16 0)
(can-research-with-escrow ri-bodkin-arrow)
=>
(release-escrow wood)
(release-escrow food)
(release-escrow gold)
(release-escrow stone)
(research ri-bodkin-arrow)
(chat-local-to-self "research bodkin-arrow")
)
(goal 16 0)
(can-research-with-escrow ri-bracer)
=>
(release-escrow wood)
(release-escrow food)
(release-escrow gold)
(release-escrow stone)
(research ri-bracer)
(chat-local-to-self "research bracer")
)
(goal 16 0)
(or
(unit-type-count-total archer-line >
(or
(unit-type-count-total skirmisher-line >
(unit-type-count-total cavalry-archer-line >
)
)
(can-research-with-escrow ri-padded-archer-armor)
=>
(release-escrow wood)
(release-escrow food)
(release-escrow gold)
(release-escrow stone)
(research ri-padded-archer-armor)
(chat-local-to-self "research padded-archer-armor")
)
(goal 16 0)
(or
(unit-type-count-total archer-line >
(or
(unit-type-count-total skirmisher-line >
(unit-type-count-total cavalry-archer-line >
)
)
(can-research-with-escrow ri-leather-archer-armor)
=>
(release-escrow wood)
(release-escrow food)
(release-escrow gold)
(release-escrow stone)
(research ri-leather-archer-armor)
(chat-local-to-self "research leather-archer-armor")
)
(goal 16 0)
(or
(unit-type-count-total archer-line >
(or
(unit-type-count-total skirmisher-line >
(unit-type-count-total cavalry-archer-line >
)
)
(can-research-with-escrow ri-ring-archer-armor)
=>
(release-escrow wood)
(release-escrow food)
(release-escrow gold)
(release-escrow stone)
(research ri-ring-archer-armor)
(chat-local-to-self "research ring-archer-armor")
)
(goal 16 0)
(or
(unit-type-count-total militiaman-line >
(unit-type-count-total spearman-line >
)
(can-research-with-escrow ri-scale-mail)
=>
(release-escrow wood)
(release-escrow food)
(release-escrow gold)
(release-escrow stone)
(research ri-scale-mail)
(chat-local-to-self "research scale-mail")
)
(goal 16 0)
(or
(unit-type-count-total militiaman-line >
(unit-type-count-total spearman-line >
)
(can-research-with-escrow ri-chain-mail)
=>
(release-escrow wood)
(release-escrow food)
(release-escrow gold)
(release-escrow stone)
(research ri-chain-mail)
(chat-local-to-self "research chain-mail")
)
(goal 16 0)
(or
(unit-type-count-total militiaman-line >
(unit-type-count-total spearman-line >
)
(can-research-with-escrow ri-plate-mail)
=>
(release-escrow wood)
(release-escrow food)
(release-escrow gold)
(release-escrow stone)
(research ri-plate-mail)
(chat-local-to-self "research plate-mail")
)
(defrule
(goal 16 0)
(or
(unit-type-count-total militiaman-line >
(unit-type-count-total spearman-line >
)
(can-research-with-escrow ri-tracking)
=>
(release-escrow wood)
(release-escrow food)
(release-escrow gold)
(release-escrow stone)
(research ri-tracking)
(chat-local-to-self "research tracking")
)
(goal 16 0)
(or
(unit-type-count-total militiaman-line >
(unit-type-count-total spearman-line >
)
(can-research-with-escrow ri-squires)
=>
(release-escrow wood)
(release-escrow food)
(release-escrow gold)
(release-escrow stone)
(research ri-squires)
(chat-local-to-self "research squires")
)
(goal 16 0)
(or
(unit-type-count-total knight-line >
(unit-type-count-total scout-cavalry-line >
)
(can-research-with-escrow ri-scale-barding)
=>
(release-escrow wood)
(release-escrow food)
(release-escrow gold)
(release-escrow stone)
(research ri-scale-barding)
(chat-local-to-self "research scale-barding")
)
(goal 16 0)
(or
(unit-type-count-total knight-line >
(unit-type-count-total scout-cavalry-line >
)
(can-research-with-escrow ri-chain-barding)
=>
(release-escrow wood)
(release-escrow food)
(release-escrow gold)
(release-escrow stone)
(research ri-chain-barding)
(chat-local-to-self "research chain-barding")
)
(goal 16 0)
(or
(unit-type-count-total knight-line >
(unit-type-count-total scout-cavalry-line >
)
(can-research-with-escrow ri-plate-barding)
=>
(release-escrow wood)
(release-escrow food)
(release-escrow gold)
(release-escrow stone)
(research ri-plate-barding)
(chat-local-to-self "research plate-barding")
)
(goal 16 0)
(or
(unit-type-count-total cavalry-archer-line >
(or
(unit-type-count-total knight-line >
(unit-type-count-total scout-cavalry-line >
)
)
(can-research-with-escrow ri-husbandry)
=>
(release-escrow wood)
(release-escrow food)
(release-escrow gold)
(release-escrow stone)
(research ri-husbandry)
(chat-local-to-self "research husbandry")
)
(goal 16 0)
(can-research-with-escrow ri-siege-engineers)
=>
(release-escrow wood)
(release-escrow food)
(release-escrow gold)
(release-escrow stone)
(research ri-siege-engineers)
(chat-local-to-self "research siege-engineers")
)