(defactor phil (l r (sticks 0)) (m)
  (if (zerop sticks)
      (progn
	(pr "Got one")
	(incf sticks) next)
      (progn 
	(pr "Got both")
	(send l (make-drop self)) (send r (make-drop self))
	(pr "Dropped")
	(send l (make-pick self)) (send r (make-pick self))
	(setf sticks 0) next)))

(defactor chopstick ((h nil) (w nil)) (m)
  (if (pick? m)
      (if (null h)
	  (progn (send (get-phil m) nil) 
		 (setf h (get-phil m) w nil)
		 next)
	  (progn (setf w (get-phil m))
		 next)))
  (if (drop? m)
      (if (null w)
	  (progn (setf w nil h nil)
		 next)
	  (progn (send w nil)
		 (setf h w w nil))))
  next)

(defun make-drop (cust) `("drop" ,cust))
(defun make-pick (cust) `("pick" ,cust)) 
(defun pick? (x) (equal (first x) "pick"))
(defun drop? (x) (equal (first x) "drop"))
(defun get-phil (m) (second m))

(defactor phil (l r (sticks 0)) (m)
  (if (zerop sticks)
      (progn
	(pr "Got one")
	(incf sticks) next)
      (progn 
	(pr "Got both")
	(send l (make-drop self)) (send r (make-drop self))
	(pr "Dropped")
	(send l (make-pick self)) (send r (make-pick self))
	(setf sticks 0) next)))

(defactor chopstick ((h nil) (w nil)) (m)
  (if (pick? m)
      (if (null h)
	  (progn (send (get-phil m) nil) 
		 (setf h (get-phil m) w nil)
		 next)
	  (progn (setf w (get-phil m))
		 next)))
  (if (drop? m)
      (if (null w)
	  (progn (setf w nil h nil)
		 next)
	  (progn (send w nil)
		 (setf h w w nil))))
  next)

(defun make-drop (cust) `("drop" ,cust))
(defun make-pick (cust) `("pick" ,cust)) 
(defun pick? (x) (equal (first x) "pick"))
(defun drop? (x) (equal (first x) "drop"))
(defun get-phil (m) (second m))
