;;; THE INTRO TO AI SHOW ;;; Summer Session I 1997 ;;; ;;; DEMO: ;;; Simple tutorial with JR9000 ;;; Ralph plays an obnoxious game against Selmer ;;; ;;; NOTE: ;;; The function in question is defined in normal ;;; mathematical form in the class slides. ;;; ;;; Selmer Bringsjord ;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; How might the following function be reconstructed so that pieces within ;;; it are given over to helper functions that do part of the work? (defun jr9000 () "A script for a simple tutorial aided by the obsequious JR9000." (let ((defun-template nil) (adds-three nil) (new-three nil)) (format t "~&O Most Esteemed Professor Doctor") (format t "~&Selmer, may I ask you some questions?~%") (format t "~&Can you show me the template for defining a function?~%") (if (eql (read) 'sure) (format t "~&O thank you Doctor Professor! Please specify the template:~%") (format t "~&I implore you, Doctor Selmer. NASA, my boss, needs your wisdom:~%")) (setf defun-template (read)) ;; What sort of interesting things could be done with the list read in here? ;; As things stand now, the list isn't processed. (format t "~&I see; thank you.") (format t "~&Could you possibly define a function that adds three numbers?~%") (setf adds-three (read)) (eval adds-three) (format t "~%Can you show me this function in action, Doctor Professor?~%") ;; How would you allow for the "output" of this function to be shown on the ;; monitor at the next step? (eval (read)) (format t "~%Thank you! But what if the input isn't a number?") (format t "~%Can you anticipate that? Show me a new function, please:~%") (setf new-three (read)) (eval new-three) (format t "~%Can you show me this new function in action, Doctor Professor?~%") (eval (read)))) (defun ralph () "Calls Ralph. The idea is to leave things open here for other games in the future." (random-list)) (defun random-list () (let ((random-list)) (format t "~%Selmer, since you are so Vulcanesque, let us play a little game.") (format t "~&I will give you a list of random numbers for you to sort") (format t "~&from largest to smallest. I will expect your answer to come quickly.") (format t "~&Are you ready?~%") (if (eql 'yes (read)) (format t "~%Very well; here goes......") (format t "~%Chicken! I say we play anyway ....")) (setf random-list (random-nums)) (format t "~&The number is: ~% ~A." random-list) (countdown2) (format t "~&The answer is: ~% ~A." (sort random-list #'>)) (format t "~&What happened, O Brilliant One?"))) (defun random-nums () (list (random 5000) (random 5000) (random 5000) (random 5000) (random 5000) (random 5000) (random 5000) (random 5000) (random 5000) (random 5000) (random 5000) (random 5000) (random 5000) (random 5000) (random 5000) (random 5000) (random 5000) (random 5000) (random 5000) (random 5000) (random 5000) (random 5000) (random 5000) (random 5000) (random 5000) (random 5000) (random 5000) (random 5000) (random 5000) (random 5000) (random 5000) (random 5000) (random 5000) (random 5000) (random 5000))) (defun countdown2 () (do ((result (format t "~%Your time is nearly up. My positronic brain is humming ...")) (counter 0)) ((= counter 800000) result) (setf counter (1+ counter))))