(load-file "domain.tlp") (declare-external-symbols "../userlib/freecell" (predicate stack-card "StackCard" 1) (predicate end-stack "EndStack" 0) (predicate print-stacks "PrintStacks" 1) (function random-freecell-game "RandomFreeCellGame" 2)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; 6. Print Routines ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (def-defined-predicate (print-freecell-world ?stream) (and (exists (?cells) (cellspace ?cells) (?cols) (colspace ?cols) (print ?stream "Colspace = ~3S Cellspace = ~3S~%" ?cols ?cells)) (print-home-and-free-cells ?stream) (forall (?card) (bottomcol ?card) (accumulate-stack ?card)) (print-stacks ?stream))) ;; print the home cells and the free cells (def-defined-predicate (print-home-and-free-cells ?stream) (and (print ?stream "Free Cells: ") (forall (?card) (incell ?card) (print ?stream "~3S " ?card)) (print ?stream "~%Home Cells: ") (forall (?card) (home ?card) (print ?stream "~3S " ?card)) (print ?stream "~%~%"))) ;; accumulate a list containing a stack of cards (def-defined-predicate (accumulate-stack ?card) (and (stack-card ?card) (or (and (clear ?card) (end-stack)) (exists (?newcard) (on ?newcard ?card) (accumulate-stack ?newcard))))) (set-print-world-fn print-freecell-world) (define (goal10) (home c10) (home d10) (home h10) (home s10)) (define (goal11) (home cJ) (home dJ) (home hJ) (home sJ)) (define (goal12) (home cQ) (home dQ) (home hQ) (home sQ)) (define (goal13) (home cK) (home dK) (home hK) (home sK)) (define (goal9) (home c9) (home d9) (home h9) (home s9)) (define (goal8) (home c8) (home d8) (home h8) (home s8)) (define (goal7) (home c7) (home d7) (home h7) (home s7)) (define (goal6) (home c6) (home d6) (home h6) (home s6)) (define (goal5) (home c5) (home d5) (home h5) (home s5)) (define (goal4) (home c4) (home d4) (home h4) (home s4)) (define (goal3) (home c3) (home d3) (home h3) (home s3)) (define (goal2) (home c2) (home d2) (home h2) (home s2)) (define (goal1) (home cA) (home dA) (home hA) (home sA)) ;;We will print full fledged init states. More than we actually need ;;given that the domain generates most of it. (set-initial-world (random-freecell-game 1 3)) (set-goal (goal3)) (declare-defined-symbols (predicate genprobs 4)) (def-defined-predicate (genprobs ?minsize ?maxsize ?numprobs ?stream) (and (forall (?size) (is-between ?size ?minsize ?maxsize) (forall (?probnum) (is-between ?probnum 1 ?numprobs) (and (set-initial-world (random-freecell-game ?probnum ?size)) (select-initial-world) (print ?stream "(set-plan-name freecell-~A-~A)~%" ?size ?probnum) (print ?stream "(set-initial-world ~%") (current (and (forall (?cd ?vl) (value ?cd ?vl) (implies (<= ?vl ?size) (print ?stream " (value ~A n~A)~%" ?cd ?vl))) (forall (?n1 ?n0) (successor ?n1 ?n0) (print ?stream " (successor n~A n~A)~%" ?n1 ?n0)) (forall (?cd ?suit) (suit ?cd ?suit) (implies (exists (?vl) (value ?cd ?vl) (<= ?vl ?size)) (print ?stream " (suit ~A ~A)~%" ?cd ?suit))) (forall (?c1 ?c2) (canstack ?c1 ?c2) (implies (and (exists (?v1) (value ?c1 ?v1) (<= ?v1 ?size)) (exists (?v2) (value ?c2 ?v2) (<= ?v2 ?size))) (print ?stream " (canstack ~A ~A)~%" ?c1 ?c2))) (print ?stream " (home c0) (home d0) (home h0) (home s0)~%") (forall (?cells) (cellspace ?cells) (print ?stream " (cellspace n~A)~%" ?cells)) (forall (?cols) (colspace ?cols) (print ?stream " (colspace n~A)~%" ?cols)) (forall (?c1 ?c2) (on ?c1 ?c2) (print ?stream " (on ~A ~A)~%" ?c1 ?c2)) (forall (?c1) (incell ?c1) (print ?stream " (incell ~A)~%" ?c1)) (forall (?c1) (clear ?c1) (print ?stream " (clear ~A)~%" ?c1)) (forall (?c1) (bottomcol ?c1) (print ?stream " (bottomcol ~A)~%" ?c1)) (print ?stream ")~%(set-goal ~%") (forall (?homegoal) (value ?homegoal ?size) (print ?stream " (home ~A)~%" ?homegoal)) (print ?stream ")~%(plan)~%~%"))))))))