;;; -*- Mode: Lisp; Syntax: Common-Lisp; -*- File: planning/domains/blocks-world.lisp

;;;; The Blocks World

(defun make-blocks-world-schemas ()
  "The MOVE and MOVETOTABLE action schemas of the blocks world [Fig. 11.4]."
  (list (make-action-schema
	 :name '(Move $b $x $y)
	 :precond '((On $b $x) (Clear $b) (Clear $y) (Block $b) (Block $y)
		    (/= $b $x) (/= $b $y) (/= $x $y))
	 :effect '((On $b $y) (Clear $x) (not (On $b $x)) (not (Clear $y))))
	(make-action-schema
	 :name '(MoveToTable $b $x)
	 :precond '((On $b $x) (Clear $b) (Block $b) (Block $x))
	 :effect '((On $b Table) (Clear $x) (not (On $b $x))))))

(defun make-blocks-world-problem ()
  "Build a three-block tower, starting from C on A [Fig. 11.4]; this is the
  Sussman anomaly.  One solution is ((MoveToTable C A) (Move B Table C)
  (Move A Table B))."
  (make-planning-problem
   :initial '((On A Table) (On B Table) (On C A)
	      (Block A) (Block B) (Block C) (Clear B) (Clear C) (Clear Table))
   :goal '((On A B) (On B C))
   :schemas (make-blocks-world-schemas)))
