Advertisement
Guest User

Untitled

a guest
Dec 7th, 2016
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 22.17 KB | None | 0 0
  1. ; Wed Dec 07 16:28:52 CET 2016
  2. ;
  3. ;+ (version "3.4.8")
  4. ;+ (build "Build 629")
  5.  
  6.  
  7. (defclass %3ACLIPS_TOP_LEVEL_SLOT_CLASS "Fake class to save top-level slot information"
  8. (is-a USER)
  9. (role abstract)
  10. (single-slot corrent
  11. (type STRING)
  12. ;+ (cardinality 0 1)
  13. (create-accessor read-write))
  14. (single-slot epocaP
  15. (type STRING)
  16. ;+ (cardinality 0 1)
  17. (create-accessor read-write))
  18. (single-slot any
  19. (type INTEGER)
  20. ;+ (cardinality 0 1)
  21. (create-accessor read-write))
  22. (multislot preferencies
  23. (type STRING)
  24. (create-accessor read-write))
  25. (single-slot tipus
  26. (type STRING)
  27. ;+ (value "Individual" "Familia" "Grup petit" "Grup gran")
  28. ;+ (cardinality 0 1)
  29. (create-accessor read-write))
  30. (single-slot destacat
  31. (type SYMBOL)
  32. (allowed-values FALSE TRUE)
  33. ;+ (cardinality 0 1)
  34. (create-accessor read-write))
  35. (single-slot importancia
  36. (type STRING)
  37. ;+ (value "Baixa" "Mitjana" "Alta")
  38. ;+ (cardinality 0 1)
  39. (create-accessor read-write))
  40. (single-slot autor
  41. (type STRING)
  42. ;+ (cardinality 0 1)
  43. (create-accessor read-write))
  44. (single-slot dimensions
  45. (type STRING)
  46. ;+ (cardinality 0 1)
  47. (create-accessor read-write))
  48. (single-slot nacionalitat
  49. (type STRING)
  50. ;+ (cardinality 0 1)
  51. (create-accessor read-write))
  52. (single-slot complexitat
  53. (type INTEGER)
  54. (range 1 10)
  55. ;+ (cardinality 0 1)
  56. (create-accessor read-write))
  57. (single-slot sala
  58. (type STRING)
  59. ;+ (cardinality 0 1)
  60. (create-accessor read-write))
  61. (single-slot nombre+de+dies
  62. (type INTEGER)
  63. ;+ (cardinality 0 1)
  64. (create-accessor read-write))
  65. (single-slot tematica
  66. (type STRING)
  67. ;+ (cardinality 0 1)
  68. (create-accessor read-write))
  69. (single-slot correntA
  70. (type STRING)
  71. ;+ (cardinality 0 1)
  72. (create-accessor read-write))
  73. (single-slot epoca
  74. (type STRING)
  75. ;+ (cardinality 0 1)
  76. (create-accessor read-write))
  77. (single-slot titol
  78. (type STRING)
  79. ;+ (cardinality 0 1)
  80. (create-accessor read-write))
  81. (single-slot nom
  82. (type STRING)
  83. ;+ (cardinality 0 1)
  84. (create-accessor read-write))
  85. (single-slot coneixements
  86. (type INTEGER)
  87. (range 1 10)
  88. ;+ (cardinality 0 1)
  89. (create-accessor read-write))
  90. (single-slot duracio
  91. ;+ (comment "Nombre d'hores diaries dels visitants")
  92. (type INTEGER)
  93. ;+ (cardinality 0 1)
  94. (create-accessor read-write)))
  95.  
  96. (defclass Obra
  97. (is-a USER)
  98. (role concrete)
  99. (single-slot autor
  100. (type STRING)
  101. ;+ (cardinality 0 1)
  102. (create-accessor read-write))
  103. (single-slot titol
  104. (type STRING)
  105. ;+ (cardinality 0 1)
  106. (create-accessor read-write))
  107. (single-slot dimensions
  108. (type STRING)
  109. ;+ (cardinality 0 1)
  110. (create-accessor read-write))
  111. (single-slot any
  112. (type INTEGER)
  113. ;+ (cardinality 0 1)
  114. (create-accessor read-write))
  115. (single-slot sala
  116. (type STRING)
  117. ;+ (cardinality 0 1)
  118. (create-accessor read-write))
  119. (single-slot destacat
  120. (type SYMBOL)
  121. (allowed-values FALSE TRUE)
  122. ;+ (cardinality 0 1)
  123. (create-accessor read-write))
  124. (single-slot tematica
  125. (type STRING)
  126. ;+ (cardinality 0 1)
  127. (create-accessor read-write))
  128. (single-slot correntA
  129. (type STRING)
  130. ;+ (cardinality 0 1)
  131. (create-accessor read-write))
  132. (single-slot complexitat
  133. (type INTEGER)
  134. (range 1 10)
  135. ;+ (cardinality 0 1)
  136. (create-accessor read-write)))
  137.  
  138. (defclass Pintor
  139. (is-a USER)
  140. (role concrete)
  141. (single-slot nacionalitat
  142. (type STRING)
  143. ;+ (cardinality 0 1)
  144. (create-accessor read-write))
  145. (single-slot corrent
  146. (type STRING)
  147. ;+ (cardinality 0 1)
  148. (create-accessor read-write))
  149. (single-slot nom
  150. (type STRING)
  151. ;+ (cardinality 0 1)
  152. (create-accessor read-write))
  153. (single-slot epoca
  154. (type STRING)
  155. ;+ (cardinality 0 1)
  156. (create-accessor read-write)))
  157.  
  158. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  159. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  160. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  161.  
  162. (definstances instancies
  163. ; Wed Dec 07 16:28:52 CET 2016
  164. ;
  165. ;+ (version "3.4.8")
  166. ;+ (build "Build 629")
  167.  
  168. ([ontologia_Class0] of Pintor
  169.  
  170. (corrent "impressionisme")
  171. (epoca "XIX")
  172. (nacionalitat "Francesa")
  173. (nom "manet"))
  174.  
  175. ([ontologia_Class1] of Obra
  176.  
  177. (any 1888)
  178. (autor "gogh")
  179. (complexitat 1)
  180. (correntA "postimpressionisme")
  181. (dimensions "72 x 90")
  182. (sala "2")
  183. (tematica "habitacio")
  184. (titol "L'habitacio"))
  185.  
  186. ([ontologia_Class10] of Obra
  187.  
  188. (any 1813)
  189. (autor "hayez")
  190. (complexitat 2)
  191. (correntA "romanticisme")
  192. (destacat TRUE)
  193. (dimensions "94.1 x 73.5")
  194. (sala "4")
  195. (tematica "mort")
  196. (titol "La mort d'Abradatas"))
  197.  
  198. ([ontologia_Class10002] of Pintor
  199.  
  200. (corrent "romanticisme")
  201. (epoca "XIX")
  202. (nacionalitat "Espanyola")
  203. (nom "goya"))
  204.  
  205. ([ontologia_Class10003] of Pintor
  206.  
  207. (corrent "postimpressionisme")
  208. (epoca "XIX")
  209. (nacionalitat "Holandes")
  210. (nom "gogh"))
  211.  
  212. ([ontologia_Class10004] of Pintor
  213.  
  214. (corrent "expressionisme")
  215. (epoca "XIX")
  216. (nacionalitat "Noruec")
  217. (nom "munch"))
  218.  
  219. ([ontologia_Class10005] of Pintor
  220.  
  221. (corrent "neoclacissisme")
  222. (epoca "XIX")
  223. (nacionalitat "Americana")
  224. (nom "copley"))
  225.  
  226. ([ontologia_Class10006] of Pintor
  227.  
  228. (corrent "romanticisme")
  229. (epoca "XIX")
  230. (nacionalitat "Russa")
  231. (nom "brullov"))
  232.  
  233. ([ontologia_Class10007] of Pintor
  234.  
  235. (corrent "postimpressionisme")
  236. (epoca "XIX")
  237. (nacionalitat "Italiana")
  238. (nom "hayez"))
  239.  
  240. ([ontologia_Class10008] of Pintor
  241.  
  242. (corrent "expressionisme")
  243. (epoca "XIX")
  244. (nacionalitat "Italiana")
  245. (nom "modigliani"))
  246.  
  247. ([ontologia_Class10009] of Pintor
  248.  
  249. (corrent "expressionisme")
  250. (epoca "XIX")
  251. (nacionalitat "Brasileña")
  252. (nom "segall"))
  253.  
  254. ([ontologia_Class10010] of Pintor
  255.  
  256. (corrent "expressionisme")
  257. (epoca "XIX")
  258. (nacionalitat "Canadenc")
  259. (nom "carr"))
  260.  
  261. ([ontologia_Class10011] of Obra
  262.  
  263. (any 1911)
  264. (autor "carr")
  265. (complexitat 2)
  266. (correntA "expressionisme")
  267. (destacat TRUE)
  268. (dimensions "80.2 x 59.8")
  269. (sala "1")
  270. (tematica "paisatge")
  271. (titol "Tardor a França"))
  272.  
  273. ([ontologia_Class10012] of Obra
  274.  
  275. (any 1906)
  276. (autor "carr")
  277. (complexitat 2)
  278. (correntA "expressionisme")
  279. (dimensions "42.5 x 32.2")
  280. (sala "1")
  281. (tematica "paisatge")
  282. (titol "Esglesia Francesa"))
  283.  
  284. ([ontologia_Class10014] of Obra
  285.  
  286. (any 1928)
  287. (autor "carr")
  288. (complexitat 2)
  289. (correntA "expressionisme")
  290. (dimensions "81 x 100")
  291. (sala "1")
  292. (tematica "paisatge")
  293. (titol "Kitwancool"))
  294.  
  295. ([ontologia_Class10015] of Obra
  296.  
  297. (any 1933)
  298. (autor "carr")
  299. (complexitat 1)
  300. (correntA "expressionisme")
  301. (destacat TRUE)
  302. (dimensions "40.9 x 35.3")
  303. (sala "1")
  304. (tematica "paisatge")
  305. (titol "Vista marina"))
  306.  
  307. ([ontologia_Class10016] of Obra
  308.  
  309. (any 1930)
  310. (autor "carr")
  311. (complexitat 3)
  312. (correntA "expressionisme")
  313. (destacat TRUE)
  314. (dimensions "153.6 x 216.7")
  315. (sala "5")
  316. (tematica "paisatge")
  317. (titol "Blunden Harbour"))
  318.  
  319. ([ontologia_Class10017] of Obra
  320.  
  321. (any 1879)
  322. (autor "manet")
  323. (complexitat 3)
  324. (correntA "impressionisme")
  325. (destacat TRUE)
  326. (dimensions "115 x 150")
  327. (sala "1")
  328. (tematica "retrat")
  329. (titol "Al conservatori"))
  330.  
  331. ([ontologia_Class10018] of Obra
  332.  
  333. (any 1863)
  334. (autor "manet")
  335. (complexitat 3)
  336. (correntA "impressionisme")
  337. (dimensions "208 × 264")
  338. (sala "3")
  339. (tematica "retrat")
  340. (titol "El dinar campestre"))
  341.  
  342. ([ontologia_Class10019] of Obra
  343.  
  344. (any 1863)
  345. (autor "manet")
  346. (complexitat 3)
  347. (correntA "impressionisme")
  348. (destacat TRUE)
  349. (dimensions "130 x 190")
  350. (sala "3")
  351. (tematica "retrat")
  352. (titol "Olympia"))
  353.  
  354. ([ontologia_Class10020] of Obra
  355.  
  356. (any 1798)
  357. (autor "goya")
  358. (complexitat 1)
  359. (correntA "romanticisme")
  360. (dimensions "30 x 43")
  361. (sala "4")
  362. (tematica "mitologia")
  363. (titol "Aquelarre"))
  364.  
  365. ([ontologia_Class10021] of Obra
  366.  
  367. (any 1765)
  368. (autor "goya")
  369. (complexitat 2)
  370. (correntA "romanticisme")
  371. (dimensions "50.4 x 72.5")
  372. (sala "4")
  373. (tematica "mitologia")
  374. (titol "La Triple generacion"))
  375.  
  376. ([ontologia_Class10022] of Obra
  377.  
  378. (any 1770)
  379. (autor "goya")
  380. (complexitat 2)
  381. (correntA "romanticisme")
  382. (dimensions "87 x 131.5")
  383. (sala "4")
  384. (tematica "mitologia")
  385. (titol "Anibal vencedor"))
  386.  
  387. ([ontologia_Class10023] of Obra
  388.  
  389. (any 1771)
  390. (autor "goya")
  391. (complexitat 1)
  392. (correntA "romanticisme")
  393. (destacat TRUE)
  394. (dimensions "33 x 24")
  395. (sala "4")
  396. (tematica "mitologia")
  397. (titol "Sacrificio a Pan"))
  398.  
  399. ([ontologia_Class10024] of Obra
  400.  
  401. (any 1872)
  402. (autor "gogh")
  403. (complexitat 1)
  404. (correntA "postimpressionisme")
  405. (dimensions "24.5 x 18.5")
  406. (sala "2")
  407. (tematica "natura")
  408. (titol "Sequia"))
  409.  
  410. ([ontologia_Class10025] of Obra
  411.  
  412. (any 1885)
  413. (autor "gogh")
  414. (complexitat 2)
  415. (correntA "postimpressionisme")
  416. (dimensions "82 x 114")
  417. (sala "1")
  418. (tematica "retrat")
  419. (titol "Menjant patates"))
  420.  
  421. ([ontologia_Class10026] of Obra
  422.  
  423. (any 1889)
  424. (autor "gogh")
  425. (complexitat 2)
  426. (correntA "postimpressionisme")
  427. (destacat TRUE)
  428. (dimensions "74 x 92.1")
  429. (sala "2")
  430. (tematica "natura")
  431. (titol "Camp tancat amb pages"))
  432.  
  433. ([ontologia_Class10027] of Obra
  434.  
  435. (any 1887)
  436. (autor "gogh")
  437. (complexitat 2)
  438. (correntA "postimpressionisme")
  439. (dimensions "55.5 x 46.5")
  440. (sala "1")
  441. (tematica "retrat")
  442. (titol "Dona al Cafè de Tambourin"))
  443.  
  444. ([ontologia_Class10028] of Obra
  445.  
  446. (any 1915)
  447. (autor "modigliani")
  448. (complexitat 2)
  449. (correntA "expressionisme")
  450. (dimensions "75 x 105")
  451. (sala "1")
  452. (tematica "retrat")
  453. (titol "Paul Guillaume, Novo Pilota"))
  454.  
  455. ([ontologia_Class10029] of Obra
  456.  
  457. (any 1917)
  458. (autor "modigliani")
  459. (complexitat 2)
  460. (correntA "expressionisme")
  461. (dimensions "60 x 92")
  462. (sala "5")
  463. (tematica "retrat")
  464. (titol "Nu reclinat"))
  465.  
  466. ([ontologia_Class10030] of Obra
  467.  
  468. (any 1916)
  469. (autor "modigliani")
  470. (complexitat 2)
  471. (correntA "expressionisme")
  472. (dimensions "55 x 46")
  473. (sala "5")
  474. (tematica "retrat")
  475. (titol "La jueva"))
  476.  
  477. ([ontologia_Class11] of Obra
  478.  
  479. (any 1916)
  480. (autor "modigliani")
  481. (complexitat 2)
  482. (correntA "expressionisme")
  483. (dimensions "81 x 54")
  484. (sala "5")
  485. (tematica "retrat")
  486. (titol "Retrat de Jaques i Berthe Lipchitz"))
  487.  
  488. ([ontologia_Class12] of Obra
  489.  
  490. (any 1910)
  491. (autor "munch")
  492. (complexitat 1)
  493. (correntA "expressionisme")
  494. (dimensions "66 x 83")
  495. (sala "1")
  496. (tematica "paisatge")
  497. (titol "El crit"))
  498.  
  499. ([ontologia_Class13] of Obra
  500.  
  501. (any 1927)
  502. (autor "segall")
  503. (complexitat 2)
  504. (correntA "expressionisme")
  505. (dimensions "46 x 69")
  506. (sala "5")
  507. (tematica "retrat")
  508. (titol "Retrat de Guilherme de Almeida"))
  509.  
  510. ([ontologia_Class14] of Obra
  511.  
  512. (any 1939)
  513. (autor "carr")
  514. (complexitat 3)
  515. (correntA "expressionisme")
  516. (dimensions "300 x 185.4")
  517. (sala "5")
  518. (tematica "paisatge")
  519. (titol "Odds and Ends"))
  520.  
  521. ([ontologia_Class15] of Obra
  522.  
  523. (any 1782)
  524. (autor "copley")
  525. (complexitat 3)
  526. (correntA "neoclacissisme")
  527. (destacat TRUE)
  528. (dimensions "103 x 137.5")
  529. (sala "5")
  530. (tematica "retrat")
  531. (titol "Henry Laurens"))
  532.  
  533. ([ontologia_Class3] of Obra
  534.  
  535. (any 1890)
  536. (autor "gogh")
  537. (complexitat 2)
  538. (correntA "postimpressionisme")
  539. (dimensions "49.5 x 99.7")
  540. (sala "2")
  541. (tematica "natura")
  542. (titol "Parella caminant entre arbres"))
  543.  
  544. ([ontologia_Class4] of Obra
  545.  
  546. (any 1887)
  547. (autor "gogh")
  548. (complexitat 2)
  549. (correntA "postimpressionisme")
  550. (dimensions "65 x 51")
  551. (sala "1")
  552. (tematica "retrat")
  553. (titol "Retrat de Père Tanguy"))
  554.  
  555. ([ontologia_Class5] of Obra
  556.  
  557. (any 1882)
  558. (autor "manet")
  559. (complexitat 2)
  560. (correntA "impressionisme")
  561. (dimensions "96 x 130")
  562. (sala "1")
  563. (tematica "retrat")
  564. (titol "El bar del Folies Bergère"))
  565.  
  566. ([ontologia_Class6] of Obra
  567.  
  568. (any 1873)
  569. (autor "manet")
  570. (complexitat 2)
  571. (correntA "impressionisme")
  572. (dimensions "94.6 x 83.3")
  573. (sala "3")
  574. (tematica "retrat")
  575. (titol "El Bon Bock"))
  576.  
  577. ([ontologia_Class7] of Obra
  578.  
  579. (any 1779)
  580. (autor "goya")
  581. (complexitat 3)
  582. (correntA "romanticisme")
  583. (destacat TRUE)
  584. (dimensions "259 x 220")
  585. (sala "5")
  586. (tematica "paisatge")
  587. (titol "El cacharrero"))
  588.  
  589. ([ontologia_Class8] of Obra
  590.  
  591. (any 1833)
  592. (autor "brullov")
  593. (complexitat 3)
  594. (correntA "romanticisme")
  595. (dimensions "465.5 x 651")
  596. (sala "4")
  597. (tematica "mort")
  598. (titol "L'ultim dia de Pompeii"))
  599. )
  600.  
  601. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  602. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  603. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  604.  
  605. (defmodule MAIN (export ?ALL))
  606.  
  607. ;;;------------------------------------------------------------------------------------------------------------------------------------------------------
  608. ;;;---------- DEFINICION DE TEMPLATES ---------- DEFINICION DE TEMPLATES
  609. ;;;-------------------------------------------------------------------------------------------------------------------------------------------------------
  610.  
  611. (deftemplate MAIN::Visitant
  612. (slot coneixements (type INTEGER)(default 0))
  613. (slot hores (type INTEGER) (default 0))
  614. (slot dies (type INTEGER) (default 0))
  615. (slot corrent_p (type SYMBOL) (default cap))
  616. (slot corrent_d (type SYMBOL) (default cap))
  617. (slot pintor_p (type SYMBOL) (default cap))
  618. (slot pintor_d (type SYMBOL) (default cap))
  619. (slot tipus_v (type INTEGER) (default 0))
  620. (slot primera_v (type SYMBOL) (default desconeguda))
  621.  
  622. )
  623.  
  624. ; Emmagatzemem la puntuació de cada una de les obres
  625. (deftemplate puntuacions
  626. (slot obra (type STRING))
  627. (slot puntuacio (type INTEGER) (default 5)))
  628.  
  629. ;(deftemplate puntuacions_ordenades
  630. (slot titol (type STRING))
  631. (slot puntuacio (type INTEGER)))
  632.  
  633. ;;;------------------------------------------------------------------------------------------------------------------------------------------------------
  634. ;;;---------- FUNCIONES ---------- EXTRAS
  635. ;;;-------------------------------------------------------------------------------------------------------------------------------------------------------
  636.  
  637.  
  638. (defmodule MAIN (export ?ALL))
  639.  
  640. (defmodule test_nivell
  641. (import MAIN ?ALL)
  642. (export ?ALL)
  643. )
  644.  
  645. (defmodule hacer_preguntas
  646. (import MAIN ?ALL)
  647. (import test_nivell deftemplate ?ALL)
  648. (export ?ALL)
  649. )
  650.  
  651. (defmodule hacer_calculos
  652. (import MAIN ?ALL)
  653. (import test_nivell deftemplate ?ALL)
  654. (import hacer_preguntas deftemplate ?ALL)
  655. (export ?ALL)
  656. )
  657.  
  658. ;;;; Funcion para hacer una pregunta general
  659. (deffunction MAIN::pregunta-general (?pregunta)
  660. (format t "%s" ?pregunta)
  661. (bind ?respuesta (read))
  662. ?respuesta
  663. )
  664.  
  665. ;;; Funcion para hacer una pregunta general con una serie de respuestas admitidas
  666. (deffunction MAIN::pregunta-opciones (?question $?allowed-values)
  667. (format t "%s "?question)
  668. (progn$ (?curr-value $?allowed-values)
  669. (format t "[%s]" ?curr-value)
  670. )
  671. (printout t ": ")
  672. (bind ?answer (read))
  673. (if (lexemep ?answer)
  674. then (bind ?answer (lowcase ?answer)))
  675. (while (not (member ?answer ?allowed-values)) do
  676. (format t "%s "?question)
  677. (progn$ (?curr-value $?allowed-values)
  678. (format t "[%s]" ?curr-value)
  679. )
  680. (printout t ": ")
  681. (bind ?answer (read))
  682. (if (lexemep ?answer)
  683. then (bind ?answer (lowcase ?answer))))
  684. ?answer
  685. )
  686.  
  687. ;;; Funcion para hacer una pregunta de tipo si/no
  688. (deffunction MAIN::pregunta-si-no (?question)
  689. (bind ?response (pregunta-opciones ?question si no))
  690. (if (or (eq ?response si) (eq ?response s))
  691. then TRUE
  692. else FALSE)
  693. )
  694.  
  695. ;;; Funcion para hacer una pregunta multi-respuesta con indices
  696. (deffunction pregunta-multi (?pregunta $?valores-posibles)
  697. (bind ?linea (format nil "%s" ?pregunta))
  698. (printout t ?linea crlf)
  699. (progn$ (?var ?valores-posibles)
  700. (bind ?linea (format nil " %d. %s" ?var-index ?var))
  701. (printout t ?linea crlf)
  702. )
  703. (format t "%s" "Indica los números separados por un espacio: ")
  704. (bind ?resp (readline))
  705. (bind ?numeros (str-explode ?resp))
  706. (bind $?lista (create$ ))
  707. (progn$ (?var ?numeros)
  708. (if (and (integerp ?var) (and (>= ?var 1) (<= ?var (length$ ?valores-posibles))))
  709. then
  710. (if (not (member$ ?var ?lista))
  711. then (bind ?lista (insert$ ?lista (+ (length$ ?lista) 1) ?var))
  712. )
  713. )
  714. )
  715. ?lista
  716. )
  717. ;;; Pregunta amb rang
  718. (deffunction pregunta-numerica (?pregunta ?rangini ?rangfi)
  719. (format t "%s [%d, %d] " ?pregunta ?rangini ?rangfi)
  720. (bind ?respuesta (read))
  721. (while (not(and(>= ?respuesta ?rangini)(<= ?respuesta ?rangfi))) do
  722. (format t "¿%s? [%d, %d] " ?pregunta ?rangini ?rangfi)
  723. (bind ?respuesta (read)))
  724. ?respuesta)
  725.  
  726. ;;;------------------------------------------------------------------------------------------------------------------------------------------------------
  727. ;;;---------- MAIN ---------- MAIN
  728. ;;;------------------------------------------------------------------------------------------------------------------------------------------------------
  729. (defrule MAIN::comienzo "regla inicial"
  730. (initial-fact)
  731. =>
  732. (printout t crlf)
  733. (printout t "--------------------------------------------------------------------" crlf)
  734. (printout t "------ Sistema de Recomanacio d'obres d'art -----" crlf)
  735. (printout t "--------------------------------------------------------------------" crlf)
  736. (printout t crlf)
  737. (focus test_nivell)
  738. )
  739.  
  740. ;;;------------------------------------------------------------------------------------------------------------------------------------------------------
  741. ;;;---------- MODULO DE PREGUNTAS ---------- MODULO DE PREGUNTAS
  742. ;;;------------------------------------------------------------------------------------------------------------------------------------------------------
  743.  
  744. (defrule test_nivell::coneixements "Valoracio coneixements d'art"
  745. (not(Visitant))
  746. =>
  747. (bind ?nivel 0)
  748. (printout t "------ TEST DE CONEIXEMENTS xd -----" crlf)
  749. (bind ?q (pregunta-si-no "El Renaixement surgeix durant els segles XIV i XV"))
  750. (if (eq ?q FALSE) then (bind ?nivel (+ ?nivel 1)))
  751. (bind ?q (pregunta-opciones "El Palau de Versalles es troba a ..." paris roma barcelona))
  752. (if (eq ?q paris) then (bind ?nivel (+ ?nivel 1)))
  753. (bind ?q (pregunta-si-no "El quadre El grito va ser pintat per Edvard Munch "))
  754. (if (eq ?q TRUE) then (bind ?nivel (+ ?nivel 1)))
  755. (bind ?q (pregunta-opciones "El quadre Les Menines es troba al seguent museu: " louvre prado britanico))
  756. (if (eq ?q prado) then (bind ?nivel (+ ?nivel 1)))
  757. (bind ?q (pregunta-si-no "Picasso destaca per les seves obres abstractes"))
  758. (if (eq ?q FALSE) then (bind ?nivel (+ ?nivel 1)))
  759. (bind ?nivel (* ?nivel 2))
  760. (if (< ?nivel 5) then (bind ?nivel 1)
  761. else (if (< ?nivel 8) then (bind ?nivel 2))
  762. else (bind ?nivel 3))
  763. (assert (Visitant (coneixements ?nivel)))
  764. (focus hacer_preguntas)
  765. )
  766.  
  767. ;;;;;;;;;;;;;;;;;;;;;;;;;;PREGUNTAS USUARIO
  768. (defrule hacer_preguntas::primera_visita "Primera Visita?"
  769. ?v <- (Visitant (primera_v desconeguda))
  770. =>
  771. (bind ?q (pregunta-si-no "Es el primer cop que visites aquest museu? "))
  772. (modify ?v (primera_v ?q))
  773. )
  774.  
  775. (defrule hacer_preguntas::nombre_hores "Nombre d'hores del visitant al dia"
  776. ?v <- (Visitant (hores 0))
  777. =>
  778. (bind ?duracio (pregunta-numerica "Quantes hores diaries visitaras?" 1 12))
  779. (modify ?v(hores ?duracio))
  780. )
  781.  
  782. (defrule hacer_preguntas::nombre_dies "Nombre de dies"
  783. ?v <- (Visitant (dies 0))
  784. =>
  785. (bind ?dies (pregunta-general "Quants dies visitaras?"))
  786. (modify ?v(dies ?dies))
  787. )
  788.  
  789. (defrule hacer_preguntas::corrent_Pref "Corrent mes interesant"
  790. ?v <- (Visitant (corrent_p cap))
  791. =>
  792. (bind ?q (pregunta-opciones "De les seguents opcions quina corrent et resulta mes interessant" realisme impressionisme classicisme))
  793. (modify ?v (corrent_p ?q))
  794. )
  795.  
  796. (defrule hacer_preguntas::corrent_desc "Corrent a descartar"
  797. ?v <- (Visitant (corrent_d cap))
  798. =>
  799. (bind ?q (pregunta-opciones "De les seguents opcions quina corrent et resulta menys interessant" realisme impressionisme classicisme))
  800. (modify ?v (corrent_d ?q))
  801. )
  802.  
  803. (defrule hacer_preguntas::pintor_Pref "Pintor mes interesant"
  804. ?v <- (Visitant (pintor_p cap))
  805. =>
  806. (bind ?q (pregunta-opciones "De les seguents opcions quin pintor et resulta mes interessant" vangogh goya picasso))
  807. (modify ?v (pintor_p ?q))
  808. )
  809.  
  810. (defrule hacer_preguntas::pintor_desc "Pintor a descartar"
  811. ?v <- (Visitant (pintor_d cap))
  812. =>
  813. (bind ?q (pregunta-opciones "De les seguents opcions quin pintor et resulta menys interessant" vangogh goya picasso))
  814. (modify ?v (pintor_d ?q))
  815. )
  816.  
  817. (defrule hacer_preguntas::tipus_visita "Tipus de visita"
  818. ?v <- (Visitant (tipus_v 0))
  819. =>
  820. (bind ?tipus (pregunta-numerica "Especifica el tipus de visita: (1) Individual, (2) Familia, (3) Grup petit, (4) Grup gran" 1 4))
  821. (modify ?v (tipus_v ?tipus))
  822. (focus hacer_calculos)
  823. )
  824.  
  825. ;;;;;;;;;;;;;;;;;;;;;;;;;;HACER CALCULOS
  826.  
  827. (defrule hacer_calculos::tiempo_por_obra "Calcula el tiempo de observación por obra"
  828. (Visitant (tipus_v ?tv) (coneixements ?lvl))
  829. =>
  830. (bind ?temps 0)
  831. (if (eq ?tv 2) then (bind ?temps (+ ?temps 2))
  832. else (if (eq ?tv 3) then (bind ?temps (+ ?temps 6)))
  833. else (if (eq ?tv 4) then (bind ?temps (+ ?temps 10))))
  834. (if (eq ?lvl 2) then (bind ?temps (+ ?temps 5))
  835. else (if (eq ?lvl 3) then (bind ?temps (+ ?temps 10))))
  836. (bind $?llista (find-all-instances ((?inst Obra)) TRUE))
  837. (bind ?i 1)
  838. (while (<= ?i (length$ ?llista)) do
  839. (bind ?o (nth$ ?i ?llista))
  840. (bind ?comp (send ?o get-complexitat))
  841. (bind ?time (+ ?temps ?comp))
  842. (send ?o put-complexitat ?time)
  843. (bind ?i (+ ?i 1))
  844. )
  845. )
  846. (defrule hacer_calculos::modificar_puntuaciones
  847. (Visitant (corrent_p ?cp) (corrent_d ?cd) (pintor_p ?pp) (pintor_d ?pd) (primera_v ?pv) (coneixements ?lvl))
  848. =>
  849. (bind $?llista (find-all-instances ((?inst Obra)) TRUE))
  850. (bind ?i 1)
  851. (while (<= ?i (length$ ?llista)) do
  852. (bind ?o (nth$ ?i ?llista))
  853. (bind ?comp (send ?o get-complexitat))
  854. (bind ?autor (send ?o get-autor))
  855. (bind ?cA (send ?o get-correntA))
  856. (bind ?dest (send ?o get-destacat))
  857. (bind ?punt (send ?o get-puntuacio))
  858. (if(eq ?cp ?cA) then (bind ?punt (+ ?punt 10))
  859. else (if(eq ?cd ?cA) then (bind ?punt (- ?punt 10))))
  860. (if(eq ?pp ?autor) then (bind ?punt (+ ?punt 20))
  861. else (if(eq ?pd ?autor) then (bind ?punt (- ?punt 20))))
  862. (if (and (eq ?pv TRUE) (eq ?dest si)) then (bind ?punt (+ ?punt 20))
  863. else (if (and (eq ?pv FALSE) (eq ?dest si)) then (bind ?punt (- ?punt 20))))
  864. (send ?o put-complexitat ?time)
  865. (bind ?i (+ ?i 1))
  866. )
  867. )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement