期悦 发表于 2020-5-5 11:05:06

我的写的AI是不是格式不对?

(defrule
    (true)
=>
    (chat-to-all "AI ready")
    (disable-self)
)

;村民不动

(defrule
    (true)
=>
    (set-strategic-number sn-maximum-food-drop-distance 0)
    (set-strategic-number sn-maximum-wood-drop-distance 0)
    (set-strategic-number sn-maximum-gold-drop-distance 0)
    (set-strategic-number sn-maximum-stone-drop-distance 0)
    (disable-self)
)

(defrule
    (true)
=>
    (set-strategic-number sn-percent-civilian-gatherers 0)
    (set-strategic-number sn-percent-civilian-builders 0)
    (set-strategic-number sn-percent-civilian-explorers 0)
    (disable-self)
)

;士兵不动

(defrule
    (true)
=>
    (set-strategic-number sn-task-ungrouped-soldiers 0)
    (disable-self)
)

;输入数字

(defrule
(taunt-detected 1 202)
=>
(acknowledge-taunt 1 202)
(cc-add-resource wood 10)
)

(defrule
(taunt-detected 1 203)
=>
(acknowledge-taunt 1 203)
(cc-add-resource food 10)
)

(defrule
(taunt-detected 1 204)
=>
(acknowledge-taunt 1 204)
(cc-add-resource gold 10)
)

(defrule
(taunt-detected 1 205)
=>
(acknowledge-taunt 1 205)
(cc-add-resource stone 10)
)

(defrule
(taunt-detected 1 206)
=>
(acknowledge-taunt 1 206)
(cc-add-resource stone 20)
)
决定版,自定义AI,每次保存,打开游戏都会提示这个。文件在附件里。


;AI

(defrule
    (true)
=>
    (chat-to-all "AI ready")
    (disable-self)
)

;士兵不动

(defrule
    (true)
=>
    (set-strategic-number sn-task-ungrouped-soldiers 0)
    (disable-self)
)

;村民不动

(defrule
    (true)
=>
    (set-strategic-number sn-maximum-food-drop-distance 0)
    (set-strategic-number sn-maximum-wood-drop-distance 0)
    (set-strategic-number sn-maximum-gold-drop-distance 0)
    (set-strategic-number sn-maximum-stone-drop-distance 0)
    (disable-self)
)

(defrule
    (true)
=>
    (set-strategic-number sn-percent-civilian-gatherers 0)
    (set-strategic-number sn-percent-civilian-builders 0)
    (set-strategic-number sn-percent-civilian-explorers 0)
    (disable-self)
)

;驻扎单位

(defrule
    (true)
=>
    (up-gather-inside c: barracks c: 1)
    (up-gather-inside c: archery-range c: 1)
    (up-gather-inside c: stable c: 1)
    (disable-self)
)

;开始训练部队

(defrule
(up-research-status c: 375 >= research-pending)
=>
(enable-timer 1 2)
(enable-timer 5 2)
(enable-timer 8 2)
(disable-self)
)

;兵营训练部队

(defrule
(timer-triggered 1)
=>
(disable-timer 1)
(enable-timer 2 2)
(train militiaman-line)
)

(defrule
(timer-triggered 2)
=>
(disable-timer 2)
(enable-timer 12 2)
(train spearman-line)
)

(defrule
(timer-triggered 3)
=>
(disable-timer 3)
(enable-timer 4 2)
(train 892)
)

(defrule
(timer-triggered 4)
=>
(disable-timer 4)
(enable-timer 1 2)
(train 1109)
)

;靶场训练部队

(defrule
(timer-triggered 5)
=>
(disable-timer 5)
(enable-timer 6 2)
(train archer-line)
)

(defrule
(timer-triggered 6)
=>
(disable-timer 6)
(enable-timer 7 2)
(train skirmisher-line)
)

(defrule
(timer-triggered 7)
=>
(disable-timer 7)
(enable-timer 5 2)
(train 73)
)

;马厩训练部队

(defrule
(timer-triggered 8)
=>
(disable-timer 8)
(enable-timer 9 2)
(train 1266)
)

(defrule
(timer-triggered 9)
=>
(disable-timer 9)
(enable-timer 8 2)
(train 827)
)

;攻城器械厂训练部队

(defrule
    (unit-type-count-total battering-ram-line < 4)
    (can-train battering-ram-line)
=>
    (train battering-ram-line)
)

;爆出兵建筑

(defrule
    (up-research-status c: 374 >= research-pending)
    (building-type-count barracks less-than 10)
    (can-build barracks)
=>
    (build-forward barracks)
)

(defrule
    (up-research-status c: 374 >= research-pending)
    (building-type-count archery-range less-than 3)
    (can-build archery-range)
=>
    (build-forward archery-range)
)

(defrule
    (up-research-status c: 374 >= research-pending)
    (building-type-count stable less-than 3)
    (can-build stable)
=>
    (build-forward stable)
)

(defrule
    (up-research-status c: 374 >= research-pending)
    (building-type-count siege-workshop less-than 2)
    (can-build siege-workshop)
=>
    (build-forward siege-workshop)
)

(defrule
    (up-research-status c: 374 >= research-pending)
=>
    (up-gather-inside c: barracks c: 0)
    (up-gather-inside c: archery-range c: 0)
    (up-gather-inside c: stable c: 0)
    (disable-self)
)

;进攻

(defrule
    (up-research-status c: 380 >= research-pending)
=>
    (attack-now)
    (enable-timer 50 20)
    (disable-self)
)

(defrule
    (timer-triggered 50)
=>
    (attack-now)
    (disable-timer 50)
    (enable-timer 50 20)
)

;自增资源

(defrule
    (food-amount <= 5000)
    (event-detected trigger 220)
=>
    (cc-add-resource food 5000)
)

(defrule
    (gold-amount <= 5000)
    (event-detected trigger 220)
=>
    (cc-add-resource gold 5000)
)

(defrule
    (wood-amount <= 5000)
    (event-detected trigger 220)
=>
    (cc-add-resource wood 5000)
)

;维持村民

(defrule
    (up-research-status c: 374 >= research-pending)
    (building-type-count town-center less-than 1)
    (can-build town-center)
=>
    (build town-center)
)

(defrule
    (up-research-status c: 374 >= research-pending)
    (unit-type-count-total villager < 10)
    (can-train villager)
=>
    (train villager)
)

;放哨

(defrule
    (up-research-status c: 373 >= research-pending)
=>
    (set-strategic-number sn-task-ungrouped-soldiers 1)
    (set-strategic-number sn-enemy-sighted-response-distance 5)
    (set-strategic-number sn-percent-enemy-sighted-response 100)
    (set-difficulty-parameter ability-to-dodge-missiles 100)
    (set-difficulty-parameter ability-to-maintain-distance 100)
    (disable-self)
)


(defrule
    (true)
=>
    (chat-to-all "AI ready")
    (disable-self)
)

;村民不动

(defrule
    (true)
=>
    (set-strategic-number sn-maximum-food-drop-distance 0)
    (set-strategic-number sn-maximum-wood-drop-distance 0)
    (set-strategic-number sn-maximum-gold-drop-distance 0)
    (set-strategic-number sn-maximum-stone-drop-distance 0)
    (disable-self)
)

(defrule
    (true)
=>
    (set-strategic-number sn-percent-civilian-gatherers 0)
    (set-strategic-number sn-percent-civilian-builders 0)
    (set-strategic-number sn-percent-civilian-explorers 0)
    (disable-self)
)

;士兵不动

(defrule
    (true)
=>
    (set-strategic-number sn-task-ungrouped-soldiers 0)
    (disable-self)
)

;输入数字

(defrule
(taunt-detected 1 202)
=>
(acknowledge-taunt 1 202)
(cc-add-resource wood 10)
)

(defrule
(taunt-detected 1 203)
=>
(acknowledge-taunt 1 203)
(cc-add-resource food 10)
)

(defrule
(taunt-detected 1 204)
=>
(acknowledge-taunt 1 204)
(cc-add-resource gold 10)
)

(defrule
(taunt-detected 1 205)
=>
(acknowledge-taunt 1 205)
(cc-add-resource stone 10)
)

(defrule
(taunt-detected 1 206)
=>
(acknowledge-taunt 1 206)
(cc-add-resource stone 20)
)

blazefires 发表于 2020-5-5 15:59:11

research-pending 是属於Userpatch的内容,你可能要去预读一下Userpatch.per档案

newtonerdai 发表于 2020-5-5 17:37:05

同楼上,应该在AI开头先写一句:
(load "UserPatchConst")
然后在AI的文件群里加一个UserPatchConst.per的UP常数预定义档。
这样才能正常使用research-pending这些自定义常数名。
UserPatchConst文件可以去订阅Jacky_Lin的Beginner那个AI,在AI文件目录里能找到。
页: [1]
查看完整版本: 我的写的AI是不是格式不对?