概念问题
有点晕呼……大概的意思就是判断是否需要战船
需要 (goal boat must-need-boat)
不需要(goal boat no-need-boat)
如果需要战船则考虑有多少码头,2个码头以上则必须有10艘以上战船,如果没有2个码头则不考虑战船数量
不会写了
[此贴子已经被作者于2004-12-18 0:54:23编辑过]
写了个大概比较繁琐,大家看看还能不能简化 (or
(and
(goal boat must-need-boat)
(or
(and (building-type-count dock >= 2) (warboat-count > 10) )
(building-type-count dock < 2)
)
)
(goal boat no-need-boat)
)
意思是说如果有两码头但还没10艘船就训练战船吗?那是这样:(defrule
(building-type-count-total dock >= 2)
(unit-type-count-total galley < 10) (can-train galley)
=>
(train galley)
)
SonicX 兄的意思真不好解,呵呵。是不是这样:
(defrule
(building-type-count-total dock >2)
(unit-type-count-total galley < 10)
(can-train galley)
=>
(train galley)
)
(defrule
(building-type-count-total dock <2)
(can-train galley)
=>
(train galley)
)
[此贴子已经被作者于2004-12-19 17:20:43编辑过]
我没说清楚,应该是个优先级问题
首先判断是否需要海战,这个已经可以了
需要海战 (goal boat must-need-boat)
不需要(goal boat no-need-boat)
然后在生产单位时先判断码头数量,如果码头大于2个而且战船少于10艘则停止生产其他部队,优先建造船支,如果码头小于2则可以生产其他部队
下面是我写的代码(部分)
(defconst boat 10)
(defconst boat-num 11)
(defconst must-need-boat 1)
(defconst no-need-boat 2)
(defconst have-more-boat 3)
(defconst have-little-boat 4)
……
……
;判断部分
(defrule
(goal boat must-need-boat)
(not (goal boat-num have-more-boat))
(or
(and (building-type-count dock >= 2) (warboat-count >= 10) )
(building-type-count dock < 2)
)
=>
(set-goal boat-num have-more-boat);已有战船或无码头建造战船
)
(defrule
(goal boat must-need-boat)
(goal boat-num have-more-boat)
(and (building-type-count dock >= 2) (warboat-count < 10) )
=>
(set-goal boat-num have-little-boat);没有战船
……
……
;生产骑兵
(defrule
(or (goal boat-num have-more-boat) (goal boat no-need-boat) )
(unit-type-count-total knight-line < 20)
(can-train knight-line)
=>
(train knight-line)
)
主要是想把这些合在一行,目前是条件太多报错,呵呵
[此贴子已经被作者于2004-12-19 22:28:33编辑过]
哦, 明白了, 那不如分两步:(defrule
(unit-type-count-total galley >= 10)=>
(set-goal boat-num have-more-boat))(defrule
(building-type-count-total dock < 2)
=>
(set-goal boat no-need-boat))(defrule
(building-type-count-total dock >= 2)
=>
(set-goal boat must-need-boat))(defrule
(goal boat must-need-boat)
(goal boat-num have-more-boat)
(building-type-count dock >= 2) (warboat-count < 10) =>
(set-goal boat-num have-little-boat)
页:
[1]