Reputation: 1
I don't see the bug in the syntax of the program, the error I get is this:
Reglas.CLP, Line 6: Syntax Error: Check appropriate syntax for defrule. ERROR: (defrule MAIN::DormitorioIluminación_Encender ?d <- (Dormitorio (Presencia Si) (Iluminación Apagada)) ?o <- (Otras (
Python code:
import clips
DEFTEMPLATE_STRING = """
(deftemplate Dormitorio
(slot Presencia (type SYMBOL))
(slot Iluminación (type SYMBOL)))
"""
"""
(deftemplate Otras
(slot Hora (type INTEGER))
(slot Estación (type SYMBOL)))
"""
env = clips.Environment()
env.build(DEFTEMPLATE_STRING)
env.load('Reglas.CLP')
Dormitorio = env.find_template('Dormitorio')
fact_Dormitorio = Dormitorio.assert_fact(Presencia = clips.Symbol('Si'),
Iluminación = clips.Symbol('Apagada'))
Otras = env.find_template('Otras')
fact_Otras = Otras.assert_fact(Hora = '2000',
Estación = clips.Symbol('Verano'))
env.run()
CLIPS code:
(defrule Regla1
?d <- (Dormitorio
(Presencia Si)
(Iluminación Apagada))
?o <- (Otras
(Hora ?Hora))
(test (and (>= ?Hora 1800) (< ?Hora 2300)))
=>
(printout t "Encender la iluminación del dormitorio." crlf)
(modify ?d (Iluminación Encendida))
)
What is the error?
Upvotes: 0
Views: 85
Reputation: 10757
You can't place multiple constructs in your call in the string you pass to the build method. The deftemplate Dormitorio is getting defined but not Otras.
Upvotes: 0