翔鹰帝国网|帝国时代论坛|帝国时代系列|神话时代
 找回密码
 注册翔鹰会员(昵称)
搜索
查看: 3199|回复: 4

[发展AI] 自己写的 AI 脚本,阿拉伯 3V3 完胜 hard 级别的电脑

[复制链接]

38

主题

0

精华

5066

积分

国王

耕战
933
鹰币
4
天龙币
0
回帖
249

三级嘉禾勋章

附庸关系0
发表于 2012-9-29 21:16:32 | 显示全部楼层 |阅读模式
本帖最后由 tankant 于 2012-9-29 21:54 编辑

这是本人自己写的一个脚本,确切的说是修改前人的脚本,加了好多东西,去除作弊。最需要改进的地方可能是缺少load吧。
另外我发现timer-trigger允许的编号从1到49均有效,和文档上说的不一样。求解释。
我禁止电脑使用市场做交易,中间增加了27个timer-trigger来对资源情况实时监控,让村民动态分配来平衡资源。不过目前还平衡的不好,需要高手来加以完善。
这个AI在进攻的时候可以偷偷摸摸在敌人家里面造箭塔、城堡、兵营、马厩、靶场。
; https://www.orayes.com
; 2012.9.29



;语音指令

(defrule
   (taunt-detected any-ally 31)
   =>
   (acknowledge-taunt this-any-ally 31)
   (attack-now)
   (chat-to-player this-any-ally "我会策应你的进攻!")

)


(defrule
   (taunt-detected any-ally 23)
   =>
   (acknowledge-taunt this-any-ally 23)
   (attack-now)
   (chat-to-player this-any-ally "一起上!")

)





(defrule
    (taunt-detected any-ally 2)
=>
    (acknowledge-taunt this-any-ally 2)
    (cc-add-resource food 5000)
    (cc-add-resource wood 5000)
    (cc-add-resource gold 5000)
    (chat-to-player this-any-ally "增加了资源!")
)


; ============== GROUPS - most of these will work for any file

(defrule
        (true)
=>
        (set-strategic-number sn-maximum-town-size 25)
        (set-strategic-number sn-camp-max-distance 15)
        (set-strategic-number sn-mill-max-distance 12)
        (set-strategic-number sn-percent-enemy-sighted-response 100);敌视回应比率
        (set-strategic-number sn-enemy-sighted-response-distance 15);敌视回应距离
        (set-strategic-number sn-blot-exploration-map 1)
        (set-strategic-number sn-number-explore-groups 2)
        (set-strategic-number sn-attack-intelligence 1);敌视回应比率
        (set-strategic-number sn-minimum-dropsite-buffer 50);经济建筑和敌人城镇中心最小距离
          (set-strategic-number sn-hits-before-alliance-change 1);多少次攻击后解除结盟
    ;(set-strategic-number ability-to-dodge-missiles 0);回避力
    ;(set-strategic-number ability-to-maintain-distance 0);持距力
    (set-difficulty-parameter ability-to-dodge-missiles 0);回避力
    (set-difficulty-parameter ability-to-maintain-distance 0);持距力
    (set-strategic-number sn-group-commander-selection-method 0);部队长为最大生命值单位
        (disable-self)
)

; ============== ATTACK GROUPS - changing percent attack soldiers will make an AI weak or tough

(defrule
        ;(current-age == feudal-age)
        (true)
=>
        (set-strategic-number sn-task-ungrouped-soldiers 1)
        (set-strategic-number sn-percent-attack-soldiers 100);进攻的时候出动军队百分比
    (set-strategic-number sn-minimum-attack-group-size 1);最小攻击规模
    (set-strategic-number sn-maximum-attack-group-size 60);最大攻击规模
    (set-strategic-number sn-group-form-distance 30);设定计算机游戏者组织陆上军事单位攻击部队时,会选择距离部队集合点有多远的单位。如果生产单位的建筑物很遥远,就必须调高此策略值的数值。默认值是 20 。

    (set-strategic-number sn-attack-group-gather-spacing 10);攻击部队集合点留间隔
    (set-strategic-number sn-group-leader-defense-distance 10);部队长防御距离
    (set-strategic-number sn-maximum-gaia-attack-response 4);村民打狼的人数

        (set-strategic-number sn-number-explore-groups 1)
        (disable-self)
)

; ================== RESIGNING - resigns if it can't train villagers

(defrule
        (building-type-count town-center less-than 1)
        (unit-type-count-total villager < 2)
        (not (can-train villager) )
=>
        (resign)
        (disable-self)
)


; ============== VILLAGER ASSIGNMENT - most of these will work for any file
;农民工作分配
(defrule

        (true)
=>
    (set-strategic-number sn-minimum-boar-hunt-group-size 10)
    (set-strategic-number sn-maximum-hunt-drop-distance 5)
    (disable-self)
)
;黑暗时代农民分配
(defrule

        (current-age == dark-age)
=>
        (set-strategic-number sn-percent-civilian-explorers 0)

        (set-strategic-number sn-percent-civilian-builders 30)
        (set-strategic-number sn-percent-civilian-gatherers 70)



        (set-strategic-number sn-cap-civilian-explorers 0)
        (set-strategic-number sn-cap-civilian-gatherers 100)

        (set-strategic-number sn-food-gatherer-percentage  90)
        (set-strategic-number sn-wood-gatherer-percentage  10)

        (set-strategic-number sn-maximum-gold-drop-distance 5)
        (set-strategic-number sn-maximum-stone-drop-distance 5)
        (set-strategic-number sn-maximum-food-drop-distance 5)
        (set-strategic-number sn-maximum-wood-drop-distance 5)



    (set-goal 7 1)
    ;(chat-to-all "timer 250")
        (disable-self)

;开局找浆果和绵羊
)
(defrule
    (current-age == dark-age)
    (sheep-and-forage-too-far)
    (game-time < 500)
=>
        (set-strategic-number sn-percent-civilian-explorers 100)
        (set-strategic-number sn-cap-civilian-explorers 3)
    (chat-to-all "开局找浆果和绵羊")
    (disable-self)
)


;找到浆果
(defrule
    (current-age == dark-age)
    (resource-found food)
=>
        (set-strategic-number sn-percent-civilian-explorers 0)
        (set-strategic-number sn-cap-civilian-explorers 0)
    (chat-to-all "找到浆果和绵羊")
    (disable-self)
)






;封建时代农民分配
(defrule
        (current-age == feudal-age)
=>
        (set-strategic-number sn-percent-civilian-explorers 0)
        (set-strategic-number sn-percent-civilian-builders 50)
        (set-strategic-number sn-percent-civilian-gatherers 80)
        (set-strategic-number sn-cap-civilian-explorers 0)
        (set-strategic-number sn-cap-civilian-gatherers 100)

        (set-strategic-number sn-food-gatherer-percentage  65)
        (set-strategic-number sn-wood-gatherer-percentage  25)
        (set-strategic-number sn-gold-gatherer-percentage  10)
        (set-strategic-number sn-stone-gatherer-percentage 0)


        (set-strategic-number sn-maximum-gold-drop-distance 10)
        (set-strategic-number sn-maximum-stone-drop-distance 10)
        (set-strategic-number sn-maximum-food-drop-distance 10)
        (set-strategic-number sn-maximum-wood-drop-distance 10)
    (set-goal 7 2)
        (disable-self)
)



;城堡和帝王时代农民分配
(defrule
        (or
                (current-age == castle-age)
                (current-age == imperial-age)
        )
=>
        (set-strategic-number sn-percent-civilian-explorers 0)
        (set-strategic-number sn-percent-civilian-builders 50)
        (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  30)
        (set-strategic-number sn-wood-gatherer-percentage  15)
        (set-strategic-number sn-gold-gatherer-percentage  15)
        (set-strategic-number sn-stone-gatherer-percentage 40)


        (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)
)


; ============== COMPUTER CHEATING - In long scenario games, a CP can run out of resources. This magically gives him more.  Delete if you don't like your AI to cheat.

(defrule
        (true)
=>
        (enable-timer 4 0)
        (disable-self)
)

(defrule
        (timer-triggered 4)
=>
        ;(cc-add-resource food 5000)
        ;(cc-add-resource wood 5000)
        ;(cc-add-resource gold 5000)
        ;(disable-timer 4)
    ;(chat-to-all "操!")
        (enable-timer 4 30)
)





; ============== BUILD LISTS


;maintain housing
(defrule
    (current-age == dark-age)
        (housing-headroom less-than 4)
        (population-headroom greater-than 0)
        (can-build house)
=>
        (build house)
        (chat-to-all "house 4 left")
)


;maintain housing
(defrule
    (current-age != dark-age)
        (housing-headroom less-than 10)
        (population-headroom greater-than 0)
        (can-build house)
=>
        (build house)
        (chat-to-all "house 10 left")
)

;造城镇中心(游牧民族开局)
;maintain a town center
(defrule
        (game-time greater-than 45)
        (building-type-count town-center less-than 3)
        (can-build town-center)
=>
        (build town-center)
)

;造城镇中心
(defrule
        (current-age == castle-age)
        (building-type-count town-center less-than 3)
        (can-build town-center)
=>
        (build town-center)
)






;造兵营
(defrule
    (timer-triggered 3)
    (attack-soldier-count > 10)
    (current-age != dark-age)
        (building-type-count-total watch-tower-line less-than 10)
        (can-build watch-tower-line)
    (food-amount >= 500)
    (or
        (wood-amount >= 200)
        (gold-amount >= 300)
    )
=>
        (build-forward watch-tower-line)(chat-to-player any-enemy "9")
        (chat-to-all "build-forward watch-tower-line !!!!!!!!!!!!!")
    (disable-timer 3)
)


;造兵营
(defrule
    (timer-triggered 3)
    (attack-soldier-count > 10)
    (current-age != dark-age)
        (building-type-count-total barracks less-than 2)
        (can-build barracks)
    (food-amount >= 500)
    (or
        (wood-amount >= 200)
        (gold-amount >= 300)
    )
=>
        (build-forward barracks)(chat-to-player any-enemy "9")
        (chat-to-all "build-forward barracks !!!!!!!!!!!!!")
    (disable-timer 3)
)

;造靶场
(defrule
    (timer-triggered 3)
    (attack-soldier-count > 10)
        (building-type-count-total archery-range less-than 2)
        (can-build archery-range)
    (food-amount >= 500)
    (or
        (wood-amount >= 200)
        (gold-amount >= 300)
    )
=>
        (build-forward archery-range)(chat-to-player any-enemy "9")
        (chat-to-all "build-forward range !!!!!!!!!!!!!")
    (disable-timer 3)
)

;造马厩
(defrule
    (timer-triggered 3)
    (attack-soldier-count > 10)
        (building-type-count-total stable less-than 2)
        (can-build stable)
    (food-amount >= 500)
    (or
        (wood-amount >= 200)
        (gold-amount >= 300)
    )
=>
        (build-forward stable)(chat-to-player any-enemy "9")
        (chat-to-all "build-forward stable !!!!!!!!!!!!!")
    (disable-timer 3)
)

;造城堡
(defrule
    (timer-triggered 3)
    (attack-soldier-count > 10)
        (can-build castle)
=>
        (build-forward castle)(chat-to-player any-enemy "9")
        (chat-to-all "build-forward castle !!!!!!!!!!!!!")
    (disable-timer 3)
)












;造兵营
(defrule
    (current-age != dark-age)
    (attack-soldier-count <= 10)
        (building-type-count-total barracks less-than 2)
        (can-build barracks)
    (food-amount >= 500)
    (or
        (wood-amount >= 200)
        (gold-amount >= 300)
    )
=>
        (build barracks)
        (chat-to-all "barracks")
)

;造靶场
(defrule
    (attack-soldier-count <= 10)
        (building-type-count-total archery-range less-than 2)
        (can-build archery-range)
    (food-amount >= 500)
    (or
        (wood-amount >= 200)
        (gold-amount >= 300)
    )
=>
        (build archery-range)
        (chat-to-all "range")
)

;造马厩
(defrule
    (attack-soldier-count <= 10)
        (building-type-count-total stable less-than 2)
        (can-build stable)
    (food-amount >= 500)
    (or
        (wood-amount >= 200)
        (gold-amount >= 300)
    )
=>
        (build stable)
        (chat-to-all "stable")
)







;造铁匠铺
(defrule
        (building-type-count-total blacksmith less-than 1)
        (can-build blacksmith)
    (defend-soldier-count >= 5)
=>
        (build blacksmith)
        (chat-to-all "blacksmith")
)

;造市场
(defrule
        (building-type-count-total market less-than 1)
        (can-build market)
    (food-amount >= 1000)
    (or
        (wood-amount >= 500)
        (gold-amount >= 500)
    )
=>
        (build market)
        (chat-to-all "market")
)

;造大学
(defrule
        (building-type-count-total university less-than 1)
        (can-build university)
    (food-amount >= 200)
    (or
        (wood-amount >= 200)
        (gold-amount >= 300)
    )
=>
        (build university)
        (chat-to-all " university ")
)

;造修道院
(defrule
        (building-type-count-total monastery less-than 1)
        (can-build monastery)
=>
        (build monastery)
        (chat-to-all " monastery ")
)

;造城堡
(defrule
    (attack-soldier-count <= 10)
        (building-type-count-total castle <= 2)
        (can-build castle)
=>
        (build castle)
        (chat-to-all "castle")
)






;攻城武器车间
(defrule
        (building-type-count-total siege-workshop less-than 1)
        (can-build siege-workshop)
=>
        (build siege-workshop)
        (chat-to-all "siege workshop")
)

;黑暗时代造农田
(defrule
    (current-age == dark-age)
    (sheep-and-forage-too-far)
        (building-type-count-total farm less-than 14)
    (game-time > 420)
        (can-build farm)
=>
        (build farm)
)

;非黑暗时代第一阶段造农田
(defrule
    (current-age != dark-age)

        (food-amount < 400)
    (wood-amount >= 90)
    (building-type-count-total mill != 0)
    (building-type-count-total lumber-camp != 0)
        (building-type-count-total farm < 5)
        (can-build farm)
=>
        (build farm)
)

;非黑暗时代第二阶段造农田
(defrule
    (current-age != dark-age)
        (food-amount < 400)
    (wood-amount >= 500)
    (building-type-count-total mill != 0)
    (building-type-count-total lumber-camp != 0)
        (building-type-count-total farm >= 5)
        (building-type-count-total farm < 25)
        (can-build farm)
=>
        (build farm)
)




;造矿场
(defrule
        (building-type-count-total mining-camp == 0)
    (building-type-count-total mill != 0)
    (building-type-count-total lumber-camp != 0)
        (dropsite-min-distance wood > 1)
        (can-build mining-camp)
    (game-time > 600)
=>
        (build mining-camp)
        (chat-to-all "mining-camp place")
)





;造伐木场
(defrule
        (resource-found wood)
        (building-type-count-total lumber-camp < 3)
        (dropsite-min-distance wood > 2)
        (can-build lumber-camp)
    (current-age != dark-age)
    (building-type-count-total mill != 0)
=>
    (set-strategic-number sn-camp-max-distance 25)
        (build lumber-camp)
        (chat-to-all "lumber-camp place")
)

;为黄金造矿场
(defrule
        (resource-found gold)
        (building-type-count-total mining-camp < 5)
    (building-type-count-total mill != 0)
    (building-type-count-total lumber-camp != 0)
        (dropsite-min-distance gold > 3)
        (can-build mining-camp)
    (current-age != dark-age)
=>
        (build mining-camp)
        (chat-to-all "gold place")
)

;为石头造矿场
(defrule
        (resource-found stone)
    (current-age >= castle-age)
        (building-type-count-total mining-camp < 5)
        (dropsite-min-distance stone > 3)
        (can-build mining-camp)
    (game-time > 800)
=>
        (build mining-camp)
        (chat-to-all "rock place")
)



; ============== MILITARY UNITS



;造打包投石机
(defrule
        (unit-type-count-total trebuchet < 3)
    (defend-soldier-count >= 10)
        (can-train trebuchet)
=>
        (train trebuchet)
        (chat-to-all "trebuchet")
)

;造僧侣============================

(defrule
        (difficulty == moderate)
        (unit-type-count-total monk < 1)
        (can-train monk)
=>
        (train monk)
        (chat-to-all "monk")
)

(defrule
        (difficulty == hard)
        (unit-type-count-total monk < 1)
        (can-train monk)
=>
        (train monk)
        (chat-to-all "monk")
)

(defrule
        (difficulty == hardest)
        (unit-type-count-total monk < 1)
        (can-train monk)
=>
        (train monk)
        (chat-to-all "monk")
)

;===============================



; ============== ADVANCING IN AGE

(defrule
        (current-age == dark-age)

=>
        (set-goal 99 1)
    (disable-self)
)

(defrule
        (unit-type-count-total villager > 8)
        (current-age == feudal-age)

=>
        (set-goal 99 2)
    (enable-timer 38 0)
    (enable-timer 39 0)
    (enable-timer 40 0)
    (disable-self)
)


(defrule
        (unit-type-count-total villager > 15)
        (current-age == castle-age)

=>
        (set-goal 99 3)
    (disable-self)
)

(defrule
        (unit-type-count-total villager > 15)
        (current-age == imperial-age)

=>
        (set-goal 99 4)
    (disable-self)
)





;        (set-strategic-number sn-food-gatherer-percentage  55)
;        (set-strategic-number sn-wood-gatherer-percentage  15)
;        (set-strategic-number sn-gold-gatherer-percentage  30)



;任何时代:食物和木材过少报警
(defrule
    (current-age != dark-age)
    (food-amount <= 49)
    (wood-amount <= 120)
    ;(gold-amount > 29)
    (timer-triggered 38)
=>
        (set-strategic-number sn-food-gatherer-percentage  35)
        (set-strategic-number sn-wood-gatherer-percentage  60)
        (set-strategic-number sn-gold-gatherer-percentage  5)
        (set-strategic-number sn-stone-gatherer-percentage 0)
        (chat-to-all "食物、木材都过少")
    (disable-timer 38)
    (enable-timer 38 5)
)


;任何时代:食物过少报警
(defrule
    (current-age != dark-age)
    (food-amount <= 49)
    (wood-amount > 300)
    ;(gold-amount > 29)
    (timer-triggered 5)
=>
        (set-strategic-number sn-food-gatherer-percentage  80)
        (set-strategic-number sn-wood-gatherer-percentage  15)
        (set-strategic-number sn-gold-gatherer-percentage  5)
        (set-strategic-number sn-stone-gatherer-percentage 0)
        (chat-to-all "食物过少")
    (disable-timer 209)
    (enable-timer 39 5)
)

;任何时代:木材过少报警
(defrule
    (current-age != dark-age)
    (food-amount > 300)
    (wood-amount <= 120)
    ;(gold-amount > 29)
    (timer-triggered 40)
=>
        (set-strategic-number sn-food-gatherer-percentage  20)
        (set-strategic-number sn-wood-gatherer-percentage  75)
        (set-strategic-number sn-gold-gatherer-percentage  5)
        (set-strategic-number sn-stone-gatherer-percentage 0)
        (chat-to-all "木材过少")
    (disable-timer 40)
    (enable-timer 40 5)
)


;任何时代:黄金过少报警
(defrule
    (current-age != dark-age)
    (food-amount > 300)
    (wood-amount > 300)
    (gold-amount <= 29)
=>
        (set-strategic-number sn-food-gatherer-percentage  45)
        (set-strategic-number sn-wood-gatherer-percentage  5)
        (set-strategic-number sn-gold-gatherer-percentage  50)
        (set-strategic-number sn-stone-gatherer-percentage 0)
        (chat-to-all "黄金过少")
)

;任何时代:卡人口报警
(defrule
    (housing-headroom == 0)
=>
    ;(enable-timer 90 10)
        (chat-to-all "卡人口了")
)



; Dark to Feudal,黑暗升封建

(defrule
        (unit-type-count-total villager > 5)
        (current-age == dark-age)
        (can-research-with-escrow feudal-age)
=>
        (release-escrow wood)
        (release-escrow food)
        (release-escrow gold)
        (release-escrow stone)
        (research feudal-age)

    ;(disable-timer 250)
    (chat-to-all "disable-timer 250")
        (set-strategic-number sn-food-gatherer-percentage  50)
        (set-strategic-number sn-wood-gatherer-percentage  30)
        (set-strategic-number sn-gold-gatherer-percentage  20)
    (set-goal 90 0)
        (chat-to-player any-ally "1")(chat-to-all "rising to feudal")
        (set-goal 99 20)
)


;黑暗时代劳动力动态调控=============================
;        (set-strategic-number sn-food-gatherer-percentage  80)
;        (set-strategic-number sn-wood-gatherer-percentage  20)

(defrule
    (true)
=>

    (disable-self)
)

;建造磨坊
(defrule
        (building-type-count-total mill == 0)
    ;(dropsite-min-distance food > 0)
    (can-build mill)
    (game-time > 80)
=>
        (build mill)
        (chat-to-all "mill place")
)


(defrule
        (building-type-count-total mill > 0)
        (building-type-count-total mill < 2)
    (building-type-count-total farm >= 16)
    (current-age >= castle-age)
    (can-build mill)
    (wood-amount >= 800)
    (food-amount <= 500)
=>
        (build mill)
        (chat-to-all "mill place")
)




;建造伐木场
(defrule
        (building-type-count-total lumber-camp == 0)
        (building-type-count-total mill != 0)
        ;(dropsite-min-distance wood > 1)
        (can-build lumber-camp)
    (game-time > 90)
=>
        (build lumber-camp)
        (chat-to-all "lumber-camp place")
)




;黑暗时代:(食物够了,不能升级封建):


(defrule
    (food-amount >= 500)
    (goal 99 1)
    (not
        (can-research-with-escrow feudal-age)
    )
=>
        (chat-to-all "食物够500了,但是没法升级(缺少磨坊或者伐木场,或者农民正在造,或者研究织布机中)")
        (set-strategic-number sn-food-gatherer-percentage  20)
        (set-strategic-number sn-wood-gatherer-percentage  80)
)

;黑暗时代:(没羊和浆果,且木头过少):让采集食物的农民采集木头
(defrule

    (goal 99 1)
    (not
    (sheep-and-forage-too-far)
    )
    (wood-amount < 30)
    (or
        (building-type-count mill == 0)
            (building-type-count-total lumber-camp == 0)
    )
=>
        (chat-to-all "重点采集木头")
        (set-strategic-number sn-food-gatherer-percentage  60)
        (set-strategic-number sn-wood-gatherer-percentage  40)
)


;黑暗时代:(没羊和浆果,且木头过少):让采集食物的农民采集木头
(defrule

    (goal 99 1)
    (sheep-and-forage-too-far)
    (wood-amount < 100)
    (or
        (building-type-count mill == 0)
            (building-type-count-total lumber-camp == 0)
    )
=>
        (chat-to-all "重点采集木头")
        (set-strategic-number sn-food-gatherer-percentage  75)
        (set-strategic-number sn-wood-gatherer-percentage  25)
)





;黑暗时代:(木头过多):让采集木头的农民采集食物
(defrule

    (goal 99 1)
    (wood-amount >= 100)
    (or
        (building-type-count mill == 0)
            (building-type-count-total lumber-camp == 0)
    )

=>
        (chat-to-all "重点采集食物")
        (set-strategic-number sn-food-gatherer-percentage  85)
        (set-strategic-number sn-wood-gatherer-percentage  15)
)

;黑暗时代:食物过少
(defrule
    (goal 99 1)
    (building-type-count mill == 1)
        (building-type-count-total lumber-camp == 1)
    (wood-amount >= 60)
=>
    (chat-to-all "农民全部采集食物~~~~~~~~~~~~")

        (set-strategic-number sn-food-gatherer-percentage  100)
        (set-strategic-number sn-wood-gatherer-percentage  0)
)




;        (set-strategic-number sn-food-gatherer-percentage  30)
;        (set-strategic-number sn-wood-gatherer-percentage  30)
;        (set-strategic-number sn-gold-gatherer-percentage  30)
;        (set-strategic-number sn-stone-gatherer-percentage 10)






;设置封建时代的一种状态 16
(defrule
        (unit-type-count-total villager > 10)
        (current-age == feudal-age)
=>
        (set-goal 16 98)
        (disable-self)
)


;封建升城堡
; Feudal to Castle

(defrule
        (goal 99 2)
        (can-research-with-escrow castle-age)
=>
        (release-escrow wood)
        (release-escrow food)
        (release-escrow gold)
        (release-escrow stone)
        (research castle-age)
    (chat-to-player any-ally "1")
        (chat-to-all "升级城堡时代")
        (set-goal 99 30)
)



;封建时代劳动力动态调控=============================

;        (set-strategic-number sn-food-gatherer-percentage  55)
;        (set-strategic-number sn-wood-gatherer-percentage  15)
;        (set-strategic-number sn-gold-gatherer-percentage  30)


;定时器11到37全部定义
;启动资源动态调控定时器
(defrule
    (current-age == feudal-age)
=>
    (enable-timer 11 0)
    (enable-timer 12 0)
    (enable-timer 13 0)
    (enable-timer 14 0)
    (enable-timer 15 0)
    (enable-timer 16 0)
    (enable-timer 17 0)
    (enable-timer 18 0)
    (enable-timer 19 0)
    (disable-self)
)
(defrule
    (current-age == feudal-age)
=>
    (enable-timer 20 0)
    (enable-timer 21 0)
    (enable-timer 22 0)
    (enable-timer 23 0)
    (enable-timer 24 0)
    (enable-timer 25 0)
    (enable-timer 26 0)
    (enable-timer 27 0)
    (enable-timer 28 0)
    (disable-self)
)
(defrule
    (current-age == feudal-age)
=>
    (enable-timer 29 0)
    (enable-timer 30 0)
    (enable-timer 31 0)
    (enable-timer 32 0)
    (enable-timer 33 0)
    (enable-timer 34 0)
    (enable-timer 35 0)
    (enable-timer 36 0)
    (enable-timer 37 0)
    (disable-self)

)

(defrule
    (true)
  =>
    (enable-timer 51 0)
    (disable-self)
)
(defrule
    (timer-triggered 51)
=>
    (chat-to-all "QQQQQQQQQQQQQQQQQQQQQ")
    (disable-timer 51)
    (enable-timer 51 10)
)




;xx1
;11
;封建时代:(食物1,木材1,黄金1):
(defrule
    (timer-triggered 11)
    (goal 7 2)
        (food-amount <= 400)
    (wood-amount <= 200)
    (gold-amount <= 130)
=>
        (chat-to-all "食物1,木材1,黄金1")

        (set-strategic-number sn-food-gatherer-percentage  60)
        (set-strategic-number sn-wood-gatherer-percentage  35)
        (set-strategic-number sn-gold-gatherer-percentage  5)
    (disable-timer 11)
    (enable-timer 11 209)
)

;12
;封建时代:(食物2,木材1,黄金1):
(defrule
    (timer-triggered 12)
    (goal 7 2)
        (food-amount > 400)
           (food-amount <= 800)
    (wood-amount <= 200)
    (gold-amount <= 130)
=>
        (chat-to-all "食物2,木材1,黄金1")

        (set-strategic-number sn-food-gatherer-percentage  55)
        (set-strategic-number sn-wood-gatherer-percentage  40)
        (set-strategic-number sn-gold-gatherer-percentage  5)
    (disable-timer 12)
    (enable-timer 12 209)
)

;13
;封建时代:(食物3,木材1,黄金1):
(defrule
    (timer-triggered 13)
    (goal 7 2)
        (food-amount > 800)
    (wood-amount <= 200)
    (gold-amount <= 130)
=>
        (chat-to-all "食物3,木材1,黄金1")

        (set-strategic-number sn-food-gatherer-percentage  10)
        (set-strategic-number sn-wood-gatherer-percentage  55)
        (set-strategic-number sn-gold-gatherer-percentage  35)
    (disable-timer 13)
    (enable-timer 13 209)
)

;=

;14
;封建时代:(食物1,木材2,黄金1):
(defrule
    (timer-triggered 14)
    (goal 7 2)
        (food-amount <= 400)
    (wood-amount > 200)
    (wood-amount <= 500)
    (gold-amount <= 130)
=>
        (chat-to-all "食物1,木材2,黄金1")

        (set-strategic-number sn-food-gatherer-percentage  70)
        (set-strategic-number sn-wood-gatherer-percentage  25)
        (set-strategic-number sn-gold-gatherer-percentage  5)
    (disable-timer 14)
    (enable-timer 14 209)
)

;15
;封建时代:(食物2,木材2,黄金1):
(defrule
    (timer-triggered 15)
    (goal 7 2)
        (food-amount > 400)
        (food-amount <= 800)
    (wood-amount > 200)
    (wood-amount <= 500)
    (gold-amount <= 130)
=>
        (chat-to-all "食物2,木材2,黄金1")

        (set-strategic-number sn-food-gatherer-percentage  55)
        (set-strategic-number sn-wood-gatherer-percentage  20)
        (set-strategic-number sn-gold-gatherer-percentage  25)
    (disable-timer 15)
    (enable-timer 15 209)
)

;16
;封建时代:(食物3,木材2,黄金1):
(defrule
    (timer-triggered 16)
    (goal 7 2)
        (food-amount > 800)
    (wood-amount > 200)
    (wood-amount <= 500)
    (gold-amount <= 130)
=>
        (chat-to-all "食物3,木材2,黄金1")

        (set-strategic-number sn-food-gatherer-percentage  10)
        (set-strategic-number sn-wood-gatherer-percentage  20)
        (set-strategic-number sn-gold-gatherer-percentage  70)
    (disable-timer 16)
    (enable-timer 16 209)
)

;17
;封建时代:(食物1,木材3,黄金1):
(defrule
    (timer-triggered 17)
    (goal 7 2)
        (food-amount <= 400)
    (wood-amount > 500)
    (gold-amount <= 130)
=>
        (chat-to-all "食物1,木材3,黄金1")

        (set-strategic-number sn-food-gatherer-percentage  75)
        (set-strategic-number sn-wood-gatherer-percentage  5)
        (set-strategic-number sn-gold-gatherer-percentage  20)
    (disable-timer 17)
    (enable-timer 17 209)
)

;18
;封建时代:(食物2,木材3,黄金1):
(defrule
    (timer-triggered 18)
    (goal 7 2)
        (food-amount > 400)
        (food-amount <= 800)
    (wood-amount > 500)
    (gold-amount <= 130)
=>
        (chat-to-all "食物2,木材3,黄金1")

        (set-strategic-number sn-food-gatherer-percentage  45)
        (set-strategic-number sn-wood-gatherer-percentage  10)
        (set-strategic-number sn-gold-gatherer-percentage  35)
    (disable-timer 18)
    (enable-timer 18 209)
)

;19
;封建时代:(食物3,木材3,黄金1):
(defrule
    (timer-triggered 19)
    (goal 7 2)
        (food-amount > 800)
    (wood-amount > 500)
    (gold-amount <= 130)
=>
        (chat-to-all "食物3,木材3,黄金1")

        (set-strategic-number sn-food-gatherer-percentage  20)
        (set-strategic-number sn-wood-gatherer-percentage  10)
        (set-strategic-number sn-gold-gatherer-percentage  70)
    (disable-timer 19)
    (enable-timer 19 209)
)

;=======================

;xx2
;20
;封建时代:(食物1,木材1,黄金2):
(defrule
    (timer-triggered 20)
    (goal 7 2)
        (food-amount <= 400)
    (wood-amount <= 200)
    (gold-amount > 130)
    (gold-amount <= 300)
=>
        (chat-to-all "食物1,木材1,黄金2")

        (set-strategic-number sn-food-gatherer-percentage  75)
        (set-strategic-number sn-wood-gatherer-percentage  20)
        (set-strategic-number sn-gold-gatherer-percentage  5)
    (disable-timer 20)
    (enable-timer 20 209)
)

;21
;封建时代:(食物2,木材1,黄金2):
(defrule
    (timer-triggered 21)
    (goal 7 2)
        (food-amount > 400)
           (food-amount <= 800)
    (wood-amount <= 200)
    (gold-amount > 130)
    (gold-amount <= 300)
=>
        (chat-to-all "食物2,木材1,黄金2")

        (set-strategic-number sn-food-gatherer-percentage  65)
        (set-strategic-number sn-wood-gatherer-percentage  30)
        (set-strategic-number sn-gold-gatherer-percentage  5)
    (disable-timer 21)
    (enable-timer 21 209)
)

;22:过了
;封建时代:(食物3,木材1,黄金2):
(defrule
    (timer-triggered 22)
    (goal 7 2)
        (food-amount > 800)
    (wood-amount <= 200)
    (gold-amount > 130)
    (gold-amount <= 300)
=>
        (chat-to-all "食物3,木材1,黄金2")

        (set-strategic-number sn-food-gatherer-percentage  55)
        (set-strategic-number sn-wood-gatherer-percentage  25)
        (set-strategic-number sn-gold-gatherer-percentage  20)
        ;(set-strategic-number sn-stone-gatherer-percentage  20)
    (disable-timer 22)
    (enable-timer 22 209)
)

;=

;23
;封建时代:(食物1,木材2,黄金2):
(defrule
    (timer-triggered 23)
    (goal 7 2)
        (food-amount <= 400)
    (wood-amount > 200)
    (wood-amount <= 500)
    (gold-amount > 130)
    (gold-amount <= 300)
=>
        (chat-to-all "食物1,木材2,黄金2")

        (set-strategic-number sn-food-gatherer-percentage  80)
        (set-strategic-number sn-wood-gatherer-percentage  10)
        (set-strategic-number sn-gold-gatherer-percentage  10)
    (disable-timer 23)
    (enable-timer 23 209)
)

;24
;封建时代:(食物2,木材2,黄金2):
(defrule
    (timer-triggered 24)
    (goal 7 2)
        (food-amount > 400)
        (food-amount <= 800)
    (wood-amount > 200)
    (wood-amount <= 500)
    (gold-amount > 130)
    (gold-amount <= 300)
=>
        (chat-to-all "食物2,木材2,黄金2")

        (set-strategic-number sn-food-gatherer-percentage  70)
        (set-strategic-number sn-wood-gatherer-percentage  15)
        (set-strategic-number sn-gold-gatherer-percentage  15)
    (disable-timer 24)
    (enable-timer 24 209)
)

;25:过了
;封建时代:(食物3,木材2,黄金2):
(defrule
    (timer-triggered 25)
    (goal 7 2)
        (food-amount > 800)
    (wood-amount > 200)
    (wood-amount <= 500)
    (gold-amount > 130)
    (gold-amount <= 300)
=>
        (chat-to-all "食物3,木材2,黄金2")

        (set-strategic-number sn-food-gatherer-percentage  55)
        (set-strategic-number sn-wood-gatherer-percentage  25)
        (set-strategic-number sn-gold-gatherer-percentage  20)
    ;(set-strategic-number sn-stone-gatherer-percentage  20)
    (disable-timer 25)
    (enable-timer 25 209)
)

;26
;封建时代:(食物1,木材3,黄金2):
(defrule
    (timer-triggered 26)
    (goal 7 2)
        (food-amount <= 400)
    (wood-amount > 500)
    (gold-amount > 130)
    (gold-amount <= 300)
=>
        (chat-to-all "食物1,木材3,黄金2")

        (set-strategic-number sn-food-gatherer-percentage  90)
        (set-strategic-number sn-wood-gatherer-percentage  0)
        (set-strategic-number sn-gold-gatherer-percentage  10)
    (disable-timer 26)
    (enable-timer 26 209)
)

;27
;封建时代:(食物2,木材3,黄金2):
(defrule
    (timer-triggered 27)
    (goal 7 2)
        (food-amount > 400)
        (food-amount <= 800)
    (wood-amount > 500)
    (gold-amount > 130)
    (gold-amount <= 300)
=>
        (chat-to-all "食物2,木材3,黄金2")

        (set-strategic-number sn-food-gatherer-percentage  90)
        (set-strategic-number sn-wood-gatherer-percentage  0)
        (set-strategic-number sn-gold-gatherer-percentage  10)
    (disable-timer 27)
    (enable-timer 27 209)
)

;28:过了
;封建时代:(食物3,木材3,黄金2):
(defrule
    (timer-triggered 28)
    (goal 7 2)
        (food-amount > 800)
    (wood-amount > 500)
    (gold-amount > 130)
    (gold-amount <= 300)
=>
        (chat-to-all "食物3,木材3,黄金2")

        (set-strategic-number sn-food-gatherer-percentage  55)
        (set-strategic-number sn-wood-gatherer-percentage  25)
        (set-strategic-number sn-gold-gatherer-percentage  20)
    ;(set-strategic-number sn-stone-gatherer-percentage  20)
    (disable-timer 28)
    (enable-timer 28 209)
)

;======================
;xx3

;xx1
;29
;封建时代:(食物1,木材1,黄金3):
(defrule
    (timer-triggered 29)
    (goal 7 2)
        (food-amount <= 400)
    (wood-amount <= 200)
    (gold-amount > 300)
=>
        (chat-to-all "食物1,木材1,黄金3")

        (set-strategic-number sn-food-gatherer-percentage  85)
        (set-strategic-number sn-wood-gatherer-percentage  15)
        (set-strategic-number sn-gold-gatherer-percentage  0)
    (disable-timer 29)
    (enable-timer 29 209)
)

;30
;封建时代:(食物2,木材1,黄金3):
(defrule
    (timer-triggered 30)
    (goal 7 2)
        (food-amount > 400)
           (food-amount <= 800)
    (wood-amount <= 200)
    (gold-amount > 300)
=>
        (chat-to-all "食物2,木材1,黄金3")

        (set-strategic-number sn-food-gatherer-percentage  85)
        (set-strategic-number sn-wood-gatherer-percentage  15)
        (set-strategic-number sn-gold-gatherer-percentage  0)
    (disable-timer 30)
    (enable-timer 30 209)
)

;31:过了
;封建时代:(食物3,木材1,黄金3):
(defrule
    (timer-triggered 31)
    (goal 7 2)
        (food-amount > 800)
    (wood-amount <= 200)
    (gold-amount > 300)
=>
        (chat-to-all "食物3,木材1,黄金3")

        (set-strategic-number sn-food-gatherer-percentage  55)
        (set-strategic-number sn-wood-gatherer-percentage  25)
        (set-strategic-number sn-gold-gatherer-percentage  20)
    ;(set-strategic-number sn-stone-gatherer-percentage  20)
    (disable-timer 31)
    (enable-timer 31 209)
)

;=

;32
;封建时代:(食物1,木材2,黄金3):
(defrule
    (timer-triggered 32)
    (goal 7 2)
        (food-amount <= 400)
    (wood-amount > 200)
    (wood-amount <= 500)
    (gold-amount > 300)
=>
        (chat-to-all "食物1,木材2,黄金3")

        (set-strategic-number sn-food-gatherer-percentage  80)
        (set-strategic-number sn-wood-gatherer-percentage  20)
        (set-strategic-number sn-gold-gatherer-percentage  0)
    (disable-timer 32)
    (enable-timer 32 209)
)

;33
;封建时代:(食物2,木材2,黄金3):
(defrule
    (timer-triggered 33)
    (goal 7 2)
        (food-amount > 200)
        (food-amount <= 400)
    (wood-amount > 200)
    (wood-amount <= 500)
    (gold-amount > 300)
=>
        (chat-to-all "食物2,木材2,黄金3")

        (set-strategic-number sn-food-gatherer-percentage  65)
        (set-strategic-number sn-wood-gatherer-percentage  15)
        (set-strategic-number sn-gold-gatherer-percentage  10)
    (disable-timer 33)
    (enable-timer 33 209)
)

;34:过了
;封建时代:(食物3,木材2,黄金3):
(defrule
    (timer-triggered 34)
    (goal 7 2)
        (food-amount > 800)
    (wood-amount > 200)
    (wood-amount <= 500)
    (gold-amount > 300)
=>
        (chat-to-all "食物3,木材2,黄金3")

        (set-strategic-number sn-food-gatherer-percentage  55)
        (set-strategic-number sn-wood-gatherer-percentage  25)
        (set-strategic-number sn-gold-gatherer-percentage  20)
    ;(set-strategic-number sn-stone-gatherer-percentage  20)
    (disable-timer 34)
    (enable-timer 34 209)
)

;35
;封建时代:(食物1,木材3,黄金3):
(defrule
    (timer-triggered 35)
    (goal 7 2)
        (food-amount <= 400)
    (wood-amount > 500)
    (gold-amount > 300)
=>
        (chat-to-all "食物1,木材3,黄金3")

        (set-strategic-number sn-food-gatherer-percentage  55)
        (set-strategic-number sn-wood-gatherer-percentage  0)
        (set-strategic-number sn-gold-gatherer-percentage  45)
    (disable-timer 35)
    (enable-timer 35 209)
)

;36
;封建时代:(食物2,木材3,黄金3):
(defrule
    (timer-triggered 36)
    (goal 7 2)
        (food-amount > 400)
        (food-amount <= 800)
    (wood-amount > 500)
    (gold-amount > 300)
=>
        (chat-to-all "食物2,木材3,黄金3")

        (set-strategic-number sn-food-gatherer-percentage  55)
        (set-strategic-number sn-wood-gatherer-percentage  0)
        (set-strategic-number sn-gold-gatherer-percentage  45)
    (disable-timer 36)
    (enable-timer 36 209)
)

;37:过了
;封建时代:(食物3,木材3,黄金3):
(defrule
    (timer-triggered 37)
    (goal 7 2)
        (food-amount > 800)
    (wood-amount > 500)
    (gold-amount > 300)
=>
        (chat-to-all "食物3,木材3,黄金3")

        (set-strategic-number sn-food-gatherer-percentage  55)
        (set-strategic-number sn-wood-gatherer-percentage  30)
        (set-strategic-number sn-gold-gatherer-percentage  45)
    ;(set-strategic-number sn-stone-gatherer-percentage  20)

    ;(set-goal 37 1)
    (disable-timer 37)
    (enable-timer 37 209)
)




;=============================
;封建时代:(石头过多):卖掉
(defrule
    (current-age == feudal-age)
    (goal 7 2)
        (stone-amount >= 200)
        (commodity-selling-price stone greater-than 50)
        (can-sell-commodity stone)
=>
        (chat-to-all "卖石头赚黄金为了升城堡")
        (sell-commodity stone)
)





;城堡升帝王
; advance to imperial age if possible.
(defrule
        (goal 99 3)
        (can-research-with-escrow imperial-age)
=>
        (release-escrow wood)
        (release-escrow food)
        (release-escrow gold)
        (release-escrow stone)
        (research imperial-age)
        (chat-to-all "升级帝王时代")
        (set-goal 99 40)
)

;城堡时代劳动力动态调控=============================


;        (set-strategic-number sn-food-gatherer-percentage  30)
;        (set-strategic-number sn-wood-gatherer-percentage  15)
;        (set-strategic-number sn-gold-gatherer-percentage  15)
;        (set-strategic-number sn-stone-gatherer-percentage 40)


;城堡和帝王时代:(其他资源不缺少,且需要建造城堡)

(defrule
        (or
                (current-age == castle-age)
                (current-age == imperial-age)
        )
   
        (food-amount > 200)
    (wood-amount > 200)
    (gold-amount > 200)
    (building-type-count-total castle <= 2)
   
=>
        ;(chat-to-all "其他资源不缺少,且需要建造城堡")

        (set-strategic-number sn-food-gatherer-percentage  30)
        (set-strategic-number sn-wood-gatherer-percentage  15)
        (set-strategic-number sn-gold-gatherer-percentage  15)
        (set-strategic-number sn-stone-gatherer-percentage 40)
)

;城堡和帝王时代:(不满足需要建造城堡的条件)

(defrule
        (or
                (current-age == castle-age)
                (current-age == imperial-age)
    )
    (or
        (or
            (food-amount <= 200)
            (wood-amount <= 200)
        )
        (gold-amount <= 200)
    )
    (building-type-count-total castle > 2)
=>
        ;(chat-to-all "不满足需要建造城堡的条件")
    (set-goal 7 2)
)





;================================
;城堡时代:(石头过多):卖掉
(defrule
    (goal 99 3)
        (stone-amount greater-than 4000)
        (commodity-selling-price stone greater-than 50)
        (can-sell-commodity stone)
=>
        (chat-to-all "卖石头赚黄金为了升城堡")
        (sell-commodity stone)
)

;造农民







;黑暗时代造农民
(defrule
        (current-age == dark-age)
        (unit-type-count-total villager less-than 60)
        (can-train villager)
=>
        (train villager)
        (chat-to-all "dark-age villager 26")
)



;封建时代造农民
(defrule
        (current-age == feudal-age)
        (unit-type-count-total villager less-than 50)
        (can-train villager)
=>
        (train villager)
        (chat-to-all "feudal-age villager 60")
)

; Castle to Imperial

(defrule
        (unit-type-count-total villager > 25)
        (current-age == castle-age)
=>
        (set-goal 16 99)
        (disable-self)
)

;城堡时代造农民
(defrule
        (current-age == castle-age)
        (unit-type-count-total villager less-than 50)
        (can-train villager)
=>
        (train villager)
        (chat-to-all "feudal-age villager 100")
)


;帝王时代造农民
(defrule
        (current-age == imperial-age)
        (unit-type-count-total villager less-than 50)
        (can-train villager)
=>
        (train villager)
        (chat-to-all "imperial-age villager 110")
)





; ========================== 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.

; problem with escrow - give up

(defrule
        (or
                (or
                        (escrow-amount wood > 2000)
                        (escrow-amount food > 2000)
                )
                (or
                        (escrow-amount gold > 3000)
                        (escrow-amount stone > 3000)
                )
        )
=>
        (release-escrow wood)
        (release-escrow food)
        (release-escrow gold)
        (release-escrow stone)
        (set-goal 16 0)
)


; ////////////////////////////////////////////////////

; sets initial goal for escrow to make sure there are villagers

(defrule
        (true)
=>
        (set-goal 16 50)
        (disable-self)
)

(defrule
        (unit-type-count villager >= 15)
=>
        (set-goal 16 0)
        (disable-self)
)

; sets escrow

(defrule
        (true)
=>
        (set-escrow-percentage wood 40)
        (set-escrow-percentage food 40)
        (set-escrow-percentage gold 40)
        (set-escrow-percentage stone 40)
)
;状态设定

(defrule
    (unit-type-count-total villager > 10)
=>
    (set-goal 2 0)
)

; /////////////////////////////////////////////////////
;UNIT UPGRADES,单位升级

;城堡兵升级
(defrule
        (goal 2 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-to-all "research elite uniques")
)

;升级到剑士
(defrule
        (goal 2 0)
        (unit-type-count militiaman > 2)
        (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-to-all "research man-at-arms")
)

;升级到长剑士
(defrule
        (goal 2 0)
        (unit-type-count man-at-arms > 2)
        (can-research-with-escrow ri-long-swordsman)
=>
        (release-escrow wood)
        (release-escrow food)
        (release-escrow gold)
        (release-escrow stone)
      (research ri-long-swordsman)
        (chat-to-all "research long swordsman ")
)

;升级到双手剑士
(defrule
        (goal 2 0)
        (unit-type-count long-swordsman > 2)
        (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-to-all "research two-handed-swordsman")
)

;升级到冠军
(defrule
        (goal 2 0)
        (unit-type-count two-handed-swordsman > 2)
        (can-research-with-escrow ri-champion)
=>
        (release-escrow wood)
        (release-escrow food)
        (release-escrow gold)
        (release-escrow stone)
      (research ri-champion)
        (chat-to-all "research champion")
)

;升级到长枪兵
(defrule
        (goal 2 0)
        (unit-type-count-total spearman > 2)
        (can-research-with-escrow ri-pikeman)
=>
        (release-escrow wood)
        (release-escrow food)
        (release-escrow gold)
        (release-escrow stone)
      (research ri-pikeman)
        (chat-to-all "research pike")
)

;升级到轻骑兵
(defrule
        (goal 2 0)
        (unit-type-count-total scout-cavalry > 2)
        (can-research-with-escrow ri-light-cavalry)
=>
        (release-escrow wood)
        (release-escrow food)
        (release-escrow gold)
        (release-escrow stone)
        (research ri-light-cavalry)
        (chat-to-all "research light-cavalry")
)

;升级到重装骆驼兵
(defrule
        (goal 2 0)
        (unit-type-count-total camel > 2)
        (can-research-with-escrow ri-heavy-camel)
=>
        (release-escrow wood)
        (release-escrow food)
        (release-escrow gold)
        (release-escrow stone)
      (research ri-heavy-camel)
        (chat-to-all "research heavy camel")
)

;升级到重装骑士
(defrule
        (goal 2 0)
      (unit-type-count-total knight > 2)
        (can-research-with-escrow ri-cavalier)
=>
        (release-escrow wood)
        (release-escrow food)
        (release-escrow gold)
        (release-escrow stone)
      (research ri-cavalier)
        (chat-to-all "research cavalier")
)

;升级到游侠
(defrule
        (goal 2 0)
      (unit-type-count-total cavalier > 2)
        (can-research-with-escrow ri-paladin)
=>
        (release-escrow wood)
        (release-escrow food)
        (release-escrow gold)
        (release-escrow stone)
    (research ri-paladin)
        (chat-to-all "research paladin")
)

;升级到弩手
(defrule
        (goal 2 0)
        (unit-type-count archer > 1)
        (can-research-with-escrow ri-crossbow)
=>
        (release-escrow wood)
        (release-escrow food)
        (release-escrow gold)
        (release-escrow stone)
    (research ri-crossbow)
        (chat-to-all "research crossbow")
)

;升级到劲弩手
(defrule
        (goal 2 0)
        (unit-type-count crossbowman > 1)
        (can-research-with-escrow ri-arbalest)
=>
        (release-escrow wood)
        (release-escrow food)
        (release-escrow gold)
        (release-escrow stone)
    (research ri-arbalest)
        (chat-to-all "research arbalest")
)

;升级到重装骑射手
(defrule
        (goal 2 0)
        (unit-type-count cavalry-archer > 2)
        (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-to-all "research heavy-cavalry-archer")
)

;升级到精锐投矛战士
(defrule
        (unit-type-count-total skirmisher > 2)
        (can-research-with-escrow ri-elite-skirmisher)
=>
        (release-escrow wood)
        (release-escrow food)
        (release-escrow gold)
        (release-escrow stone)
    (research ri-elite-skirmisher)
        (chat-to-all "research elite skirmisher")
)

;研究火枪手
(defrule
        (unit-type-count-total knight-line > 2)
        (can-research-with-escrow ri-hand-cannon)
=>
        (release-escrow wood)
        (release-escrow food)
        (release-escrow gold)
        (release-escrow stone)
    (research ri-hand-cannon)
        (chat-to-all "research ri-hand-cannon")
)






;升级到重型弩车
(defrule
        (goal 2 0)
        (unit-type-count scorpion > 2)
        (can-research-with-escrow ri-heavy-scorpion)
=>
        (release-escrow wood)
        (release-escrow food)
        (release-escrow gold)
        (release-escrow stone)
    (research ri-heavy-scorpion)
        (chat-to-all "research heavy-scorpion")
)

;升级到中型攻城锤
(defrule
        (goal 2 0)
      (unit-type-count battering-ram > 1)
        (can-research-with-escrow ri-capped-ram)
=>
        (release-escrow wood)
        (release-escrow food)
        (release-escrow gold)
        (release-escrow stone)
    (research ri-capped-ram)
        (chat-to-all "research capped ram")
)

;升级到重型攻城锤
(defrule
        (goal 2 0)
      (unit-type-count capped-ram > 2)
        (can-research-with-escrow ri-siege-ram)
=>
        (release-escrow wood)
        (release-escrow food)
        (release-escrow gold)
        (release-escrow stone)
    (research ri-siege-ram)
        (chat-to-all "research siege-ram")
)

;升级到中型投石车
(defrule
        (goal 2 0)
        (unit-type-count mangonel > 2)
        (can-research-with-escrow ri-onager)
=>
        (release-escrow wood)
        (release-escrow food)
        (release-escrow gold)
        (release-escrow stone)
      (research ri-onager)
        (chat-to-all "research onager")
)

;升级到重型投石车
(defrule
        (goal 2 0)
      (unit-type-count onager > 2)
        (can-research-with-escrow ri-siege-onager)
=>
        (release-escrow wood)
        (release-escrow food)
        (release-escrow gold)
        (release-escrow stone)
    (research ri-siege-onager)
        (chat-to-all "research siege onager")
)

;各种船升级
;DOCK UNITS

;升级到战舰
(defrule
        (goal 2 0)
        (unit-type-count galley > 2)
        (can-research-with-escrow ri-war-galley)
=>
        (release-escrow wood)
        (release-escrow food)
        (release-escrow gold)
        (release-escrow stone)
    (research ri-war-galley)
        (chat-to-all "research war-galley")
)

;升级到大型战舰
(defrule
        (goal 2 0)
        (unit-type-count war-galley > 2)
        (can-research-with-escrow ri-galleon)
=>
        (release-escrow wood)
        (release-escrow food)
        (release-escrow gold)
        (release-escrow stone)
    (research ri-galleon)
        (chat-to-all "research galleon")
)

;研究炮舰
(defrule
        (goal 2 0)
        (or
                (unit-type-count galleon > 2)
                (unit-type-count war-galley > 2)
        )
        (can-research-with-escrow ri-cannon-galleon)
=>
        (release-escrow wood)
        (release-escrow food)
        (release-escrow gold)
        (release-escrow stone)
      (research ri-cannon-galleon)
        (chat-to-all "research cannon-galleon")
)

;升级到重型喷火舰
(defrule
        (goal 2 0)
        (unit-type-count-total fire-ship > 1)
        (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-to-all "research fast-fire-ship")
)

;升级到重型爆破船
(defrule
        (goal 2 0)
        (unit-type-count demolition-ship > 2)
        (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-to-all "research heavy-demolition-ship")
)

; ////////////////////////WEAPONS//////////////////

(defrule
        (goal 2 0)
        (can-research-with-escrow ri-forging)
=>
        (release-escrow wood)
        (release-escrow food)
        (release-escrow gold)
        (release-escrow stone)
     (research ri-forging)
        (chat-to-all "research forging")
)

(defrule
        (goal 2 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-to-all "research iron-casting")
)

(defrule
        (goal 2 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-to-all "research blast-furnace")
)

;ARCHER UPGRADES -- cost food/gold
(defrule
        (goal 2 0)
        (can-research-with-escrow ri-fletching)
=>
        (release-escrow wood)
        (release-escrow food)
        (release-escrow gold)
        (release-escrow stone)
        (research ri-fletching)
        (chat-to-all "research fletching")
)

(defrule
        (goal 2 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-to-all "research bodkin-arrow")
)

(defrule
        (goal 2 0)
        (can-research-with-escrow ri-bracer)
=>
        (release-escrow wood)
        (release-escrow food)
        (release-escrow gold)
        (release-escrow stone)
        (research ri-bracer)
        (chat-to-all "research bracer")
)

(defrule
        (goal 2 0)
        (or
                (unit-type-count-total archer-line > 3)
                (or
                        (unit-type-count-total skirmisher-line > 3)
                        (unit-type-count-total cavalry-archer-line > 3)
                )
        )
        (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-to-all "research padded-archer-armor")
)

(defrule
        (goal 2 0)
        (or
                (unit-type-count-total archer-line > 3)
                (or
                        (unit-type-count-total skirmisher-line > 3)
                        (unit-type-count-total cavalry-archer-line > 3)
                )
        )
        (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-to-all "research leather-archer-armor")
)

(defrule
        (goal 2 0)
        (or
                (unit-type-count-total archer-line > 3)
                (or
                        (unit-type-count-total skirmisher-line > 3)
                        (unit-type-count-total cavalry-archer-line > 3)
                )
        )
        (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-to-all "research ring-archer-armor")
)

(defrule
        (goal 2 0)
        (or
                (unit-type-count-total militiaman-line > 3)
                (unit-type-count-total spearman-line > 3)
        )
        (can-research-with-escrow ri-scale-mail)
=>
        (release-escrow wood)
        (release-escrow food)
        (release-escrow gold)
        (release-escrow stone)
        (research ri-scale-mail)
        (chat-to-all "research scale-mail")
)

(defrule
        (goal 2 0)
        (or
                (unit-type-count-total militiaman-line > 3)
                (unit-type-count-total spearman-line > 3)
        )
        (can-research-with-escrow ri-chain-mail)
=>
        (release-escrow wood)
        (release-escrow food)
        (release-escrow gold)
        (release-escrow stone)
        (research ri-chain-mail)
        (chat-to-all "research chain-mail")
)

(defrule
        (goal 2 0)
        (or
                (unit-type-count-total militiaman-line > 3)
                (unit-type-count-total spearman-line > 3)
        )
        (can-research-with-escrow ri-plate-mail)
=>
        (release-escrow wood)
        (release-escrow food)
        (release-escrow gold)
        (release-escrow stone)
        (research ri-plate-mail)
        (chat-to-all "research plate-mail")
)


(defrule
        (goal 2 0)
        (or
                (unit-type-count-total militiaman-line > 3)
                (unit-type-count-total spearman-line > 3)
        )
        (can-research-with-escrow ri-tracking)
=>
        (release-escrow wood)
        (release-escrow food)
        (release-escrow gold)
        (release-escrow stone)
        (research ri-tracking)
        (chat-to-all "research tracking")
)

(defrule
        (goal 2 0)
        (or
                (unit-type-count-total militiaman-line > 3)
                (unit-type-count-total spearman-line > 3)
        )
        (can-research-with-escrow ri-squires)
=>
        (release-escrow wood)
        (release-escrow food)
        (release-escrow gold)
        (release-escrow stone)
        (research ri-squires)
        (chat-to-all "research squires")
)

(defrule
        (goal 2 0)
        (or
                (unit-type-count-total knight-line > 3)
                (unit-type-count-total scout-cavalry-line > 3)
        )
        (can-research-with-escrow ri-scale-barding)
=>
        (release-escrow wood)
        (release-escrow food)
        (release-escrow gold)
        (release-escrow stone)
        (research ri-scale-barding)
        (chat-to-all "research scale-barding")
)

(defrule
        (goal 2 0)
        (or
                (unit-type-count-total knight-line > 3)
                (unit-type-count-total scout-cavalry-line > 3)
        )
        (can-research-with-escrow ri-chain-barding)
=>
        (release-escrow wood)
        (release-escrow food)
        (release-escrow gold)
        (release-escrow stone)
        (research ri-chain-barding)
        (chat-to-all "research chain-barding")
)

(defrule
        (goal 2 0)
        (or
                (unit-type-count-total knight-line > 3)
                (unit-type-count-total scout-cavalry-line > 3)
        )
        (can-research-with-escrow ri-plate-barding)
=>
        (release-escrow wood)
        (release-escrow food)
        (release-escrow gold)
        (release-escrow stone)
        (research ri-plate-barding)
        (chat-to-all "research plate-barding")
)

(defrule
        (goal 2 0)
        (or
                (unit-type-count-total cavalry-archer-line > 3)
                (or
                        (unit-type-count-total knight-line > 3)
                        (unit-type-count-total scout-cavalry-line > 3)
                )
        )
        (can-research-with-escrow ri-husbandry)
=>
        (release-escrow wood)
        (release-escrow food)
        (release-escrow gold)
        (release-escrow stone)
        (research ri-husbandry)
        (chat-to-all "research husbandry")
)

; /////////////////////SIEGE RESEARCH ITEMS///////////////////////////

(defrule
        (goal 2 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-to-all "research siege-engineers")
)

;FORTRESS UPGRADES
(defrule
        (goal 2 0)
        (can-research-with-escrow ri-hoardings)
=>
        (release-escrow wood)
        (release-escrow food)
        (release-escrow gold)
        (release-escrow stone)
        (research ri-hoardings)
        (chat-to-all "research hoardings")
)

;SHIPS
(defrule
        (goal 2 0)
        (unit-type-count cannon-galleon > 2)
        (can-research-with-escrow ri-deck-guns)
=>
        (release-escrow wood)
        (release-escrow food)
        (release-escrow gold)
        (release-escrow stone)
        (research ri-deck-guns)
        (chat-to-all "research deck guns ")
)

(defrule
        (goal 2 0)
        (or
                (unit-type-count transport-ship > 0)
                (unit-type-count galley-line > 2)
        )
        (can-research-with-escrow ri-careening)
=>
        (release-escrow wood)
        (release-escrow food)
        (release-escrow gold)
        (release-escrow stone)
        (research ri-careening)
        (chat-to-all "research careening ")
)

(defrule
        (goal 2 0)
        (or
                (unit-type-count transport-ship > 0)
                (unit-type-count galley-line > 2)
        )
        (can-research-with-escrow ri-dry-dock)
=>
        (release-escrow wood)
        (release-escrow food)
        (release-escrow gold)
        (release-escrow stone)
        (research ri-dry-dock)
        (chat-to-all "research dry-dock ")
)

(defrule
        (goal 2 0)
        (or
                (unit-type-count galley-line > 2)
                (or
                        (unit-type-count-total cannon-galleon-line > 1)
                        (unit-type-count-total fire-ship-line > 1)
                )
        )
        (can-research-with-escrow ri-shipwright)
=>
        (release-escrow wood)
        (release-escrow food)
        (release-escrow gold)
        (release-escrow stone)
        (research ri-shipwright)
        (chat-to-all "research shipwright ")
)

;OTHER RESEARCH ITEMS
(defrule
        (goal 2 0)
        (can-research-with-escrow ri-ballistics)
=>
        (release-escrow wood)
        (release-escrow food)
        (release-escrow gold)
        (release-escrow stone)
        (research ri-ballistics)
        (chat-to-all "research ballistics ")
)

(defrule
        (goal 2 0)
        (can-research-with-escrow ri-chemistry)
=>
        (release-escrow wood)
        (release-escrow food)
        (release-escrow gold)
        (release-escrow stone)
        (research ri-chemistry)
        (chat-to-all "research chemistry ")
)

(defrule
        (goal 2 0)
        (can-research-with-escrow ri-conscription)
=>
        (release-escrow wood)
        (release-escrow food)
        (release-escrow gold)
        (release-escrow stone)
        (research ri-conscription)
        (chat-to-all "research conscription")
)

(defrule
        (goal 2 0)
        (can-research-with-escrow my-unique-research)
=>
        (release-escrow wood)
        (release-escrow food)
        (release-escrow gold)
        (release-escrow stone)
        (research my-unique-research)
        (chat-to-all "research unique tech")
)


; //////////////////////ECONOMIC////////////////////////生产力升级

;mining-camp items
(defrule
        (goal 2 0)
   
        (can-research-with-escrow ri-gold-mining)
=>
        (release-escrow wood)
        (release-escrow food)
        (release-escrow gold)
        (release-escrow stone)
        (research ri-gold-mining)
        (chat-to-all "research gold mining")
)

(defrule
        (goal 2 0)
        (can-research-with-escrow ri-gold-shaft-mining)
=>
        (release-escrow wood)
        (release-escrow food)
        (release-escrow gold)
        (release-escrow stone)
        (research ri-gold-shaft-mining)
        (chat-to-all "research gold shaft mining")
)

(defrule
        (goal 2 0)
        (building-type-count mining-camp > 1)
    (current-age >= castle-age)
        (can-research-with-escrow ri-stone-mining)
=>
        (release-escrow wood)
        (release-escrow food)
        (release-escrow gold)
        (release-escrow stone)
        (research ri-stone-mining)
        (chat-to-all "research stone mining")
)

(defrule
        (goal 2 0)
        (building-type-count mining-camp > 1)
    (current-age >= castle-age)
        (can-research-with-escrow ri-stone-shaft-mining)
=>
        (release-escrow wood)
        (release-escrow food)
        (release-escrow gold)
        (release-escrow stone)
        (research ri-stone-shaft-mining)
        (chat-to-all "research stone shaft mining")
)

;mill items
(defrule
        (goal 2 0)
        (can-research-with-escrow ri-horse-collar)
=>
        (release-escrow wood)
        (release-escrow food)
        (release-escrow gold)
        (release-escrow stone)
        (research ri-horse-collar)
        (chat-to-all "research horse collar")
)

(defrule
        (goal 2 0)
        (can-research-with-escrow ri-heavy-plow)
=>
        (release-escrow wood)
        (release-escrow food)
        (release-escrow gold)
        (release-escrow stone)
        (research ri-heavy-plow)
        (chat-to-all "research heavy plow")
)

(defrule
        (goal 2 0)
        (can-research-with-escrow ri-crop-rotation)
=>
        (release-escrow wood)
        (release-escrow food)
        (release-escrow gold)
        (release-escrow stone)
        (research ri-crop-rotation)
        (chat-to-all "research crop rotation")
)

;saw mill
(defrule
        (goal 2 0)
        (can-research-with-escrow ri-double-bit-axe)
=>
        (release-escrow wood)
        (release-escrow food)
        (release-escrow gold)
        (release-escrow stone)
        (research ri-double-bit-axe)
        (chat-to-all "research double bit axe")
)

(defrule
        (goal 2 0)
        (can-research-with-escrow ri-bow-saw)
=>
        (release-escrow wood)
        (release-escrow food)
        (release-escrow gold)
        (release-escrow stone)
        (research ri-bow-saw)
        (chat-to-all "research bow saw")
)

(defrule
        (goal 2 0)
        (can-research-with-escrow ri-two-man-saw)
=>
        (release-escrow wood)
        (release-escrow food)
        (release-escrow gold)
        (release-escrow stone)
        (research ri-two-man-saw)
        (chat-to-all "research 2 man saw")
)

;university stuff
(defrule
        (goal 2 0)
        (can-research-with-escrow ri-masonry)
=>
        (release-escrow wood)
        (release-escrow food)
        (release-escrow gold)
        (release-escrow stone)
        (research ri-masonry)
        (chat-to-all "research masonry")
)

(defrule
        (goal 2 0)
        (can-research-with-escrow ri-architecture)
=>
        (release-escrow wood)
        (release-escrow food)
        (release-escrow gold)
        (release-escrow stone)
        (research ri-architecture)
        (chat-to-all "research architecture")
)

(defrule
        (goal 2 0)
        (can-research-with-escrow ri-stonecutting)
=>
        (release-escrow wood)
        (release-escrow food)
        (release-escrow gold)
        (release-escrow stone)
        (research ri-stonecutting)
        (chat-to-all "research stonecutting")
)

;market & town center
(defrule
        (goal 2 0)
        (can-research-with-escrow ri-guilds)
=>
        (release-escrow wood)
        (release-escrow food)
        (release-escrow gold)
        (release-escrow stone)
        (research ri-guilds)
        (chat-to-all "research guilds")
)






(defrule
    ;(timer-triggered 90)
        (goal 2 0)
    (housing-headroom == 0)
        ;(current-age == dark-age)
        (can-research-with-escrow ri-loom)
=>
        (release-escrow wood)
        (release-escrow food)
        (release-escrow gold)
        (release-escrow stone)
        (research ri-loom)
        (chat-to-all "research loom")
)

(defrule
        (goal 2 0)
        (can-research-with-escrow ri-hand-cart)
=>
        (release-escrow wood)
        (release-escrow food)
        (release-escrow gold)
        (release-escrow stone)
        (research ri-hand-cart)
        (chat-to-all "research hand-cart")
)

(defrule
        (goal 2 0)
        (can-research-with-escrow ri-wheel-barrow)
=>
        (release-escrow wood)
        (release-escrow food)
        (release-escrow gold)
        (release-escrow stone)
        (research ri-wheel-barrow)
        (chat-to-all "research wheelbarrow")
)

(defrule
        (goal 2 0)
        (or
                (players-stance any-computer ally)
                (players-stance any-human ally)
        )
        (can-research-with-escrow ri-coinage)
=>
        (release-escrow wood)
        (release-escrow food)
        (release-escrow gold)
        (release-escrow stone)
        (research ri-coinage)
        (chat-to-all "research coinage")
)

(defrule
        (goal 2 0)
        (or
                (players-stance any-computer ally)
                (players-stance any-human ally)
        )
        (can-research-with-escrow ri-banking)
=>
        (release-escrow wood)
        (release-escrow food)
        (release-escrow gold)
        (release-escrow stone)
        (research ri-banking)
        (chat-to-all "research banking")
)

; ////////////////////MONK/////////////////僧侣升级
(defrule
        (goal 2 0)
        (or
                ;(cc-players-unit-type-count any-enemy monk > 2)
        (players-unit-type-count any-enemy monk > 2)
                (unit-type-count-total war-elephant-line > 2)
        )
        (can-research-with-escrow ri-faith)
=>
        (release-escrow wood)
        (release-escrow food)
        (release-escrow gold)
        (release-escrow stone)
        (research ri-faith)
        (chat-to-all "research faith")
)

(defrule
        (goal 2 0)
        ;(cc-players-unit-type-count any-enemy monk > 2)
        (players-unit-type-count any-enemy monk > 2)
        (can-research-with-escrow ri-atonement)
=>
        (release-escrow wood)
        (release-escrow food)
        (release-escrow gold)
        (release-escrow stone)
        (research ri-atonement)
        (chat-to-all "research atonement")
)

(defrule
        (goal 2 0)
        (unit-type-count-total monk > 2)
        (can-research-with-escrow ri-block-printing)
=>
        (release-escrow wood)
        (release-escrow food)
        (release-escrow gold)
        (release-escrow stone)
        (research ri-block-printing)
        (chat-to-all "research block printing")
)

(defrule
        (goal 2 0)
        (unit-type-count-total monk > 2)
        (can-research-with-escrow ri-illumination)
=>
        (release-escrow wood)
        (release-escrow food)
        (release-escrow gold)
        (release-escrow stone)
        (research ri-illumination)
        (chat-to-all "research illumination")
)

(defrule
        (goal 2 0)
        (unit-type-count-total monk > 2)
        (can-research-with-escrow ri-fervor)
=>
        (release-escrow wood)
        (release-escrow food)
        (release-escrow gold)
        (release-escrow stone)
        (research ri-fervor)
        (chat-to-all "research fervor")
)

(defrule
        (goal 2 0)
        (unit-type-count-total monk > 2)
        (can-research-with-escrow ri-redemption)
=>
        (release-escrow wood)
        (release-escrow food)
        (release-escrow gold)
        (release-escrow stone)
        (research ri-redemption)
        (chat-to-all "research redemption")
)

(defrule
        (goal 2 0)
        (unit-type-count-total monk > 2)
        (can-research-with-escrow ri-sanctity)
=>
        (release-escrow wood)
        (release-escrow food)
        (release-escrow gold)
        (release-escrow stone)
        (research ri-sanctity)
        (chat-to-all "research sanctity")
)

;TOWERS

(defrule
        (goal 2 0)
        (building-type-count-total watch-tower > 1)
        (can-research-with-escrow ri-guard-tower)
=>
        (release-escrow wood)
        (release-escrow food)
        (release-escrow gold)
        (release-escrow stone)
    (research ri-guard-tower)
        (chat-to-all "research guard tower")
)

(defrule
        (goal 2 0)
        (building-type-count-total guard-tower > 1)
        (can-research-with-escrow ri-keep)
=>
        (release-escrow wood)
        (release-escrow food)
        (release-escrow gold)
        (release-escrow stone)
    (research ri-keep)
        (chat-to-all "research keep")
)

(defrule
        (goal 2 0)
        (building-type-count university > 0)
        (building-type-count-total watch-tower-line > 3)
        (research-available ri-bombard-tower)
=>
        (release-escrow wood)
        (release-escrow food)
        (release-escrow gold)
        (release-escrow stone)
     (research ri-bombard-tower)
        (chat-to-all "research bombard-tower")
)

(defrule
        (goal 2 0)
        (building-type-count-total watch-tower-line > 3)
        (can-research-with-escrow ri-heated-shot)
=>
        (release-escrow wood)
        (release-escrow food)
        (release-escrow gold)
        (release-escrow stone)
     (research ri-heated-shot)
        (chat-to-all "research heated-shot")
)

(defrule
        (goal 2 0)
        (or
                (building-type-count-total castle > 0)
                (building-type-count-total watch-tower-line > 2)
        )
        (can-research-with-escrow ri-murder-holes)
=>
        (release-escrow wood)
        (release-escrow food)
        (release-escrow gold)
        (release-escrow stone)
        (research ri-murder-holes)
        (chat-to-all "research murder-holes")
)

(defrule
        (goal 2 0)
(or
                (building-type-count-total castle > 0)
                (building-type-count-total watch-tower-line > 2)
        )
        (can-research-with-escrow ri-fortified-wall)
=>
        (release-escrow wood)
        (release-escrow food)
        (release-escrow gold)
        (release-escrow stone)
        (research ri-fortified-wall)
        (chat-to-all "research fortifications")
)









; ============== ATTACKING - The AI will attack once at 1100 seconds and then again every 1400 sec, provided it has enough defense soldiers.

(defrule
        (game-time > 0)
=>
        (chat-to-all "panda ai v2.0")
    ;(enable-timer 250 0)
        (disable-self)
)

;-----------------------------------------------------


;militiaman-line民兵类
(defrule
        (timer-triggered 0)
        (unit-type-count-total militiaman-line < 3)
        (can-train militiaman-line)
=>
        (train militiaman-line)
        (chat-to-all "train militiaman-line")
        (chat-to-all "train militiaman-line")
)








;封建时代



;出兵


;造城堡兵种类
(defrule
        (unit-type-count-total my-unique-unit-line < 100)
        (can-train my-unique-unit-line)
=>
        (train my-unique-unit-line)
        (chat-to-all "unique unit")
)

;城堡兵种类满足进攻
(defrule
    (goal 19 1)
        (unit-type-count my-unique-unit-line > 20)
=>
        (attack-now)(chat-to-player any-ally "23")
    (set-goal 19 0)
        (chat-to-all "my-unique-unit-line attacks!!!!!!!!!!!!!!!!!!!!!")
    (enable-timer 3 0)
)

;造攻城锤类
(defrule
        (not (town-under-attack))
        (unit-type-count-total battering-ram-line < 4)
        (defend-soldier-count >= 10)
        (can-train battering-ram-line)
=>
        (train battering-ram-line)
        (chat-to-all " I want to ram something")
)

;攻城锤类满足进攻
(defrule
    (goal 19 1)
        (unit-type-count battering-ram-line >= 2)
    (soldier-count >= 20)
=>
        (attack-now)(chat-to-player any-ally "23")
    (set-goal 19 0)
        (chat-to-all "battering-ram-line attacks!!!!!!!!!!!!!!!!!!!!!")
    (enable-timer 3 0)
)

;knight-line 骑士类
(defrule
        (food-amount greater-than 200)
        (gold-amount greater-than 100)
        ;(wood-amount greater-than 200)

        (unit-type-count-total knight-line < 15)
        (can-train knight-line)
=>
        (train knight-line)
        (chat-to-all "train knight-line")
)

;骑士类满足进攻
(defrule
    (goal 19 1)
        (unit-type-count knight-line > 4)
=>
        (attack-now)(chat-to-player any-ally "23")
    (set-goal 19 0)
        (chat-to-all "knight-line attacks!!!!!!!!!!!!!!!!!!!!!")
    (enable-timer 3 0)
)


;hand-cannoneer 火枪手
(defrule
        (food-amount greater-than 200)
        (gold-amount greater-than 200)
        ;(wood-amount greater-than 200)
        (unit-type-count-total hand-cannoneer < 8)
        (can-train hand-cannoneer)
=>
        (train hand-cannoneer)
        (chat-to-all "train hand-cannoneer")
)
;火枪手满足进攻
(defrule
    (goal 19 1)
        (unit-type-count hand-cannoneer > 4)
=>
        (attack-now)(chat-to-player any-ally "23")
    (set-goal 19 0)
        (chat-to-all "hand-cannoneer attacks!!!!!!!!!!!!!!!!!!!!!")
    (enable-timer 3 0)
)



;militiaman-line 民兵类
(defrule
        (food-amount greater-than 100)
        (gold-amount greater-than 100)
        ;(wood-amount greater-than 200)
        (unit-type-count-total militiaman-line < 20)
        (can-train militiaman-line)
=>
        (train militiaman-line)
        (chat-to-all "train militiaman-line")
)



;民兵类满足进攻
(defrule
    (goal 19 1)
        (unit-type-count militiaman-line > 8)
=>
        (attack-now)(chat-to-player any-ally "23")
    (set-goal 19 0)
        (chat-to-all "militiaman-line attacks!!!!!!!!!!!!!!!!!!!!!")
    (enable-timer 3 0)
)




;eagle-warrior-line 鹰武士类
(defrule
        (food-amount greater-than 200)
        (gold-amount greater-than 200)
        ;(wood-amount greater-than 200)
        (unit-type-count-total eagle-warrior-line < 5)
        (can-train eagle-warrior-line)
=>
        (train eagle-warrior-line)
        (chat-to-all "train eagle-warrior-line")
)

;鹰武士类满足进攻
(defrule
    (goal 19 1)
        (unit-type-count eagle-warrior-line > 4)
=>
    (attack-now)(chat-to-player any-ally "23")
        (disable-timer 8)
    (set-goal 19 0)
        (chat-to-all "eagle-warrior-line attacks!!!!!!!!!!!!!!!!!!!!!")
    (enable-timer 3 0)
)


;spearman-line 长枪兵类
(defrule
        (food-amount greater-than 200)
        (wood-amount greater-than 100)
        ;(gold-amount greater-than 200)

        (unit-type-count-total spearman-line < 20)
        (can-train spearman-line)
=>
        (train spearman-line)
        (chat-to-all "train spearman-line")
)

;长枪兵类满足进攻
(defrule
    (goal 19 1)
        (unit-type-count spearman-line > 18)
=>
    (attack-now)(chat-to-player any-ally "23")
        (disable-timer 8)
    (set-goal 19 0)
        (chat-to-all "spearman-line attacks!!!!!!!!!!!!!!!!!!!!!")
    (enable-timer 3 0)
)




;cavalry-archer-line 骑射手类
(defrule
        ;(food-amount greater-than 200)
        (wood-amount greater-than 300)
        (gold-amount greater-than 300)
        (unit-type-count-total cavalry-archer-line < 8)
        (can-train cavalry-archer-line)
=>
        (train cavalry-archer-line)
        (chat-to-all "train cavalry-archer-line")
)
;骑射手类满足进攻
(defrule
    (goal 19 1)
        (unit-type-count cavalry-archer-line > 4)
=>
        (attack-now)(chat-to-player any-ally "23")
    (set-goal 19 0)
        (chat-to-all "cavalry-archer-line attacks!!!!!!!!!!!!!!!!!!!!!")
    (enable-timer 3 0)
)



;archer-line 步弓手类
(defrule
        ;(food-amount greater-than 200)
        (wood-amount greater-than 200)
        (gold-amount greater-than 200)

        (unit-type-count-total archer-line < 12)
        (can-train archer-line)
=>
        (train archer-line)
        (chat-to-all "train archer-line")
)
;步弓手类满足进攻
(defrule
    (goal 19 1)
        (unit-type-count archer-line > 10)
=>
        (attack-now)(chat-to-player any-ally "23")
    (set-goal 19 0)
        (chat-to-all "archer-line attacks!!!!!!!!!!!!!!!!!!!!!")
    (enable-timer 3 0)
)



;skirmisher-line投矛兵类
(defrule
        (food-amount greater-than 100)
        (wood-amount greater-than 100)
        ;(gold-amount greater-than 500)

        (unit-type-count-total skirmisher-line < 30)
        (can-train skirmisher-line)
=>
        (train skirmisher-line)
        (chat-to-all "train skirmisher-line")
)
;投矛兵类满足进攻
(defrule
    (goal 19 1)
        (unit-type-count skirmisher-line > 20)
=>
        (attack-now)(chat-to-player any-ally "23")
    (set-goal 19 0)
        (chat-to-all "skirmisher-line attacks!!!!!!!!!!!!!!!!!!!!!")
    (enable-timer 3 0)
)










;scout-cavalry 轻骑兵
(defrule
        (food-amount greater-than 500)
        ;(gold-amount greater-than 200)
        ;(wood-amount greater-than 200)

        (unit-type-count-total scout-cavalry < 10)
        (can-train scout-cavalry)
=>
        (train scout-cavalry)
        (chat-to-all "train scout-cavalry")
)

;轻骑兵类满足进攻
(defrule
    (goal 19 1)
        (unit-type-count scout-cavalry > 9)
=>
        (attack-now)(chat-to-player any-ally "23")
    (set-goal 19 0)
        (chat-to-all "scout-cavalry attacks!!!!!!!!!!!!!!!!!!!!!")
    (enable-timer 3 0)
)
;总体满足进攻
(defrule
    (or
            (defend-soldier-count >= 30)
        (attack-soldier-count >= 35)
    )
    (goal 19 1)
=>
        (attack-now)(chat-to-player any-ally "23")
    (set-goal 19 0)
    (set-strategic-number sn-number-forward-builders 20)
        (chat-to-all "other attacks!!!!!!!!!!!!!!!!!!!!")
    (enable-timer 3 0)
)

;循环进攻
(defrule
    (true)
  =>
    (enable-timer 19 0)
    (disable-self)
)


(defrule
    (timer-triggered 19)
=>
    (set-goal 19 1);可以进攻的状态
    (disable-timer 19)
    (enable-timer 19 30)
)

; https://www.orayes.com
; 2012.9.29
回复

使用道具 举报

10

主题

1

精华

1534

积分

侯爵

耕战
139
鹰币
108
天龙币
0
回帖
150

翔鹰建站十周年纪念章

附庸关系0
发表于 2012-9-30 14:57:08 | 显示全部楼层
AI呢?
回复

使用道具 举报

0

主题

0

精华

77

积分

骑士

耕战
0
鹰币
68
天龙币
0
回帖
25
附庸关系0
发表于 2012-9-30 16:36:49 | 显示全部楼层
_CgaM_燕子 发表于 2012-9-30 14:57
AI呢?

他直接贴了出来
回复

使用道具 举报

12

主题

0

精华

648

积分

伯爵

耕战
56
鹰币
347
天龙币
0
回帖
96
附庸关系0
发表于 2012-10-1 10:38:23 | 显示全部楼层
求文件啊
回复

使用道具 举报

38

主题

0

精华

5066

积分

国王

耕战
933
鹰币
4
天龙币
0
回帖
249

三级嘉禾勋章

附庸关系0
 楼主| 发表于 2012-10-1 23:12:11 | 显示全部楼层
AI文件直接贴出来了,大家给点意见,目前只在阿拉伯、高地等地图好一顿测试,其他的图可能因为各种原因遇到BUG,大家可以告诉我。
回复

使用道具 举报

本版积分规则

排行榜|小黑屋|翔鹰帝国

GMT+8, 2024-4-29 14:31 , Processed in 0.132587 second(s), 66 queries , File On.

Powered by Hawk Studio  QS Security Corp.® Licensed

Copyright © 2001-2023, Hawkaoe.net All Rights Reserved

快速回复 返回顶部 返回列表