; ##################################################### ; ########### inicialitzacions #################### ; ##################################################### (deffacts inici (inici) ) (defrule primera ?a <- (inici) => (obtenir_dades) (retract ?a) ) (deffunction obtenir_dades() (printout t "Quina distancia hi ha del jugador a la porteria? ") (assert (djpo (read))) (printout t "Quina distancia hi ha del jugador a la pilota? ") (assert (djpi (read))) (assert (DECISIO PRESA= anar_pilota)) ) ; ##################################################### ; ############# base de regles #################### ; ##################################################### (defrule porteria_aprop ?a <- (djpo ?d&:(< ?d 20)) => (retract ?a) (assert (porteria_aprop)) ) (defrule puc_xutar ?a <- (djpi ?d&:(< ?d 1)) => (retract ?a) (assert (puc_xutar)) ) (defrule conduir_pilota ?a <- (puc_xutar) ?b <- (DECISIO PRESA= anar_pilota) => (retract ?a ?b) (assert (DECISIO PRESA= conduir_pilota)) ) (defrule xutar_porteria ?a <- (DECISIO PRESA= conduir_pilota) ?b <- (porteria_aprop) => (retract ?a ?b) (assert (DECISIO PRESA= xutar_porteria)) )