;;;; 8-puzzle (role player) ;;;; initial state (init (cell 1 1 8)) (init (cell 1 2 7)) (init (cell 1 3 6)) (init (cell 2 1 5)) (init (cell 2 2 4)) (init (cell 2 3 3)) (init (cell 3 1 2)) (init (cell 3 2 1)) (init (cell 3 3 b)) (init (step 0)) ;;;; adjacency (succ 1 2) (succ 2 3) (pred 2 1) (pred 3 2) ;;;; legal moves: e.g.: move(2,2) means move the blank square to 2,2 from whereever it is. ;;;; this will only be legal if it was in a square adjacent to the square picked (<= (legal player (move ?x ?y)) (true (cell ?u ?y b)) (or (succ ?x ?u) (pred ?x ?u))) (<= (legal player (move ?x ?y)) (true (cell ?x ?v b)) (or (succ ?y ?v) (pred ?y ?v))) ;;;; next states (<= (next (step ?x)) (true (step ?y)) (successor ?y ?x)) (<= (next (cell ?x ?y b)) (does player (move ?x ?y))) (<= (next (cell ?u ?y ?z)) (does player (move ?x ?y)) (true (cell ?u ?y b)) (true (cell ?x ?y ?z)) (distinct ?z b)) (<= (next (cell ?x ?v ?z)) (does player (move ?x ?y)) (true (cell ?x ?v b)) (true (cell ?x ?y ?z)) (distinct ?z b)) (<= (next (cell ?u ?v ?z)) (true (cell ?u ?v ?z)) (does player (move ?x ?y)) (or (distinct ?x ?u) (distinct ?y ?v)) (true (cell ?x1 ?y1 b)) (or (distinct ?x1 ?u) (distinct ?y1 ?v))) ;;;; goal and terminal (<= (goal player 100) inorder (true (step 30))) (<= (goal player 99) inorder (true (step ?x)) (distinct ?x 30)) (<= (goal player 0) (not inorder)) (<= terminal inorder) (<= terminal (true (step 60))) (<= inorder (true (cell 1 1 1)) (true (cell 1 2 2)) (true (cell 1 3 3)) (true (cell 2 1 4)) (true (cell 2 2 5)) (true (cell 2 3 6)) (true (cell 3 1 7)) (true (cell 3 2 8)) (true (cell 3 3 b))) ;;; Step counting (successor 0 1) (successor 1 2) (successor 2 3) (successor 3 4) (successor 4 5) (successor 5 6) (successor 6 7) (successor 7 8) (successor 8 9) (successor 9 10) (successor 10 11) (successor 11 12) (successor 12 13) (successor 13 14) (successor 14 15) (successor 15 16) (successor 16 17) (successor 17 18) (successor 18 19) (successor 19 20) (successor 20 21) (successor 21 22) (successor 22 23) (successor 23 24) (successor 24 25) (successor 25 26) (successor 26 27) (successor 27 28) (successor 28 29) (successor 29 30) (successor 30 31) (successor 31 32) (successor 32 33) (successor 33 34) (successor 34 35) (successor 35 36) (successor 36 37) (successor 37 38) (successor 38 39) (successor 39 40) (successor 40 41) (successor 41 42) (successor 42 43) (successor 43 44) (successor 44 45) (successor 45 46) (successor 46 47) (successor 47 48) (successor 48 49) (successor 49 50) (successor 50 51) (successor 51 52) (successor 52 53) (successor 53 54) (successor 54 55) (successor 55 56) (successor 56 57) (successor 57 58) (successor 58 59) (successor 59 60)