Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; Wed Dec 07 16:28:52 CET 2016
- ;
- ;+ (version "3.4.8")
- ;+ (build "Build 629")
- (defclass %3ACLIPS_TOP_LEVEL_SLOT_CLASS "Fake class to save top-level slot information"
- (is-a USER)
- (role abstract)
- (single-slot corrent
- (type STRING)
- ;+ (cardinality 0 1)
- (create-accessor read-write))
- (single-slot epocaP
- (type STRING)
- ;+ (cardinality 0 1)
- (create-accessor read-write))
- (single-slot any
- (type INTEGER)
- ;+ (cardinality 0 1)
- (create-accessor read-write))
- (multislot preferencies
- (type STRING)
- (create-accessor read-write))
- (single-slot tipus
- (type STRING)
- ;+ (value "Individual" "Familia" "Grup petit" "Grup gran")
- ;+ (cardinality 0 1)
- (create-accessor read-write))
- (single-slot destacat
- (type SYMBOL)
- (allowed-values FALSE TRUE)
- ;+ (cardinality 0 1)
- (create-accessor read-write))
- (single-slot importancia
- (type STRING)
- ;+ (value "Baixa" "Mitjana" "Alta")
- ;+ (cardinality 0 1)
- (create-accessor read-write))
- (single-slot autor
- (type STRING)
- ;+ (cardinality 0 1)
- (create-accessor read-write))
- (single-slot dimensions
- (type STRING)
- ;+ (cardinality 0 1)
- (create-accessor read-write))
- (single-slot nacionalitat
- (type STRING)
- ;+ (cardinality 0 1)
- (create-accessor read-write))
- (single-slot complexitat
- (type INTEGER)
- (range 1 10)
- ;+ (cardinality 0 1)
- (create-accessor read-write))
- (single-slot sala
- (type STRING)
- ;+ (cardinality 0 1)
- (create-accessor read-write))
- (single-slot nombre+de+dies
- (type INTEGER)
- ;+ (cardinality 0 1)
- (create-accessor read-write))
- (single-slot tematica
- (type STRING)
- ;+ (cardinality 0 1)
- (create-accessor read-write))
- (single-slot correntA
- (type STRING)
- ;+ (cardinality 0 1)
- (create-accessor read-write))
- (single-slot epoca
- (type STRING)
- ;+ (cardinality 0 1)
- (create-accessor read-write))
- (single-slot titol
- (type STRING)
- ;+ (cardinality 0 1)
- (create-accessor read-write))
- (single-slot nom
- (type STRING)
- ;+ (cardinality 0 1)
- (create-accessor read-write))
- (single-slot coneixements
- (type INTEGER)
- (range 1 10)
- ;+ (cardinality 0 1)
- (create-accessor read-write))
- (single-slot duracio
- ;+ (comment "Nombre d'hores diaries dels visitants")
- (type INTEGER)
- ;+ (cardinality 0 1)
- (create-accessor read-write)))
- (defclass Obra
- (is-a USER)
- (role concrete)
- (single-slot autor
- (type STRING)
- ;+ (cardinality 0 1)
- (create-accessor read-write))
- (single-slot titol
- (type STRING)
- ;+ (cardinality 0 1)
- (create-accessor read-write))
- (single-slot dimensions
- (type STRING)
- ;+ (cardinality 0 1)
- (create-accessor read-write))
- (single-slot any
- (type INTEGER)
- ;+ (cardinality 0 1)
- (create-accessor read-write))
- (single-slot sala
- (type STRING)
- ;+ (cardinality 0 1)
- (create-accessor read-write))
- (single-slot destacat
- (type SYMBOL)
- (allowed-values FALSE TRUE)
- ;+ (cardinality 0 1)
- (create-accessor read-write))
- (single-slot tematica
- (type STRING)
- ;+ (cardinality 0 1)
- (create-accessor read-write))
- (single-slot correntA
- (type STRING)
- ;+ (cardinality 0 1)
- (create-accessor read-write))
- (single-slot complexitat
- (type INTEGER)
- (range 1 10)
- ;+ (cardinality 0 1)
- (create-accessor read-write)))
- (defclass Pintor
- (is-a USER)
- (role concrete)
- (single-slot nacionalitat
- (type STRING)
- ;+ (cardinality 0 1)
- (create-accessor read-write))
- (single-slot corrent
- (type STRING)
- ;+ (cardinality 0 1)
- (create-accessor read-write))
- (single-slot nom
- (type STRING)
- ;+ (cardinality 0 1)
- (create-accessor read-write))
- (single-slot epoca
- (type STRING)
- ;+ (cardinality 0 1)
- (create-accessor read-write)))
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- (definstances instancies
- ; Wed Dec 07 16:28:52 CET 2016
- ;
- ;+ (version "3.4.8")
- ;+ (build "Build 629")
- ([ontologia_Class0] of Pintor
- (corrent "impressionisme")
- (epoca "XIX")
- (nacionalitat "Francesa")
- (nom "manet"))
- ([ontologia_Class1] of Obra
- (any 1888)
- (autor "gogh")
- (complexitat 1)
- (correntA "postimpressionisme")
- (dimensions "72 x 90")
- (sala "2")
- (tematica "habitacio")
- (titol "L'habitacio"))
- ([ontologia_Class10] of Obra
- (any 1813)
- (autor "hayez")
- (complexitat 2)
- (correntA "romanticisme")
- (destacat TRUE)
- (dimensions "94.1 x 73.5")
- (sala "4")
- (tematica "mort")
- (titol "La mort d'Abradatas"))
- ([ontologia_Class10002] of Pintor
- (corrent "romanticisme")
- (epoca "XIX")
- (nacionalitat "Espanyola")
- (nom "goya"))
- ([ontologia_Class10003] of Pintor
- (corrent "postimpressionisme")
- (epoca "XIX")
- (nacionalitat "Holandes")
- (nom "gogh"))
- ([ontologia_Class10004] of Pintor
- (corrent "expressionisme")
- (epoca "XIX")
- (nacionalitat "Noruec")
- (nom "munch"))
- ([ontologia_Class10005] of Pintor
- (corrent "neoclacissisme")
- (epoca "XIX")
- (nacionalitat "Americana")
- (nom "copley"))
- ([ontologia_Class10006] of Pintor
- (corrent "romanticisme")
- (epoca "XIX")
- (nacionalitat "Russa")
- (nom "brullov"))
- ([ontologia_Class10007] of Pintor
- (corrent "postimpressionisme")
- (epoca "XIX")
- (nacionalitat "Italiana")
- (nom "hayez"))
- ([ontologia_Class10008] of Pintor
- (corrent "expressionisme")
- (epoca "XIX")
- (nacionalitat "Italiana")
- (nom "modigliani"))
- ([ontologia_Class10009] of Pintor
- (corrent "expressionisme")
- (epoca "XIX")
- (nacionalitat "Brasileña")
- (nom "segall"))
- ([ontologia_Class10010] of Pintor
- (corrent "expressionisme")
- (epoca "XIX")
- (nacionalitat "Canadenc")
- (nom "carr"))
- ([ontologia_Class10011] of Obra
- (any 1911)
- (autor "carr")
- (complexitat 2)
- (correntA "expressionisme")
- (destacat TRUE)
- (dimensions "80.2 x 59.8")
- (sala "1")
- (tematica "paisatge")
- (titol "Tardor a França"))
- ([ontologia_Class10012] of Obra
- (any 1906)
- (autor "carr")
- (complexitat 2)
- (correntA "expressionisme")
- (dimensions "42.5 x 32.2")
- (sala "1")
- (tematica "paisatge")
- (titol "Esglesia Francesa"))
- ([ontologia_Class10014] of Obra
- (any 1928)
- (autor "carr")
- (complexitat 2)
- (correntA "expressionisme")
- (dimensions "81 x 100")
- (sala "1")
- (tematica "paisatge")
- (titol "Kitwancool"))
- ([ontologia_Class10015] of Obra
- (any 1933)
- (autor "carr")
- (complexitat 1)
- (correntA "expressionisme")
- (destacat TRUE)
- (dimensions "40.9 x 35.3")
- (sala "1")
- (tematica "paisatge")
- (titol "Vista marina"))
- ([ontologia_Class10016] of Obra
- (any 1930)
- (autor "carr")
- (complexitat 3)
- (correntA "expressionisme")
- (destacat TRUE)
- (dimensions "153.6 x 216.7")
- (sala "5")
- (tematica "paisatge")
- (titol "Blunden Harbour"))
- ([ontologia_Class10017] of Obra
- (any 1879)
- (autor "manet")
- (complexitat 3)
- (correntA "impressionisme")
- (destacat TRUE)
- (dimensions "115 x 150")
- (sala "1")
- (tematica "retrat")
- (titol "Al conservatori"))
- ([ontologia_Class10018] of Obra
- (any 1863)
- (autor "manet")
- (complexitat 3)
- (correntA "impressionisme")
- (dimensions "208 × 264")
- (sala "3")
- (tematica "retrat")
- (titol "El dinar campestre"))
- ([ontologia_Class10019] of Obra
- (any 1863)
- (autor "manet")
- (complexitat 3)
- (correntA "impressionisme")
- (destacat TRUE)
- (dimensions "130 x 190")
- (sala "3")
- (tematica "retrat")
- (titol "Olympia"))
- ([ontologia_Class10020] of Obra
- (any 1798)
- (autor "goya")
- (complexitat 1)
- (correntA "romanticisme")
- (dimensions "30 x 43")
- (sala "4")
- (tematica "mitologia")
- (titol "Aquelarre"))
- ([ontologia_Class10021] of Obra
- (any 1765)
- (autor "goya")
- (complexitat 2)
- (correntA "romanticisme")
- (dimensions "50.4 x 72.5")
- (sala "4")
- (tematica "mitologia")
- (titol "La Triple generacion"))
- ([ontologia_Class10022] of Obra
- (any 1770)
- (autor "goya")
- (complexitat 2)
- (correntA "romanticisme")
- (dimensions "87 x 131.5")
- (sala "4")
- (tematica "mitologia")
- (titol "Anibal vencedor"))
- ([ontologia_Class10023] of Obra
- (any 1771)
- (autor "goya")
- (complexitat 1)
- (correntA "romanticisme")
- (destacat TRUE)
- (dimensions "33 x 24")
- (sala "4")
- (tematica "mitologia")
- (titol "Sacrificio a Pan"))
- ([ontologia_Class10024] of Obra
- (any 1872)
- (autor "gogh")
- (complexitat 1)
- (correntA "postimpressionisme")
- (dimensions "24.5 x 18.5")
- (sala "2")
- (tematica "natura")
- (titol "Sequia"))
- ([ontologia_Class10025] of Obra
- (any 1885)
- (autor "gogh")
- (complexitat 2)
- (correntA "postimpressionisme")
- (dimensions "82 x 114")
- (sala "1")
- (tematica "retrat")
- (titol "Menjant patates"))
- ([ontologia_Class10026] of Obra
- (any 1889)
- (autor "gogh")
- (complexitat 2)
- (correntA "postimpressionisme")
- (destacat TRUE)
- (dimensions "74 x 92.1")
- (sala "2")
- (tematica "natura")
- (titol "Camp tancat amb pages"))
- ([ontologia_Class10027] of Obra
- (any 1887)
- (autor "gogh")
- (complexitat 2)
- (correntA "postimpressionisme")
- (dimensions "55.5 x 46.5")
- (sala "1")
- (tematica "retrat")
- (titol "Dona al Cafè de Tambourin"))
- ([ontologia_Class10028] of Obra
- (any 1915)
- (autor "modigliani")
- (complexitat 2)
- (correntA "expressionisme")
- (dimensions "75 x 105")
- (sala "1")
- (tematica "retrat")
- (titol "Paul Guillaume, Novo Pilota"))
- ([ontologia_Class10029] of Obra
- (any 1917)
- (autor "modigliani")
- (complexitat 2)
- (correntA "expressionisme")
- (dimensions "60 x 92")
- (sala "5")
- (tematica "retrat")
- (titol "Nu reclinat"))
- ([ontologia_Class10030] of Obra
- (any 1916)
- (autor "modigliani")
- (complexitat 2)
- (correntA "expressionisme")
- (dimensions "55 x 46")
- (sala "5")
- (tematica "retrat")
- (titol "La jueva"))
- ([ontologia_Class11] of Obra
- (any 1916)
- (autor "modigliani")
- (complexitat 2)
- (correntA "expressionisme")
- (dimensions "81 x 54")
- (sala "5")
- (tematica "retrat")
- (titol "Retrat de Jaques i Berthe Lipchitz"))
- ([ontologia_Class12] of Obra
- (any 1910)
- (autor "munch")
- (complexitat 1)
- (correntA "expressionisme")
- (dimensions "66 x 83")
- (sala "1")
- (tematica "paisatge")
- (titol "El crit"))
- ([ontologia_Class13] of Obra
- (any 1927)
- (autor "segall")
- (complexitat 2)
- (correntA "expressionisme")
- (dimensions "46 x 69")
- (sala "5")
- (tematica "retrat")
- (titol "Retrat de Guilherme de Almeida"))
- ([ontologia_Class14] of Obra
- (any 1939)
- (autor "carr")
- (complexitat 3)
- (correntA "expressionisme")
- (dimensions "300 x 185.4")
- (sala "5")
- (tematica "paisatge")
- (titol "Odds and Ends"))
- ([ontologia_Class15] of Obra
- (any 1782)
- (autor "copley")
- (complexitat 3)
- (correntA "neoclacissisme")
- (destacat TRUE)
- (dimensions "103 x 137.5")
- (sala "5")
- (tematica "retrat")
- (titol "Henry Laurens"))
- ([ontologia_Class3] of Obra
- (any 1890)
- (autor "gogh")
- (complexitat 2)
- (correntA "postimpressionisme")
- (dimensions "49.5 x 99.7")
- (sala "2")
- (tematica "natura")
- (titol "Parella caminant entre arbres"))
- ([ontologia_Class4] of Obra
- (any 1887)
- (autor "gogh")
- (complexitat 2)
- (correntA "postimpressionisme")
- (dimensions "65 x 51")
- (sala "1")
- (tematica "retrat")
- (titol "Retrat de Père Tanguy"))
- ([ontologia_Class5] of Obra
- (any 1882)
- (autor "manet")
- (complexitat 2)
- (correntA "impressionisme")
- (dimensions "96 x 130")
- (sala "1")
- (tematica "retrat")
- (titol "El bar del Folies Bergère"))
- ([ontologia_Class6] of Obra
- (any 1873)
- (autor "manet")
- (complexitat 2)
- (correntA "impressionisme")
- (dimensions "94.6 x 83.3")
- (sala "3")
- (tematica "retrat")
- (titol "El Bon Bock"))
- ([ontologia_Class7] of Obra
- (any 1779)
- (autor "goya")
- (complexitat 3)
- (correntA "romanticisme")
- (destacat TRUE)
- (dimensions "259 x 220")
- (sala "5")
- (tematica "paisatge")
- (titol "El cacharrero"))
- ([ontologia_Class8] of Obra
- (any 1833)
- (autor "brullov")
- (complexitat 3)
- (correntA "romanticisme")
- (dimensions "465.5 x 651")
- (sala "4")
- (tematica "mort")
- (titol "L'ultim dia de Pompeii"))
- )
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- (defmodule MAIN (export ?ALL))
- ;;;------------------------------------------------------------------------------------------------------------------------------------------------------
- ;;;---------- DEFINICION DE TEMPLATES ---------- DEFINICION DE TEMPLATES
- ;;;-------------------------------------------------------------------------------------------------------------------------------------------------------
- (deftemplate MAIN::Visitant
- (slot coneixements (type INTEGER)(default 0))
- (slot hores (type INTEGER) (default 0))
- (slot dies (type INTEGER) (default 0))
- (slot corrent_p (type SYMBOL) (default cap))
- (slot corrent_d (type SYMBOL) (default cap))
- (slot pintor_p (type SYMBOL) (default cap))
- (slot pintor_d (type SYMBOL) (default cap))
- (slot tipus_v (type INTEGER) (default 0))
- (slot primera_v (type SYMBOL) (default desconeguda))
- )
- ; Emmagatzemem la puntuació de cada una de les obres
- (deftemplate puntuacions
- (slot obra (type STRING))
- (slot puntuacio (type INTEGER) (default 5)))
- ;(deftemplate puntuacions_ordenades
- (slot titol (type STRING))
- (slot puntuacio (type INTEGER)))
- ;;;------------------------------------------------------------------------------------------------------------------------------------------------------
- ;;;---------- FUNCIONES ---------- EXTRAS
- ;;;-------------------------------------------------------------------------------------------------------------------------------------------------------
- (defmodule MAIN (export ?ALL))
- (defmodule test_nivell
- (import MAIN ?ALL)
- (export ?ALL)
- )
- (defmodule hacer_preguntas
- (import MAIN ?ALL)
- (import test_nivell deftemplate ?ALL)
- (export ?ALL)
- )
- (defmodule hacer_calculos
- (import MAIN ?ALL)
- (import test_nivell deftemplate ?ALL)
- (import hacer_preguntas deftemplate ?ALL)
- (export ?ALL)
- )
- ;;;; Funcion para hacer una pregunta general
- (deffunction MAIN::pregunta-general (?pregunta)
- (format t "%s" ?pregunta)
- (bind ?respuesta (read))
- ?respuesta
- )
- ;;; Funcion para hacer una pregunta general con una serie de respuestas admitidas
- (deffunction MAIN::pregunta-opciones (?question $?allowed-values)
- (format t "%s "?question)
- (progn$ (?curr-value $?allowed-values)
- (format t "[%s]" ?curr-value)
- )
- (printout t ": ")
- (bind ?answer (read))
- (if (lexemep ?answer)
- then (bind ?answer (lowcase ?answer)))
- (while (not (member ?answer ?allowed-values)) do
- (format t "%s "?question)
- (progn$ (?curr-value $?allowed-values)
- (format t "[%s]" ?curr-value)
- )
- (printout t ": ")
- (bind ?answer (read))
- (if (lexemep ?answer)
- then (bind ?answer (lowcase ?answer))))
- ?answer
- )
- ;;; Funcion para hacer una pregunta de tipo si/no
- (deffunction MAIN::pregunta-si-no (?question)
- (bind ?response (pregunta-opciones ?question si no))
- (if (or (eq ?response si) (eq ?response s))
- then TRUE
- else FALSE)
- )
- ;;; Funcion para hacer una pregunta multi-respuesta con indices
- (deffunction pregunta-multi (?pregunta $?valores-posibles)
- (bind ?linea (format nil "%s" ?pregunta))
- (printout t ?linea crlf)
- (progn$ (?var ?valores-posibles)
- (bind ?linea (format nil " %d. %s" ?var-index ?var))
- (printout t ?linea crlf)
- )
- (format t "%s" "Indica los números separados por un espacio: ")
- (bind ?resp (readline))
- (bind ?numeros (str-explode ?resp))
- (bind $?lista (create$ ))
- (progn$ (?var ?numeros)
- (if (and (integerp ?var) (and (>= ?var 1) (<= ?var (length$ ?valores-posibles))))
- then
- (if (not (member$ ?var ?lista))
- then (bind ?lista (insert$ ?lista (+ (length$ ?lista) 1) ?var))
- )
- )
- )
- ?lista
- )
- ;;; Pregunta amb rang
- (deffunction pregunta-numerica (?pregunta ?rangini ?rangfi)
- (format t "%s [%d, %d] " ?pregunta ?rangini ?rangfi)
- (bind ?respuesta (read))
- (while (not(and(>= ?respuesta ?rangini)(<= ?respuesta ?rangfi))) do
- (format t "¿%s? [%d, %d] " ?pregunta ?rangini ?rangfi)
- (bind ?respuesta (read)))
- ?respuesta)
- ;;;------------------------------------------------------------------------------------------------------------------------------------------------------
- ;;;---------- MAIN ---------- MAIN
- ;;;------------------------------------------------------------------------------------------------------------------------------------------------------
- (defrule MAIN::comienzo "regla inicial"
- (initial-fact)
- =>
- (printout t crlf)
- (printout t "--------------------------------------------------------------------" crlf)
- (printout t "------ Sistema de Recomanacio d'obres d'art -----" crlf)
- (printout t "--------------------------------------------------------------------" crlf)
- (printout t crlf)
- (focus test_nivell)
- )
- ;;;------------------------------------------------------------------------------------------------------------------------------------------------------
- ;;;---------- MODULO DE PREGUNTAS ---------- MODULO DE PREGUNTAS
- ;;;------------------------------------------------------------------------------------------------------------------------------------------------------
- (defrule test_nivell::coneixements "Valoracio coneixements d'art"
- (not(Visitant))
- =>
- (bind ?nivel 0)
- (printout t "------ TEST DE CONEIXEMENTS xd -----" crlf)
- (bind ?q (pregunta-si-no "El Renaixement surgeix durant els segles XIV i XV"))
- (if (eq ?q FALSE) then (bind ?nivel (+ ?nivel 1)))
- (bind ?q (pregunta-opciones "El Palau de Versalles es troba a ..." paris roma barcelona))
- (if (eq ?q paris) then (bind ?nivel (+ ?nivel 1)))
- (bind ?q (pregunta-si-no "El quadre El grito va ser pintat per Edvard Munch "))
- (if (eq ?q TRUE) then (bind ?nivel (+ ?nivel 1)))
- (bind ?q (pregunta-opciones "El quadre Les Menines es troba al seguent museu: " louvre prado britanico))
- (if (eq ?q prado) then (bind ?nivel (+ ?nivel 1)))
- (bind ?q (pregunta-si-no "Picasso destaca per les seves obres abstractes"))
- (if (eq ?q FALSE) then (bind ?nivel (+ ?nivel 1)))
- (bind ?nivel (* ?nivel 2))
- (if (< ?nivel 5) then (bind ?nivel 1)
- else (if (< ?nivel 8) then (bind ?nivel 2))
- else (bind ?nivel 3))
- (assert (Visitant (coneixements ?nivel)))
- (focus hacer_preguntas)
- )
- ;;;;;;;;;;;;;;;;;;;;;;;;;;PREGUNTAS USUARIO
- (defrule hacer_preguntas::primera_visita "Primera Visita?"
- ?v <- (Visitant (primera_v desconeguda))
- =>
- (bind ?q (pregunta-si-no "Es el primer cop que visites aquest museu? "))
- (modify ?v (primera_v ?q))
- )
- (defrule hacer_preguntas::nombre_hores "Nombre d'hores del visitant al dia"
- ?v <- (Visitant (hores 0))
- =>
- (bind ?duracio (pregunta-numerica "Quantes hores diaries visitaras?" 1 12))
- (modify ?v(hores ?duracio))
- )
- (defrule hacer_preguntas::nombre_dies "Nombre de dies"
- ?v <- (Visitant (dies 0))
- =>
- (bind ?dies (pregunta-general "Quants dies visitaras?"))
- (modify ?v(dies ?dies))
- )
- (defrule hacer_preguntas::corrent_Pref "Corrent mes interesant"
- ?v <- (Visitant (corrent_p cap))
- =>
- (bind ?q (pregunta-opciones "De les seguents opcions quina corrent et resulta mes interessant" realisme impressionisme classicisme))
- (modify ?v (corrent_p ?q))
- )
- (defrule hacer_preguntas::corrent_desc "Corrent a descartar"
- ?v <- (Visitant (corrent_d cap))
- =>
- (bind ?q (pregunta-opciones "De les seguents opcions quina corrent et resulta menys interessant" realisme impressionisme classicisme))
- (modify ?v (corrent_d ?q))
- )
- (defrule hacer_preguntas::pintor_Pref "Pintor mes interesant"
- ?v <- (Visitant (pintor_p cap))
- =>
- (bind ?q (pregunta-opciones "De les seguents opcions quin pintor et resulta mes interessant" vangogh goya picasso))
- (modify ?v (pintor_p ?q))
- )
- (defrule hacer_preguntas::pintor_desc "Pintor a descartar"
- ?v <- (Visitant (pintor_d cap))
- =>
- (bind ?q (pregunta-opciones "De les seguents opcions quin pintor et resulta menys interessant" vangogh goya picasso))
- (modify ?v (pintor_d ?q))
- )
- (defrule hacer_preguntas::tipus_visita "Tipus de visita"
- ?v <- (Visitant (tipus_v 0))
- =>
- (bind ?tipus (pregunta-numerica "Especifica el tipus de visita: (1) Individual, (2) Familia, (3) Grup petit, (4) Grup gran" 1 4))
- (modify ?v (tipus_v ?tipus))
- (focus hacer_calculos)
- )
- ;;;;;;;;;;;;;;;;;;;;;;;;;;HACER CALCULOS
- (defrule hacer_calculos::tiempo_por_obra "Calcula el tiempo de observación por obra"
- (Visitant (tipus_v ?tv) (coneixements ?lvl))
- =>
- (bind ?temps 0)
- (if (eq ?tv 2) then (bind ?temps (+ ?temps 2))
- else (if (eq ?tv 3) then (bind ?temps (+ ?temps 6)))
- else (if (eq ?tv 4) then (bind ?temps (+ ?temps 10))))
- (if (eq ?lvl 2) then (bind ?temps (+ ?temps 5))
- else (if (eq ?lvl 3) then (bind ?temps (+ ?temps 10))))
- (bind $?llista (find-all-instances ((?inst Obra)) TRUE))
- (bind ?i 1)
- (while (<= ?i (length$ ?llista)) do
- (bind ?o (nth$ ?i ?llista))
- (bind ?comp (send ?o get-complexitat))
- (bind ?time (+ ?temps ?comp))
- (send ?o put-complexitat ?time)
- (bind ?i (+ ?i 1))
- )
- )
- (defrule hacer_calculos::modificar_puntuaciones
- (Visitant (corrent_p ?cp) (corrent_d ?cd) (pintor_p ?pp) (pintor_d ?pd) (primera_v ?pv) (coneixements ?lvl))
- =>
- (bind $?llista (find-all-instances ((?inst Obra)) TRUE))
- (bind ?i 1)
- (while (<= ?i (length$ ?llista)) do
- (bind ?o (nth$ ?i ?llista))
- (bind ?comp (send ?o get-complexitat))
- (bind ?autor (send ?o get-autor))
- (bind ?cA (send ?o get-correntA))
- (bind ?dest (send ?o get-destacat))
- (bind ?punt (send ?o get-puntuacio))
- (if(eq ?cp ?cA) then (bind ?punt (+ ?punt 10))
- else (if(eq ?cd ?cA) then (bind ?punt (- ?punt 10))))
- (if(eq ?pp ?autor) then (bind ?punt (+ ?punt 20))
- else (if(eq ?pd ?autor) then (bind ?punt (- ?punt 20))))
- (if (and (eq ?pv TRUE) (eq ?dest si)) then (bind ?punt (+ ?punt 20))
- else (if (and (eq ?pv FALSE) (eq ?dest si)) then (bind ?punt (- ?punt 20))))
- (send ?o put-complexitat ?time)
- (bind ?i (+ ?i 1))
- )
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement