(define (domain grid)
(:requirements :strips)
(:types place key shape)
(:predicates (conn ?x - place ?y - place)
             (keyshape ?k - key ?s - shape)
             (lockshape ?p - place ?s - shape)
             (at ?k - key ?p - place)
	     (atrobot ?p - place)
             (locked ?p - place)
	     (open ?p - place)
             (holding ?k - key)
             (armempty))

(:action unlock
  :parameters (?o1 - place ?o2 - place ?o3 - key ?o4 - shape)
  :precondition (and (conn ?o1 ?o2)
  		     (keyshape ?o3 ?o4)
		     (lockshape ?o2 ?o4)
		     (atrobot ?o1)
		     (locked ?o2)
		     (holding ?o3))
  :effect (and  (open ?o2)
  	  	(not (locked ?o2))))

(:action move
  :parameters (?o1 - place ?o2 - place)
  :precondition (and (atrobot ?o1)
  		     (conn ?o1 ?o2)
		     (open ?o2))
  :effect (and (atrobot ?o2)
  	       (not (atrobot ?o1))))

(:action pickup
  :parameters (?o1 - place ?o2 - key)
  :precondition (and (atrobot ?o1)
  		     (at ?o2 ?o1)
		     (armempty))
  :effect (and (holding ?o2)
  	       (not (at ?o2 ?o1))
	       (not (armempty))))


(:action pickupandloose
  :parameters (?o1 - place ?o2 - key ?o3 - key)
  :precondition (and (atrobot ?o1)
  		     (holding ?o3)
		     (at ?o2 ?o1))
  :effect (and (holding ?o2)
  	       (at ?o3 ?o1)
               (not (holding ?o3))
	       (not (at ?o2 ?o1))))

(:action putdown
  :parameters (?o1 - place ?o2 - key)
  :precondition (and (atrobot ?o1)
  		     (holding ?o2))
  :effect (and (armempty)
  	       (at ?o2 ?o1)
	       (not (holding ?o2)))))



