啃瓜子的韬哥 发表于 2014-4-5 13:12:02

AI制作方法:关于外交关系

这一些代码很适合制作AI,追求向电脑一样的(将外交关系更改为敌人,电脑会发出语言指令)
大家玩过《萨巴托重返》吗,这些AI就是这样的!


(defconst goal1 2)
(defconst goal2 3)
(defrule
(true)
=>
(set-goal goal1 0)
(disable-self)
)
(defrule
(goal goal1 0)
(or
(players-stance any-human-ally neutral)
(players-stance any-human-ally enemy)
)
=>
(chat-to-player this-any-human-ally "这是错误的选择,你不友好吗?马上和我同盟,领主")
(chat-to-player this-any-human-ally "你有20秒钟的时间可以选择,你是跟我同盟还是与我为敌?")
(enable-timer 9 20)
(set-goal goal1 1)
)
(defrule
(timer-triggered 9)
(or
(players-stance any-human-ally neutral)
(players-stance any-human-ally enemy)
)
=>
(chat-to-player this-any-human-ally "你怎么可以与我为敌!领主")
(chat-to-player this-any-human-ally "既然你做出了选择,你会为此付出代价的")
(set-stance this-any-human-ally enemy)
(enable-timer 8 10)
(set-goal goal2 1)
(disable-self)
)
(defrule
(goal goal1 1)
(players-stance any-human-ally ally)
=>
(chat-to-player this-any-human-ally "领主,感谢您,这将是一个明智的选择")
(chat-to-player this-any-human-ally "我会继续帮您对抗任何敌人的!")
(disable-timer 9)
(set-goal goal1 0)
)
(defrule
(goal goal2 1)
(players-stance any-human-enemy ally)
=>
(chat-to-player this-any-human-enemy "我不再会相信你的了")
(disable-self)
)

M.I.K.U. 发表于 2014-4-5 15:18:43

很简单的技巧,相信大多数会AI的人都懂……{:146:}

chunhim_lai 发表于 2014-4-5 21:16:24

很简单的技巧,相信大多数会AI的人都懂……
页: [1]
查看完整版本: AI制作方法:关于外交关系