




Eivind Sandstrand (username: c473bp)
#8923460
cse473 Spring 1991


1a) # of nodes = 165.

 b) Solution length = 3, Average runtime for 4 tries =
				 (1.4+1.0+0.9+1.1)/4 = 1.2 sec

 c) It backtracks since every operator will be tried against block C first, 
    causes goal clobbering and detours.



2a) Yes, because we no longer have the generator-expression test.

 b) It doen't know what it means to not hold an object, it's unknown.


3)



;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;  "Towers Of Hanoi Domain"   Eivind O. Sandstrand Cse473 May 8, 1991
;;
;;   This is meant to be a 1-operator solver for the 'tower' problem.
;;   It doesn't work right.  (Bomben und Granaten!!)  The problems seem
;;   to be in the way I let Prodigy match goals and effects - it bombs
;;   too fast.
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(setq *OPERATORS* '(

(MOVE-TO
 (params (<disk> <to-peg>))
 (preconds (and 
	    (is-disk <disk>)                ;; These work as generators.
	    (is-peg <to-peg>)               ;;  to  check for right types
	    (on-peg <disk> <old-peg>)       ;; Find old peg
	    (clear-disk <disk>)             ;; Disk to move must be clear.
	    (or (clear-peg <to-peg>)        ;; Either to-peg is clear, or
	     (and (on-peg <adisk> <to-peg>) ;;  there's another disk there
	      (clear-disk <adisk>)          ;;  which is on top and is
	      (is-smaller <disk> <adisk>)))));  smaller

 (effects( (IF (on-disk <disk> <old-disk>)  ;; If disk was on some other...
	      (del (on-disk <disk> <old-disk>))
	      (add (clear-disk <old-disk>)));; ...then free that disk
           (IF (and (on-peg <adisk> <to-peg>); If there's one on to-peg...
		    (clear-disk <adisk>))   ;; ...and it's clear
	       (del (clear-disk <adisk>))   ;; ...then cover that disk
	       (add (on-disk <disk> <adisk>)))
           (IF (clear-peg <to-peg>)         ;; If our to-peg has no disks
	       (add (on-peg <disk> <to-peg>))); ...simply place new one there
           (del (clear-peg <to-peg>))       ;; Now  to-peg is not clear
	   (del (on-peg <disk> <old-peg>))  ;; And disk has moved from old-disk
           (add (clear-disk <disk>)))))))   ;; ...and has become clear






;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;
;;                Function List
;;
;;  This function list is only meant to go with 'tower' problems of size 3.
;;  To get  a more general function list, one could use member functions
;;  to test against a user/problem defined list of disks and pegs.
;;  But it works for now.
;;
;;  (Ich habe Sauerkraut in meiner Lederhosen!)

(defun is-smaller (D1 D2)
  (cond ( (and (equal D1 'diskA) (equal D2 'diskB)) T)
	( (and (equal D1 'diskB) (equal D2 'diskC)) T)
	( T NIL)))

(defun is-disk (D)
  (cond ( (or (equal D 'diskA) (equal D 'diskB) (equal D 'diskC)) T)
	( T  NIL)))

(defun is-peg (P)
  (cond ( (or (equal P 'peg1) (equal P 'peg2) (equal P 'peg3)) T)
	( T NIL)))

	


(setq *SCR-OP-SELECT-RULES* nil)
(setq *SCR-BINDINGS-SELECT-RULES* nil)
(setq *SCCR-NODE-REJECT-RULES* nil)
(setq *SCR-GOAL-REJECT-RULES* nil)
(setq *SCR-OP-REJECT-RULES* nil)
(setq *SCR-BINDINGS-REJECT-RULES* nil)
(setq *SCR-NODE-PREFERENCE-RULES* nil)
(setq *SCR-GOAL-PREFERENCE-RULES* nil)
(setq *SCR-OP-PREFERENCE-RULES* nil)
(setq *SCR-BINDINGS-PREFERNCE-RULES nil)



(setq *WORLD-PATH*
      (pathname "~/my-domains/hanoi/"))
(load-path *WORLD-PATH* "domain")
(load-path *WORLD-PATH* "functions")
(load-path *WORLD-PATH* "sc-rules")
(load-domain)




;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;     
;;                   Towers Of Hanoi Domain
;;
;; Test problem
;;
;; Has 3 disks and three pegs.  diskA<diskB<diskC.  The goal is to get all
;; disks on peg3 with diskA on top and diskC on bottom.
;;

(load-goal 
 '(and 
   (clear diskA)
   (on diskA diskB)
   (on diskB diskC)
   (on-peg diskC peg3)
))

(load-start-state 
 '(
   (clear diskA)
   (on-peg diskC peg1)
   (on diskA diskB)
   (on diskB diskC)
))