Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (defglobal ?*nod-gen* = 0)
- (defglobal ?*f* = 1)
- ;(deffacts Aeropuerto MT P6 T1 T1 P6 T2 P2 maletas M1 12 F P3 M2 18 F P5 M3 20 P1 R M4 14 P6 R)
- ;(deffacts mapa F P2 F)
- ;(deffacts mapa P2 P4 P2)
- ;(deffacts mapa P4 P3 P4)
- ;(deffacts mapa P3 P1 P3)
- ;(deffacts mapa P1 P5 P1)
- ;(deffacts mapa F P1 F)
- ;(deffacts mapa P5 R P5)
- ;(deffacts mapa P5 P7 P5)
- ;(deffacts mapa P7 P8 P7)
- ;(deffacts mapa P8 P6 P8)
- ;(deffacts mapa P6 R P6)
- ;(deffacts cargas T1 0 15 T2 16 23)
- (defrule enganchar
- (declare (salience 20))
- ?f <- (Aeropuerto MT ?p ?vagon carros $?anon3 ?vagon ?pos $?anon1 ?maleta ?pmal $?anon2 nivel ?n)
- (cargas $? vagon ?vagon ?pmin ?pmax $?)
- (test (eq ?p ?pos))
- ;(test (and(> ?pmal ?pmin)(< ?pmal ?pmax)))
- =>
- ;(retract ?f)
- (assert (Aeropuerto MT ?p ?vagon carros $?anon3 ?vagon ?pos $?anon1 ?maleta ?pmal $?anon2 nivel (+ ?n 1)))
- )
- (defrule mover
- (declare (salience 10))
- ?f <- (Aeropuerto MT ?p ?y carros $?z1 ?y ?p $?z2 ?maleta ?peso ?ori ?dest $?z3 nivel ?n)
- (mapa $? ?p ?pos2 $?)
- =>
- (assert(Aeropuerto MT ?pos2 ?y carros $?z1 ?y ?pos2 $?z2 ?maleta ?peso ?ori ?dest $?z3 nivel (+ ?n 1)))
- (bind ?*nod-gen* (+ ?*nod-gen* 1))
- )
- (defrule cargar
- (declare(salience 100))
- (Aeropuerto MT ?p ?y carros $?z1 ?y ?p $?z2 ?m ?pmal ?ori ?dest $?z3 nivel ?n)
- (cargas $? vagon ?vagon ?pmin ?pmax $?)
- ;(test (and(> ?pmal ?pmin)(< ?pmal ?pmax)))
- (test (eq ?p ?ori))
- =>
- (assert (Aeropuerto MT ?p ?y ?m ?pmal ?ori ?dest carros $?z1 ?y ?p $?z2 $?z3 nivel (+ ?n 1)))
- (bind ?*nod-gen* (+ ?*nod-gen* 1))
- )
- (defrule descargar
- (declare (salience 100))
- (Aeropuerto MT ?p ?y carros $?z1 ?m ?pmal ?ori ?dest $?z2 ?y ?p $?z3 nivel ?n)
- (test (eq ?p ?dest))
- =>
- (assert(Aeropuerto MT ?p ?y carros $?z1 $?z2 ?y ?p $?z3 nivel (+ ?n 1)))
- (bind ?*nod-gen* (+ ?*nod-gen* 1))
- )
- (defrule objetivo
- (declare (salience 100))
- ?f<-(Aeropuerto MT $?x maletas nivel ?n)
- =>
- (printout t "SOLUCION ENCONTRADA EN EL NIVEL " ?n crlf)
- (printout t "NUMERO DE NODOS EXPANDIDOS O REGLAS DISPARADAS " ?*nod-gen* crlf)
- (printout t "HECHO OBJETIVO " ?f crlf)
- (halt)
- )
- (deffunction inicio ()
- (reset)
- (printout t "Profundidad Maxima:= " )
- (bind ?prof (read))
- (printout t "Tipo de Busqueda " crlf " 1.- Anchura" crlf " 2.- Profundidad" crlf )
- (bind ?a (read))
- (if (= ?a 1)
- then (set-strategy breadth)
- else (set-strategy depth))
- (printout t " Ejecuta run para poner en marcha el programa " crlf)
- (assert (Aeropuerto MT P6 T1 carros T1 P6 T2 P2 maletas M1 12 F P3 M2 18 F P5 M3 20 P1 R M4 14 P6 R nivel 0))
- (assert (mapa F P2 F))
- (assert (mapa P2 P4 P2))
- (assert (mapa P4 P3 P4))
- (assert (mapa P1 F P1))
- (assert (mapa P1 P5 P1))
- (assert (mapa P5 P7 P5))
- (assert (mapa P7 P8 P7))
- (assert (mapa P8 P6 P8))
- (assert (mapa R P6 R))
- (assert (mapa R P5 R))
- (assert (cargas vagon T1 0 15 vagon T2 16 23))
- (assert (profundidad-maxima ?prof))
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement