(deffacts network-of-places (place(name A1) (x 0) (y 1) (neighbors A2 B1 B2)) (place(name A2) (x 0) (y 2) (neighbors A1 A3 B1 B2 B3)) (place(name A3) (x 0) (y 3) (neighbors A2 A4 B2 B3 B4)) (place(name A4) (x 0) (y 4) (neighbors A3 A5 B3 B4 B5)) (place(name A5) (x 0) (y 5) (neighbors A4 B4 B5)) (place(name B1) (x 1) (y 1) (neighbors A1 A2 B2 C1)) (place(name B2) (x 1) (y 2) (neighbors A1 A2 A3 B1 B3)) (place(name B3) (x 1) (y 3) (neighbors A2 A3 A4 B2 B4)) (place(name B4) (x 1) (y 4) (neighbors A3 A4 A5 B3 B5)) (place(name B5) (x 1) (y 5) (neighbors A4 A5 B4 C5)) (place(name C1) (x 2) (y 1) (neighbors B1 D1)) (place(name C2) (x 2) (y 2) (neighbors C3 D2 D3)) (place(name C3) (x 2) (y 3) (neighbors C2 C4 D2 D3 D4)) (place(name C4) (x 2) (y 4) (neighbors C3 D3 D4)) (place(name C5) (x 2) (y 5) (neighbors B5 D5)) (place(name D1) (x 3) (y 1) (neighbors C1 E1)) (place(name D2) (x 3) (y 2) (neighbors C2 C3 D3 E2 E3)) (place(name D3) (x 3) (y 3) (neighbors C2 C3 C4 D2 D4 E2 E3 E4)) (place(name D4) (x 3) (y 4) (neighbors C3 C4 D3 E3 E4)) (place(name D5) (x 3) (y 5) (neighbors C5 E5)) (place(name E1) (x 4) (y 1) (neighbors D1 F1)) (place(name E2) (x 4) (y 2) (neighbors D2 D3 E3)) (place(name E3) (x 4) (y 3) (neighbors D2 D3 D4 E2 E4)) (place(name E4) (x 4) (y 4) (neighbors D3 D4 E3 F4)) (place(name E5) (x 4) (y 5) (neighbors D5 F5)) (place(name F1) (x 5) (y 1) (neighbors E1 F2)) (place(name F2) (x 5) (y 2) (neighbors F1 F3)) (place(name F3) (x 5) (y 3) (neighbors F2 F4)) (place(name F4) (x 5) (y 4) (neighbors E4 F3 F5)) (place(name F5) (x 5) (y 5) (neighbors E5 F4)) ) ;; ;; Rule to inialise the research ;; (defrule init "initiatlise the goal and start nodes" (initial-fact) (not (start)) => (printout t "The name of the start node? ") (bind ?n (read)) (assert (start (name ?n) )) (printout t "The name of the goal? ") (bind ?n (read)) (assert (goal (name ?n))) ) ;; ;; recover the path ;; (defrule recover-path "Compose a path list" ?C <- (path ?n $?q) (node (name ?n) (father ?p&:(neq ?p nil))) (goal (name ?b&:(neq ?p ?b))) => (retract ?C) (assert (chemin ?p ?n $?q)) ) ;; ;; print the path ;; (defrule print-path "Print out the path" (path ?d $?q ?b) (start (name ?d)) => (printout t "the path from " ?d " to " ?b " goes through " $?q crlf) (halt) )