-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerador_menus.clp
92 lines (77 loc) · 2.28 KB
/
generador_menus.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
;;;======================================================
;;; Automotive Expert System
;;;
;;; This expert system diagnoses some simple
;;; problems with a car.
;;;
;;; CLIPS Version 6.4 Example
;;;
;;; To execute, merely load, reset and run.
;;;======================================================
;;****************
;;* DEFCLASSES *
;;****************
;;;+++++++++++++++++
;;;
;;; MÓDULO DE PREGUNTAS
;;;
;;;+++++++++++++++++
;;;(defmodule preguntas)
(deffunction ask-question (?question $?allowed-values)
(print ?question)
(bind ?answer (read))
(if (lexemep ?answer)
then (bind ?answer (lowcase ?answer)))
(while (not (member$ ?answer ?allowed-values)) do
(print ?question)
(bind ?answer (read))
(if (lexemep ?answer)
then (bind ?answer (lowcase ?answer))))
?answer)
(deffunction yes-or-no-p (?question)
(bind ?response (ask-question ?question yes no y n))
(if (or (eq ?response yes) (eq ?response y))
then yes
else no))
(defrule saber-come-carne ""
(not (come-carne ?))
(not (output ?))
=>
(assert (come-carne (yes-or-no-p "Comes carne (yes/no)? "))))
(defrule saber-gusta-ternera ""
(come-carne yes)
(not (gusta-ternera ?))
(not (output ?))
=>
(assert (gusta-ternera (yes-or-no-p "Te gusta el bistec (yes/no)? "))))
(defrule saber-gusta-pollo ""
(come-carne yes)
(not (gusta-pollo ?))
(not (output ?))
=>
(assert (gusta-pollo (yes-or-no-p "Te gusta el pollo (yes/no)? "))))
(defrule poner-ternera ""
(come-carne yes)
(gusta-ternera yes)
(not (output ?))
=>
(assert (output "Come ternera todos los putos días.")))
(defrule poner-pollo ""
(come-carne yes)
(gusta-pollo yes)
(not (output ?))
=>
(assert (output "Come pollo todos los putos días.")))
;;;********************************
;;;* STARTUP AND CONCLUSION RULES *
;;;********************************
(defrule system-banner ""
(declare (salience 10))
=>
(println crlf "The Menu Creator" crlf))
(defrule print-menu ""
(declare (salience 10))
(output ?item)
=>
(println crlf "Suggested Menu:" crlf)
(println " " ?item crlf))