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

[交流] Promi AI修改交流

[复制链接]

31

主题

0

精华

2108

积分

侯爵

耕战
345
鹰币
2491
天龙币
0
回帖
86
附庸关系2
 楼主| 发表于 2021-1-18 14:39:09 | 显示全部楼层 |阅读模式
本帖最后由 pashanhu 于 2021-1-19 08:58 编辑

    笔者2020年制作了乌拉拉帝国之翔鹰时代MOD,为了让该MOD的7个新民族能支持AI运行,我萌发了修改AI的想法,看了常用的几个AI,发觉PROMI相对容易修改,便在看论坛教程下,自己琢磨修改,目前修改的Promi在单机游戏,不管是单人游戏还是多人游戏模式下都能较好的运行7个新民族(但联机多人游戏模式还有BUG,不能支持新民族)。现将自己琢磨修改AI的一些心得体会写出来与大家交流,不对之处,欢迎指正,期待AI高手能帮我解决联机多人游戏模式新民族没法正常运行的BUG。      
       一、新民族修改步骤
       1、增加新民族
       用AI编辑工具(我用的是管家自带的AI Script Builder)打开Promi文件夹下的const.per文件,复制修改一些语句,如下:
#load-if-defined CIV-TAGS-FOR-EDITOR
(defconst KEAIZHUANG-CIV 0)
(defconst DADIMAN-CIV 0)
(defconst TAOLUZONG-CIV 0)
(defconst WUDILIU-CIV 0)
(defconst XINFEIXIANG-CIV 0)
(defconst CAIHUAYAN-CIV 0)
(defconst DALAOTING-CIV 0)
#end-if
(defconst Keaizhuang 32)
(defconst Dadiman 33)
(defconst Taoluzong 34)
(defconst wudiliu 35)
(defconst xinfeixiang 36)
(defconst caihuayan 37)
(defconst dalaoting 38)
       以上代表新增了7个新民族,分别为可爱装、大帝慢、套路宗、无敌柳、新飞翔、纯洁眼、大佬婷。
      2、定义新民族的特色科技和特色兵种信息  ,如下:
(defconst xiaoyuchi 1400)
(defconst xiamashibaqi 1383)
(defconst ri-elite-yanyunshibaqi 795)
(defconst yanyunshibaqi 1381)
(defconst elite-yanyunshibaqi 1382)
(defconst ri-elite-baozitou 805)
(defconst baozitou 1391)
(defconst elite-baozitou 1392)
(defconst ri-elite-jixianfeng 819)
(defconst jixianfeng 1394)
(defconst elite-jixianfeng 1395)
(defconst ri-elite-yuqilin 814)
(defconst yuqilin 1397)
(defconst elite-yuqilin 1398)
(defconst ri-elite-xiaoliguang 809)
(defconst xiaoliguang 1401)
(defconst elite-xiaoliguang 1402)
(defconst ri-elite-meiyujian 823)
(defconst meiyujian 1403)
(defconst elite-meiyujian 1404)
(defconst ri-elite-tiejiabubing 826)
(defconst tiejiabubing 1412)
(defconst elite-tiejiabubing 1413)


(defconst ri-jieliu 806)
(defconst ri-sanlian 811)
(defconst ri-hufuqishe 816)
(defconst ri-shenyong 820)
(defconst ri-famuji 802)
(defconst ri-kuairufeng 792)
(defconst ri-haizhanjiaokeshu 824)

       以上第一段代码语句依次是大帝慢马厩特色兵种小尉迟,纯洁眼兵营特色兵种下马十八骑、城堡兵燕云十八骑,新飞翔城堡特色兵种豹子头,套路宗城堡特色兵种宗装骆驼,大帝慢城堡特色兵种玉麒麟,可爱装城堡特色兵种小李广,无敌柳城堡特色兵种没羽箭,大佬婷城堡特色兵种铁甲步兵。第二段代码是七个新民族银冠科技,分别为可爱装的节流,大帝慢的三连,套路宗的胡服骑射,无敌柳的神勇,新飞翔的伐木机,纯洁眼的快如风,大佬婷的海战教科书。这里为何不用增加金冠呢,这是因为金冠可以用“my-unique-research"统一表示,相应的城堡特色兵也可以用”unique-unit(如果训练城堡特色兵可以用”trainunique")表示。
3、完善新民族的一些参数数据,也是复制修改,如下
#load-if-defined KEAIZHUANG-CIV
(defconst text-civ "I'm playing as the Keaizhuang.")
(defconst unique-unit-wood 136)
(defconst unique-unit-food 0)
(defconst uu-w-dtc 311)
(defconst number-barracks 8)
(defconst number-stables 0)
(defconst number-archery-ranges 8)
(defconst dm-building barracks); for now
(defconst dm-unit militiaman-line);spearman
(defconst dm-building2 archery-range)
(defconst dm-unit2 archer)
(defconst dm-building3 castle)
(defconst dm-unit3 trainunique)
(defconst ig-food 34); 35
(defconst ig-wood 39)
(defconst ig-gold 21); 20
(defconst ig-stone 6)
(defconst uu-food 600)
(defconst uu-gold 0)
(defconst uu-food2 500)
(defconst uu-gold2 500); 100 (0)
(defconst uu-wood 1100)
(defconst uu-wood2 1000)
(defconst LN-TC-builders 2)
(defconst uu-type archer-uu)
(defconst sling-number 100); 99
(defconst drush-affinity 3)
(defconst r-flush-affinity 2)
(defconst sk-var-affinity 1)
(defconst maa-var-affinity 1)
(defconst krush-affinity 0)
(defconst s-flush-affinity 0)
(defconst castledrop-affinity 2)
(defconst stonewall-affinity 2)
(defconst a-rush-affinity 2)
(defconst ca-rush-affinity 0)
(defconst klew-affinity 2)
(defconst grush-affinity 2)
#end-if

      上面代码语句是把原AI中玛雅民族的数据复制过来修改的,修改后变成新民族可爱装的参数,少数语句我也没弄明白到底什么意思。Promi AI中对后帝王死斗开局模式设置个人认为不太合理,只有dm-building和dm-unit,所以自作主张的增加了dm-building2和dm-unit2,dm-building3和dm-unit3,以便增加AI的兵种搭配。其他新民族的数据类似增加,就是找到与新民族接近的老民族的语句,复制过来进行修改。
      4、新增语句告诉AI新民族特色科技研发时机,这里以无敌柳的银冠科技“神勇”和金冠科技“意识流”以及大帝慢的银冠科技“三连”和金冠科技“五重帝国”为例,用AI Script Builder打开Promi文件夹下的research.per文件,新增语句,如下:
#load-if-defined WUDILIU-CIV
(defrule
        (unit-type-count-total infantry-class >= 4)
        (can-research ri-shenyong)
=>
        (research ri-shenyong))
(defrule
        (goal uugoal yes)
        (can-research my-unique-research)
=>
        (research my-unique-research))
#end-if

      上面代码语句意思当步兵数量4个(含)以上,能研究银冠神勇科技就研究;当打算训练城堡特色兵种时,能研究金冠科技就研究。注:无敌柳的银冠科技效果是步兵+1攻,+1甲,+1盾;金冠科技效果是城堡特色兵种没羽箭(步兵)射程+1,获得弹道学效果。
#load-if-defined DADIMAN-CIV
(defrule
        (goal uugoal yes)
        (can-research ri-sanlian)
=>
        (research ri-sanlian))
(defrule
(or     (players-unit-type-count focus-player spearman-line >= 10)
        (gold-amount >= 1000))
        (can-research my-unique-research)
=>
        (research my-unique-research))
#end-if

      上面代码语句是当打算训练城堡特色兵种时,能研究三连科技就研究;当焦点(敌对)玩家枪兵数量10个(含)以上时,或黄金数量1000(含)以上时,能研究金冠科技就研究。注:大帝慢的银冠科技效果是城堡特色兵种玉麒麟攻速快33%,金冠科技效果是马厩特色兵种小尉迟+2攻,+1盾,训练免黄金。大帝慢民族特性设置中所有垃圾兵(枪兵、掷矛手、肉马)均只有一级,没法玩垃圾兵,而小尉迟的特性是不受反骑附加,且对枪兵+5攻击,但需要70食物,20黄金的造价,基础攻击只有7,盾为0,所以反制大量的枪兵得靠小尉迟,后期没金时也得是小尉迟为主力,因此在对面枪兵数量多或者黄金耗尽前得研发金冠五重帝国。
      5、新增语句告诉AI对特殊民族,比如大帝慢,如何兵种搭配,用AI Script Builder打开Promi文件夹下的units.per文件,新增语句,如下:
=========================================================
; Dadiman   Xiaoyuchi  Yuqilin
;=========================================================
(defrule
        (civ-selected Dadiman)
        (current-age >= imperial-age)
        (gold-amount <= 200)
        (food-amount >= 70)
=>
        (train xiaoyuchi)
        (set-goal trainpike no)
        (set-goal trainskirm no))

(defrule
        (civ-selected Dadiman)
        (current-age >= imperial-age)
        (players-unit-type-count any-enemy spearman-line > 20)
=>
        (build stable)
        (train xiaoyuchi)
        (set-goal trainpike no)
        (set-goal trainskirm no))

(defrule
        (civ-selected Dadiman)
        (current-age >= imperial-age)
        (players-unit-type-count any-enemy imperial-camel > 15)
        (building-type-count-total archery-range == 0)
=>
        (build archery-range)
        (train archer)
        (train xiaoyuchi))

(defrule
        (civ-selected Dadiman)
        (current-age >= imperial-age)
        (players-unit-type-count any-enemy war-elephant-line > 15)
        (building-type-count-total castle == 0)
=>
        (build castle)
        (train yuqilin)
        (set-goal trainpike no)
        (set-goal trainskirm no))

      以上代码语句,虚线框内容是注释,正式内容第一段的意思是当随到大帝慢民族,战局僵持到帝王后期无金时,以小尉迟为主力兵种,不要训练枪兵和掷矛手;第二段内容是当随到大帝慢民族,敌人枪兵数量多时,建马厩出小尉迟,不要训练枪兵和掷矛手;第三段内容是当随到大帝慢民族,帝王时代敌人帝王骆驼数量多且没建靶场时,建靶场训练弓箭部队,马厩训练小尉迟;第四段内容是到随到大帝慢民族,帝王时代敌人象兵数量多且没建城堡时,建城堡训练特色兵种玉麒麟,不要训练枪兵和掷矛手。注:大帝慢城堡特色兵种有1格攻击射程,对象兵有附加攻击,枪兵只有一级,反制数量较多的象兵得靠城堡特色兵种玉麒麟。
      
       二、修正标准开局AI不研发鹰勇士,不研发精锐象兵的问题
      上述问题,早有玩家讨论过,解决方案也给出了,在此不再赘述,只说我的研发机制(单机试验可行)。
      1、研究鹰勇士问题
用AI Script Builder打开Promi文件夹下的research.per文件,新增语句,如下:
(defrule
        (up-research-status c: imperial-age >= research-pending)
        (can-research ri-heavy-eagle-warrior)
=>
        (research ri-heavy-eagle-warrior))

(defrule
(or     (civ-selected Keaizhuang)
(or     (civ-selected aztec)
(or     (civ-selected incan)
        (civ-selected mayan))))
        (current-age >= imperial-age)
        (gold-amount >= 800)
        (food-amount >= 1000)
=>
        (research ri-elite-eagle-warrior))
      上面代码语句,第一段的意思是当点下帝王时代,能研究鹰勇士就研究;第二段的意思是随到可爱装、阿兹特克、印加、玛雅时,帝王时代当黄金超过800(含),食物超过(1000)时,研究精锐鹰勇士。注:这两段语句不太严谨,实战中可以改成当需要爆鸟时研究鹰勇士,精锐鹰勇士。个人设想是用”(goal traineagle yes)表示研发时机或许可行,但还没验证,有兴趣的可以尝试下。
     2、研究精锐象兵问题
用AI Script Builder打开Promi文件夹下的research.per文件,新增语句,如下:
(defrule
(or     (civ-selected burmese)
(or     (civ-selected khmer)
(or     (civ-selected malay)
        (civ-selected vietnamese))))
        (current-age >= imperial-age)
        (gold-amount >= 1200)
        (food-amount >= 2000)
        (goal underattack no)

=>
        (research ri-elite-battle-elephant))

     上面代码语句是,当随到缅甸、高棉、马来、越南时,帝王时代食物超出2000(含),黄金超出1200(含)时,研究精锐象兵。









回复

使用道具 举报

33

主题

0

精华

1万

积分

圣徒

耕战
2127
鹰币
15194
天龙币
0
回帖
542

十字军勋章翔鹰建站十周年纪念章

附庸关系0
发表于 2021-1-18 15:56:39 | 显示全部楼层
沙发 私以为排版需要优化一下

点评

cxt
翔哥几百年没冒过泡了  发表于 2021-1-18 21:20
怎么没人回帖呢?
回复

使用道具 举报

31

主题

0

精华

2108

积分

侯爵

耕战
345
鹰币
2491
天龙币
0
回帖
86
附庸关系2
 楼主| 发表于 2021-1-23 20:56:05 | 显示全部楼层


3打AI大战,promi用新民族战胜野蛮人,难度为难

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册翔鹰会员(昵称)

x
回复

使用道具 举报

0

主题

0

精华

10

积分

骑士

耕战
0
鹰币
110
天龙币
0
回帖
3
附庸关系0
发表于 2021-1-24 11:30:42 本帖来自手机 | 显示全部楼层
优秀!
回复

使用道具 举报

21

主题

0

精华

673

积分

伯爵

耕战
29
鹰币
591
天龙币
0
回帖
238
附庸关系0
发表于 2021-8-12 11:12:42 | 显示全部楼层
直接定义个dm-building2游戏里就能生效吗?我用决定版的AI(也是Promi)这样改了不能生效,是不是还有哪里需要定义?
回复

使用道具 举报

本版积分规则

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

GMT+8, 2024-4-29 18:21 , Processed in 0.210343 second(s), 76 queries , File On.

Powered by Hawk Studio  QS Security Corp.® Licensed

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

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