;;; THE INTRO TO AI SHOW ;;; Summer Session I 1999 ;;; ;;; DEMO: ;;; Practice Midterm Answers ;;; ;;; ;;; Selmer Bringsjord ;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; The answer key for the practice midterm. (defvar *key* '((1 (you are on your own)) (2 a) (3 (you are on your own)) (4 e) (5 (you are on your own)) (6 d) (7 (come on)) (8 a) (9 a) (10 (you are on your own)) (11 (explore)) (12 (y y y)) (13 (y y y)) (14 (you are on your own)) (15 d) (16 c) (17 a) (18 (you are on your own)) (19 (you are on your own)) (20 b) (21 e) (21 a) (22 a) (23 d))) ;; key for Practice Midterm 1997 (defvar *old-key* '((1 (on your own)) (2 a) (3 b) (4 b) (5 b) (6 d) (7 a) (8 a) (9 a) (10 c) (11 a) (12 d) (13 c) (14 a) (15 a) (16 b) (17 a) (18 b) (19 c) (20 d) (21 a) (22 a) (23 d))) (defun ralph () "A script for a coverage of answers to the practice midterm, aided by the cantankerous Ralph." (let ((sentence1 nil) (2nd-response nil)) (format t "~&Your practice midterm was a piece of cake. I finished") (format t "~&it in one quadrillionth of a nanosecond. Go ahead.") (format t "~&Give me a question, and I'll give you the answer.~%") (setf sentence1 (readasentence)) (format t "~%No, you human fool. A question *number*. From the exam: ") (setf 2nd-response (get-answer (read))) (format t "~%I'm cruisin'... The answer is ~A:" 2nd-response) (format t "~&That was an exceptionally easy one. Ask me others.") (let ((q-number 0)) (loop (format t "~&Enter your question number: ") (setf q-number (read)) (cond ((and (< q-number 23) (not (= q-number 24))) (format t "~&Huh! No problem, Selmer. The answer is ~A." (get-answer q-number))) ((= q-number 24) (down-on-iq)) ((= q-number 25) (return (format t "~%~%Give up, huh? Well see? Piece of cake.")))))) (format t "~%By the way, the answer to your question... ~% ~A" sentence1) (format t "~%is the statue of the god Vulcan in Alabama.") (format t "~%Always nice doing business with you, Selmer."))) (defun get-answer (n) (cond ((= n 22) (down-on-iq)) ((< n 22) (second (assoc n *key*))) ((> n 22) (format t "~%There is no such question.")))) (defun down-on-iq () (format t "~%IQ is decidely unimpressive; IQ tests are silly.") (format t "~%For example, they include tests of, quote, *digit recall*.") (format t "~%But digit recall says nothing about genuine intelligence.") (format t "~%Even Junior, that rolling advertisement for a bot in need") (format t "~%a massive CPU transplant, an utterly obsequious runt, excels on") (format t "~%this task. Junior. Show him.") (jr9000)) (defun jr9000 () (let ((sequence nil)) (format t "~%~%Hello Doctor Professor Selmer. Digit recall is my speciality.") (format t "~%It's a very important skill to have when you are in outer space.") (format t "~%If you would be so kind, give me a seqence of numbers:~%") ;; Can you modify the code so as to allow for genuine sequences of numbers to ;; be read in and reversed by JR9000? (setf sequence (read)) (format t "~%Thank you, Doctor Professor. Your list, reversed no less, is ~A" sequence) (format t "~%~%Oh, *please*. You're an idiot, Junior, you know that?"))) (defun readasentence () "Reads a sequence of S-expressions until a terminator is encountered. Returns a list of the expressions without the terminator." (let (backwards) (loop (push (read) backwards) (when (terminatorp (first backwards)) (return (reverse (rest backwards))))))) ;;; (defun readasequence () ?) ;;; (defun terminator-seq- p (s) (?) (defun terminatorp (s) "Returns T is S is a sentence terminator; NIL otherwise." (check-type s symbol) (let ((symbstring (symbol-name s))) (char= (char symbstring (1- (length symbstring))) #\.)))