【发布时间】:2012-03-16 11:48:20
【问题描述】:
我试图构建一个模板来存储我计算的一些结果,所以我做了这个用于初始化:
(deftemplate tempAlumne
(slot nota-media-total)
(slot nota-media-obligatorias)
(slot nota-media-optativas)
(slot nota-media-ales)
)
(deffacts tempAlumneFacts
(tempAlumne
(nota-media-total -1)
(nota-media-obligatorias -1)
(nota-media-optativas -1)
(nota-media-ales -1)
)
)
然后我尝试使用该结构来存储值,但我需要它可以从许多规则中访问,因此我决定将其设为全局。所以我尝试存储这样的值:
(defrule calcula-nota-media ""
(not calcula-nota-media ok)
?*tmpA* <- (tempAlumne )
=>
(bind ?llista_convocs (send ?*alumne* get-IConvocatoria))
(bind ?suma 0)
(bind ?i 0)
(while(< ?i (length$ ?llista_convocs)) do
(bind ?convoc_actual (nth$ ?i ?llista_convocs))
(bind ?suma (+ ?suma (send ?convoc_actual get-Nota)))
(bind ?i (+ ?i 1))
)
(/ )
(modify (?*tmpA* (nota-media-total (/ ?suma ?i))
(assert calcula-nota-media ok)
)
因为我希望 ?*tmpA* 具有初始值,然后为每个值分配 modify(这里我分配 nota-media-total),但它显示“[PRNTUTIL2] 语法错误:检查 defrule 的适当语法。” ,所以我不知道哪里出了问题,或者我是否走错了路。
【问题讨论】:
标签: artificial-intelligence clips