forked from polmane/Practica2IA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pregunta.clp
32 lines (29 loc) · 914 Bytes
/
pregunta.clp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
(deffunction pregunta (?pregunta $?valors-permesos) ;Si No
(progn$
(?var $?valors-permesos) ;; Si No s n
(lowcase ?var)
(printout t ?var)) ; Si No s n
;(printout t ( ?valors-permesos) )
(printout t )
(format t "%s? (%s) " ?pregunta (implode$ ?valors-permesos))
(bind ?resposta (read))
(while (not (member (lowcase ?resposta) ?valors-permesos)) do
(format t "%s? (%s) " ?pregunta (implode$ ?valors-permesos))
(bind ?resposta (read))
)
(printout t crlf)
?resposta
)
(deffunction pregunta-si-no (?pregunta)
(bind ?resposta (pregunta ?pregunta Si No s n))
(if (or (eq (lowcase ?resposta) si) (eq (lowcase ?resposta) s))
then TRUE
else FALSE
)
)
(defrule pregunta-correr "Voldries correr"
(not (pregunta-correr-feta))
=>
(bind ?e (pregunta-si-no "Voldries correr"))
(assert (pregunta-correr-feta))
)