;;; multiagent.lsp
;;; An example of running two conversational
;;; agents in the same session.
;;; This solution does not use packages.
;;; The trick is to prefix any user-defined
;;; function names or global variables with
;;; the name (or abbreviated name) of the agent.
;;;     Steve Tanimoto, 2 Feb 2003.

; The first agent called STEVE...

(defun steve-respond (sentence)
  (if (member 'love sentence) '(it must be close to valentines day)
    '(i do not really get what you are saying) ) )


; The second agent, called JOE...

(defun joe-respond (sentence)
  (if (member 'really sentence) '(like really)
    (append joe-prefix '(think of anything to say)) ) )

(setq joe-prefix '(i cannot))


; Now let's use both agents in the same session.


(defun nturns (n)
  (let ((utterance '(hello)))
  (dotimes (i n)
    (format t "Steve says: ~A~%" utterance)
    (setq utterance (joe-respond utterance))
    (format t "Joe says: ~A~%" utterance)
    (setq utterance (steve-respond utterance))
  ) ) )

(nturns 3)