0

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?

mkrieger1
24.2k7 gold badges68 silver badges84 bronze badges
asked Dec 29, 2022 at 22:23

1 Answer 1

0

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.

answered Dec 30, 2022 at 7:14
Sign up to request clarification or add additional context in comments.

3 Comments

now when I define Otras with the build I don't get this error, but now it says: in assert_fact raise PUT_SLOT_ERROR[ret](slot) TypeError: invalid type for slot 'Hora'
I'm not familiar with Python syntax, but my guess would be that you need to use 2000 in place of '2000'.
Yes, that was the error, thank you

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.