2个rule,为什么第二和第三个rule不执行?(结贴)
本帖最后由 tankant 于 2013-9-28 10:58 编辑(defconst gl-come-bugongshou 0)
(defrule
(true)
=>
(set-goal gl-come-bugongshou 1)
(chat-to-all "gl-come-bugongshou 1")
(disable-self)
)
(defrule
(goal gl-come-bugongshou 1)
=>
(chat-to-all "gl-come-bugongshou 1")
)
(defrule
(goal gl-come-bugongshou 0)
=>
(chat-to-all "gl-come-bugongshou 0")
)
求懂AI的高手指点迷津
追问2
本帖最后由 tankant 于 2013-9-28 00:10 编辑很好,YTY一眼看出来goal可能不能是0
追问:现在前三个rule已经正常运作了。第4、5个rule为什么不好用?可能原因是什么?
(defconst gl-come-bugongshou 2)
;1
(defrule
(true)
=>
(set-goal gl-come-bugongshou 1)
(chat-to-all "gl-come-bugongshou 1")
(disable-self)
)
;2
(defrule
(goal gl-come-bugongshou 1)
=>
(chat-to-all "gl-come-bugongshou 1")
)
;3
(defrule
(goal gl-come-bugongshou 2)
=>
(chat-to-all "gl-come-bugongshou 2")
)
;4
(defrule
(or(players-unit-type-count any-enemy archer-line > 3)
(or(players-unit-type-count any-enemy longbowman-line > 3)
(or(players-unit-type-count any-enemy plumed-archer-line > 3)
(or(players-unit-type-count any-enemy lunbadenushou-line > 3)
(players-unit-type-count any-enemy hualangsheshou-line > 3)))))
=>
(set-goal gl-come-bugongshou 1)
)
;5
(defrule
(players-unit-type-count any-enemy archer-line <= 3)
(players-unit-type-count any-enemy longbowman-line <= 3)
(players-unit-type-count any-enemy plumed-archer-line <= 3)
(players-unit-type-count any-enemy lunbadenushou-line <= 3)
(players-unit-type-count any-enemy hualangsheshou-line <= 3)
=>
(set-goal gl-come-bugongshou 2)
)
追问3
本帖最后由 tankant 于 2013-9-28 10:24 编辑自己尝试重点修改第五个rule换成如下形式:
(defconst gl-come-bugongshou 2)
;1
(defrule
(true)
=>
(set-goal gl-come-bugongshou 1)
(chat-to-all "gl-come-bugongshou 1")
(disable-self)
)
;4
(defrule
(or(players-unit-type-count any-enemy archer-line > 3)
(or(players-unit-type-count any-enemy longbowman-line > 3)
(or(players-unit-type-count any-enemy plumed-archer-line > 3)
(or(players-unit-type-count any-enemy lunbadenushou-line > 3)
(players-unit-type-count any-enemy hualangsheshou-line > 3)))))
=>
(set-goal gl-come-bugongshou 1)
(chat-to-all "1111111111111111111111111111")
)
;5
(defrule
(not
(or(players-unit-type-count any-enemy archer-line > 3)
(or(players-unit-type-count any-enemy longbowman-line > 3)
(or(players-unit-type-count any-enemy plumed-archer-line > 3)
(or(players-unit-type-count any-enemy lunbadenushou-line > 3)
(players-unit-type-count any-enemy hualangsheshou-line > 3)))))
)
=>
(set-goal gl-come-bugongshou 2)
(chat-to-all "22222222222222222222222")
)
;2
(defrule
(goal gl-come-bugongshou 1)
=>
(chat-to-all "gl-come-bugongshou 1")
)
;3
(defrule
(goal gl-come-bugongshou 2)
=>
(chat-to-all "gl-come-bugongshou 2")
)
测试结果:视野中任何一家敌人的步弓手+视野中任何一家敌人的步弓手尸体>3个的时候,"1111111111111111111111111111"出现;
不满足该条件的时候"22222222222222222222222"出现;
可是永远不显示"gl-come-bugongshou 1",永远是"gl-come-bugongshou 2"。
请问这个原因又是为什么?
因为你每次启动时都有(defconst gl-come-bugongshou 2)这句强行赋值为2了?
最终版本
本帖最后由 tankant 于 2013-9-28 11:53 编辑最后调试好用了,具体原因不明。最终变成以下版本:
(defconst gl-come-bugongshou 2)
;1
(defrule
(true)
=>
(set-goal gl-come-bugongshou 1)
(chat-to-all "gl-come-bugongshou 1")
(disable-self)
)
;5
(defrule
(not
(or(players-unit-type-count any-enemy archer-line > 3)
(or(players-unit-type-count any-enemy longbowman-line > 3)
(or(players-unit-type-count any-enemy plumed-archer-line > 3)
(or(players-unit-type-count any-enemy lunbadenushou-line > 3)
(players-unit-type-count any-enemy hualangsheshou-line > 3)))))
)
=>
(set-goal gl-come-bugongshou 2)
(chat-to-all "22222222222222222222222")
)
;4
(defrule
(or(players-unit-type-count any-enemy archer-line > 3)
(or(players-unit-type-count any-enemy longbowman-line > 3)
(or(players-unit-type-count any-enemy plumed-archer-line > 3)
(or(players-unit-type-count any-enemy lunbadenushou-line > 3)
(players-unit-type-count any-enemy hualangsheshou-line > 3)))))
=>
(set-goal gl-come-bugongshou 1)
(chat-to-all "1111111111111111111111111111")
)
;2
(defrule
(goal gl-come-bugongshou 1)
=>
(chat-to-all "gl-come-bugongshou 1")
)
;3
(defrule
(goal gl-come-bugongshou 2)
=>
(chat-to-all "gl-come-bugongshou 2")
)
页:
[1]