10 REM
20 REM ELIZA/DOCTOR - REM CREATED BY JOESEPH WEIZENBAUM
40 REM THIS VERSION BY JEFF SHRAGER
50 REM EDITED BY BOB ANDERSON - CREATIVE COMPUTING
60 REM PORTED TO LM80C BASIC BY LEONARDO MILIANI
70 REM
80 REM --- INITIALIZATION ---
90 PRINT "Wait...":CLEAR 200
100 DIM C$(72),I$(72),K$(72),F$(72),S$(72),R$(72),P$(72),Z$(72)
110 DIM S(36),R(36),N(36):N1=36:N2=12:N3=112
120 FOR X=1 TO N1+N2+N3:READ Z$:NEXT X
130 FOR X=1 TO N1
140 READ S(X),L:R(X)=S(X):N(X)=S(X)+L-1
150 NEXT X
160 SCREEN 0:PRINT "Hi! I'm Eliza. What is your problem?"
170 REM
180 REM --- USER INPUT ---
190 REM
200 INPUT I$
210 I$=" "+I$+"  ":GOSUB 3000
220 REM
230 FOR L=1 TO LEN(I$)
240 IF MID$(I$,L,1)="'" THEN I$=LEFT$(I$,L-1)+RIGHT$(I$,LEN(I$)-L):GOTO 240
250 IF L+4<=LEN(I$) THEN IF MID$(I$,L,4)="SHUT" THEN PRINT "SHUT UP...":END
260 NEXT L
270 IF I$=P$ THEN PRINT "PLEASE DON'T REPEAT YOURSELF!":GOTO 170
280 REM
290 REM --- FIND KEYWORD ---
300 REM
310 RESTORE
320 S=0
330 FOR K=1 TO N1
340 READ K$
350 IF S>0 THEN 390
360 FOR L=1 TO LEN(I$)-LEN(K$)+1
370 IF MID$(I$,L,LEN(K$))=K$ THEN S=K:T=L:F$=K$
380 NEXT L
390 NEXT K
400 IF S>0 THEN K=S:L=T:GOTO 430
410 K=36:GOTO 630
420 REM
430 REM TAKE RIGHT PART OF STRING
440 REM AND CONJUGATE CORRECTLY
450 REM
460 RESTORE:FOR X=1 TO N1:READ Z$:NEXT X
470 C$=" "+RIGHT$(I$,LEN(I$)-LEN(F$)-L+1)
480 FOR X=1 TO N2/2
490 READ S$,R$
500 FOR L=1 TO LEN(C$)
510 IF L+LEN(S$)>LEN(C$) THEN 560
520 IF MID$(C$,L,LEN(S$))<>S$ THEN 560
530 C$=LEFT$(C$,L-1)+R$+RIGHT$(C$,LEN(C$)-L-LEN(S$)+1)
540 L=L+LEN(S$)
550 GOTO 600
560 IF L+LEN(R$)>LEN(C$) THEN 600
570 IF MID$(C$,L,LEN(R$))<>R$ THEN 600
580 C$=LEFT$(C$,L-1)+S$+RIGHT$(C$,LEN(C$)-L-LEN(R$)+1)
590 L=L+LEN(S$)
600 NEXT L
610 NEXT X
620 REM
630 REM --- GET REPLY --
640 REM
650 RESTORE:FOR X=1 TO N1+N2:READ Z$:NEXT X
660 FOR X=1 TO R(K):READ F$:NEXT X
670 R(K)=R(K)+1:IF R(K)>N(K) THEN R(K)=S(K)
680 IF RIGHT$(F$,1)<>"*" THEN PRINT F$:P$=F$:GOTO 170
690 PRINT LEFT$(F$,LEN(F$)-1);C$
700 P$=F$:GOTO 170
1000 REM
1010 REM PROGRAM DATA
1020 REM
1030 REM KEYWORDS
1040 REM
1050 DATA "CAN YOU","CAN I","YOU ARE","YOURE","I DONT","I FEEL"
1060 DATA "WHY DONT YOU","WHY CANT I","ARE YOU","I CANT","I AM","IM "
1070 DATA "YOU ","I WANT","WHAT","HOW","WHO","WHERE","WHEN","WHY"
1080 DATA "NAME","CAUSE","SORRY","DREAM","HELLO","HI'","MAYBE"
1090 DATA "NO","YOUR","ALWAYS","THINK","ALIKE","YES","FRIEND"
1100 DATA "COMPUTER","NOKEYFOUND"
1200 REM
1210 REM --- CONJUGATION DATA ---
1220 REM
1230 DATA " ARE "," AM ","WERE ","WAS "," YOU "," I ","YOUR ","MY "
1240 DATA " IVE ", " YOUVE ", " IM ", " YOURE "
1300 REM
1310 REM --- REPLIES ---
1320 REM
1330 DATA "DON'T YOU BELIEVE THAT I CAN*"
1340 DATA "PERHAPS YOU WOULD LIKE TO BE ABLE TO*"
1350 DATA "YOU WANT ME TO BE ABLE TO*"
1360 DATA "PERHAPS YOU DON'T WANT TO*"
1370 DATA "DO YOU WANT TO BE ABLE TO*"
1380 DATA "WHAT MAKES YOU THINK I AM*"
1390 DATA "DOES IT PLEASE YOU TO BELIEVE THAT I AM*"
1400 DATA "PERHAPS YOU WOULD LIKE TO BE*"
1410 DATA "DO YOU SOMETIMES WISH YOU WERE*"
1420 DATA "DON'T YOU REALLY*"
1430 DATA "WHY DON'T YOU*"
1440 DATA "DO YOU WISH TO BE ABLE TO*"
1450 DATA "DOES THAT TROUBLE YOU?"
1460 DATA "TELL ME MORE ABOUT SUCH FEELINGS."
1470 DATA "DO YOU OFTEN FEEL*"
1480 DATA "DO YOU ENJOY FEELING*"
1490 DATA "DO YOU REALLY BELIEVE I DON'T*"
1500 DATA "PERHAPS IN GOOD TIME I WILL*"
1510 DATA "DO YOU WANT ME TO*"
1520 DATA "DO YOU THINK YOU SHOULD BE ABLE TO*"
1530 DATA "WHY CAN'T YOU*"
1540 DATA "WHY ARE YOU INTERESTED IN WHETHER OR NOT I AM*"
1550 DATA "WOULD YOU PREFER IF I WERE NOT*"
1560 DATA "PERHAPS IN YOUR FANTASIES I AM*"
1570 DATA "HOW DO YOU KNOW I CAN'T*"
1580 DATA "HAVE YOU TRIED?"
1590 DATA "PERHAPS YOU CAN NOW*"
1600 DATA "DID VOU COME TO ME BECAUSE YOU ARE*"
1610 DATA "HOW LONG HAVE YOU BEEN*"
1620 DATA "DO YOU BELIEVE IT IS NORMAL TO BE*"
1630 DATA "DO YOU ENJOY BEING*"
1640 DATA "WE WERE DI SCUSSING YOU-- NOT ME."
1650 DATA "OH, I*"
1660 DATA "YOU'RE NOT REALLY TALKING ABOUT ME, ARE YOU?"
1670 DATA "WHAT WOULD IT MEAN IF YOU GOT*"
1680 DATA "WHY DO YOU WANT*"
1690 DATA "SUPPOSE YOU SOOM GOT*"
1700 DATA "WHAT IF YOU NEVER GOT*"
1710 DATA "I SOMETIMES ALSO WANT*"
1720 DATA "WHY DO YOU ASK?"
1730 DATA "DOES THAT QUESTION INTEREST YOU?"
1740 DATA "WHAT ANSWER WOULD PLEASE YOU THE MOST?"
1750 DATA "WHAT DO YOU THINK?"
1760 DATA "ARE SUCH QUESTIONS ON YOU MIND OFTEN?"
1770 DATA "WHAT IS IT YOU REALLY WANT TO KNOW?"
1780 DATA "HAVE YOU ASKED ANYONE ELSE?"
1790 DATA "HAVE YOU ASKED SUCH QUESTIONS BEFORE?"
1800 DATA "WHAT ELSE COMES TO MIND WHEN YOU ASK THAT?"
1810 DATA "NAMES DON'T INTEREST ME."
1820 DATA "I DON'T CARE ABOUT NAMES. GO ON."
1830 DATA "IS THAT THE REAL REASON?"
1840 DATA "DON'T ANY OTHER REASONS COME TO MIND?"
1850 DATA "DOES THAT REASON EXPLAIN ANYTHING ELSE?"
1860 DATA "WHAT OTHER REASON MIGHT THERE BE?"
1870 DATA "PLEASE DON'T APOLOGIZE."
1880 DATA "APOLOGIES ARE NOT NECESSARY."
1890 DATA "WHAT FEELINGS DO YOU GET WHEN YOU APOLOGIZE."
1900 DATA "DON'T BE SO DEFENSIVE!"
1910 DATA "WHAT DOES THAT DREAM SUGGEST TO YOU?"
1920 DATA "DO YOU DREAM OFTEN?"
1930 DATA "WHAT PERSONS APPEAR IN YOUR DREAMS?"
1940 DATA "ARE YOU DISTURBED BY YOUR DREAMS?"
1950 DATA "HOW DO YOU DO... PLEASE STATE YOUR PROBLEM."
1960 DATA "YOU DON'T SEEM QUITE CERTAIN."
1970 DATA "WHY THE UNCERTAIN TONE?"
1980 DATA "CAN'T YOU BE MORE POSITIVE?"
1990 DATA "YOU AREN'T SURE?"
2000 DATA "DON'T YOU KNOW?"
2010 DATA "ARE YOU SAYING THAT JUST TO BE NEGATIVE?"
2020 DATA "YOU ARE BEING A BIT NEGATIVE."
2030 DATA "WHY NOT?"
2040 DATA "ARE YOU SURE?"
2050 DATA "WHY NO?"
2060 DATA "WHY ARE YOU CONCERNED ABOUT MY*"
2070 DATA "WHAT ABOUT YOUR OWN*"
2080 DATA "CAN YOU THINK OF A SPECIFIC EXAMPLE?"
2090 DATA "WHEN?"
2100 DATA "WHAT ARE YOU THINKING OF?"
2110 DATA "REALLY, ALWAYS?"
2120 DATA "DO YOU REALLY THINK SO"
2130 DATA "BUT YOU ARE NOT SURE YOU*"
2140 DATA "DO YOU DOUBT YOU*"
2150 DATA "IN WHAT WAY?"
2160 DATA "WHAT RESEMBLENCE DO YOU SEE?"
2170 DATA "WHAT DOES THE SIMILARITY SUGGEST TO YOU?"
2180 DATA "WHAT OTHER CONNECTIONS DO YOU SEE?"
2190 DATA "COULD THERE REALLY BE SOME CONNECTION?"
2200 DATA "HOW?"
2210 DATA "YOU SEEM QUITE POSITIVE."
2220 DATA "ARE YOU SURE?"
2230 DATA "I SEE."
2240 DATA "I UNDERSTAND."
2250 DATA "WHY DO YOU BRING UP THE TOPIC OF FRIENDS?"
2260 DATA "DO YOUR FRIENDS WORRY YOU?"
2270 DATA "DO YOUR FRIENDS PICK ON YOU?"
2280 DATA "ARE YOU SURE YOU HAVE ANY FRIENDS?"
2290 DATA "DO YOU IMPOSE ON YOUR FRIENDS?"
2300 DATA "PERHAPS YOUR LOVE FOR FRIENDS WORRIES YOU?"
2310 DATA "DO COMPUTERS WORRY YOU?"
2320 DATA "ARE YOU TALKING ABOUT ME IN PARTICULAR?"
2330 DATA "ARE YOU FRIGHTENED BY MACHINES?"
2340 DATA "WHY DO YOU MENTION COMPUTERS?"
2350 DATA "WHAT DO YOU THINK COMPUTER HAVE TO DO WITH YOUR PROBLEM?"
2360 DATA "DON'T YOU THINK COMPUTERS CAN HELP PEOPLE?"
2370 DATA "WHAT IS IT ABOUT MACHINES THAT WORRIES YOU?"
2380 DATA "SAY, DO YOU HAVE ANY PSYCOLOGICAL PROBLEMS?"
2390 DATA "WHAT DOES THAT SUGGEST TO YOU?"
2400 DATA "I SEE."
2410 DATA "I'M NOT SURE I UNDERSTAND YOU FULLY."
2420 DATA "COME COME ELUCIDATE YOUR THOUGHTS."
2430 DATA "CAN YOU ELABORATE ON THAT?"
2440 DATA "THAT IS QUITE INTERESTING."
2500 REM
2510 REM --- REPLY FINDING DATA ---
2520 REM
2530 DATA 1,3,4,2,6,4,6,4,10,4,14,3,17,3,20,2,22,3,25,3
2540 DATA 28,4,28,4,32,3,35,5,40,9,40,9,40,9,40,9,40,9,40,9
2550 DATA 49,2,51,4,55,4,59,4,63,1,63,1,64,5,69,5,74,2,76,4
2560 DATA 80,3,83,7,90,3,93,6,99,7,106,6
2570 REM
2580 REM --- CONVERT INPUT TO UPPER CASE ---
2590 REM
3000 IF I$="" THEN RETURN
3010 T$=""
3020 FOR XC=1 TO LEN(I$)
3030 V=VAL(MID$(I$,XC,1))
3040 IF V>=97 AND V<=122 THEN V=V-32
3050 T$=T$+CHR$(V)
3060 NEXT
3070 I$=T$:RETURN
