在 Lisa 中,当我希望规则只触发一次时,通用列表的 AI 包

问题描述 投票:0回答:0

我正在将 SBCL 与 LISA 包一起使用。当我运行具有多个规则的程序时,就会开始无限循环,因为我的规则多次触发。我该如何控制这种错误行为?

这是基于一个事实的简单规则。我认为对“意大利”事实的修改会再次触发该规则,依此类推。有出路吗?

enter code here

(包装内mbg)

    (setf Italy (make-instance 'COUNTRY 'name 'Italy 'population 60 
          'area 'west 'language 'Italian 'gdp 2100 'debt 2700 
          'industry '( metal mechanical textile petrochem fashion 
           tourism)
          'continent 'Europe)) (pushnew 'Italy countries)

      (assert-instance mbg::Italy)

      (in-package lisa-user)

    (defrule testab (:salience 0)
    (?country (mbg::country 
    (mbg::name ?name)
    (mbg::debt ?debt)
    (mbg::gdp  ?gdp ))
    (test (and (> ?gdp 2000.) (> ?debt 1000.))))
    =>
    (modify ?country  (mbg::inflation  15))
    (print ?name))
loops lisp common-lisp
© www.soinside.com 2019 - 2024. All rights reserved.