DR. CHALLENGER LIVES!

I got DR. CHALLENGER working last night! It's an ancient chatbot that is a simulation of an interactive Rogerian non-directive psychotherapist. I wrote it in 1979, inspired by ELIZA. (See the source code for DR. CHALLENGER at the end of this article).

Last night I first got it to run on the phone in an app that emulates Commodore BASIC from the late 70's, then online, in an Apple II BASIC emulator.

There is a description of DR. CHALLENGER and the 1978 computer it was written on in my article about AI here. Here are photos of the computer and the revival of it (2001):

Ohio Scientific Challenger 1P

Running the vintage computer and transcribing a program

 

Dr. CHALLENGER running on an iPhone

DR. CHALLENGER running in an Apple II online BASIC emulator

The online version was very helpful in debugging the program and finding syntax errors that arose from the OCR process (Optical Character Recognition).

The other night, after yet again searching high and low in the house and on my old hard drives, I finally found a thin file folder tucked away behind other files:  “COMPUTER SCI” was written on it, and inside were two stapled-together printouts of the program.

Years ago I had laboriously transcribed DR. CHALLENGER line by line by loading it into the revived Challenger 1P from a cassette tape, displaying showing sections of it – the display technology of that computer could only show 25-by-25 characters at a time – and typing them into another computer.

It is amazing to be running this ancient program on modern tools, and fun to be editing and debugging it with such convenience, and cross platform. Running Dr. Challenger on my phone is just crazy: I never would have imagined I’d be doing that, almost 40 years later (2018 - 1979 = 39).

It was also fortunate that both of these apps - cbmHandBasic on the iPhone and AppleSoft BASIC in Javascript online at a website – allow one to upload a file and run it, because it would have taken way too long and be too cumbersome to try and type in the DR. CHALLENGER. The program is 430 lines long, and some lines have multiple statements.

The reason these interpreters will run my program is that they are both emulators of the same 6502-based BASIC, which is a BASIC interpreter written by Microsoft – Bill Gates and his friend Paul Allen did it themselves. In fact this is the earliest known software written by Microsoft, and has some funny sayings and comments, interesting historical comments, and sneaky Easter eggs in the code that Bill Gates put in there to try and catch anyone claiming it was their own product.

This BASIC was used in several of the very first personal computers, including the Commodore Pet (where I saw the ELIZA program running that inspired the creation of DR. CHALLENGER), the Apple II, and the Ohio Scientific (OSI) models (the computer I had).

Here is the source code:

 

25 REM X=FRE(X)
30 REM PRINT X; "BYTES FREE"
35 FOR T=0 TO 2000: NEXT
50 FOR C=0 TO 32: PRINT:NEXT C
100 PRINT "HELLO"
150 PRINT
200 PRINT "I'M DR. CHALLENGER,"
250 PRINT "YOUR ANALYST."
300 PRINT
400 PRINT "WHAT'S YOUR NAME?"
500 INPUT A$
700 IF A$="YOU SHOULD KNOW" THEN 900
750 GOTO 1000
900 PRINT
950 PRINT "HELLO ERIC": GOTO 1105
1000 PRINT
1100 PRINT "HELLO "; A$
1105 PRINT
1110 PRINT "HOW ARE YOU TODAY?"
1120 PRINT
1125 INPUT A$
1130 B$ =LEFT$(A$,4)
1140 IF B$="l AM" THEN 1160
1150 GOTO 1190
1160 B$ = MID$(A$,5,40)
1165 PRINT
1170 PRINT "YOU ARE "; B$;" ?"
1175 PRINT "ANYTHING YOU WANT"
1180 PRINT "TO DISCUSS?"
1185 GOTO 1280
1190 IF B$="IM G" THEN 1245
1195 IF B$="GOOD" THEN 1245
1200 IF B$=“IM F" THEN 1255
1210 IF B$="FINE" THEN THEN 1255
1220 IF B$="O.K." THEN 1245
1225 IF B$="OK" THEN 1245
1230 IF B$="GREA" THEN 1245
1240 GOTO 1265
1245 PRINT
1247 PRINT “THAT'S GOOD"
1250 PRINT "DO YOU HAVE ANYTHING"
1251 PRINT "YOU WANT TO DISCUSS?"
1253 GOTO 1280
1255 PRINT "
1257 PRINT "I'M GLAD YOUR"
1258 PRINT "FEELING FINE."
1259 PRINT "ANYTHING YOU WANT"
1260 PRINT "TO DISCUSS?"
1262 GOTO 1280
1265 PRINT
1270 PRINT "THAT'S TOO BAD"
1275 PRINT "WANT TO TALK"
1276 PRINT "ABOUT IT?"
1280 PRINT
1285 INPUT C$
1287 B$=" "
1289 D$=" "
1290 G$=B$+C$+D$
1292 F=1
1294 M=1
1296 D=LEN(G$)
1298 FOR T=F TO D
1300 D$=MID$(G$,T,T)
1302 E=ASC(D$)
1304 IF E=32 THEN 1308
1306 NEXT T
1308 IF T>1 THEN 1314
1310 F=T+1
1312 GOTO 1298
1314 F$=MID$(G$,M,T-M)
1315 M=T
1316 GOTO 1326
1318 IF T=D THEN 1400
1320 M=T
1322 F=T
1324 GOTO 1298
1326 IF F$=" YOU" THEN 20600
1328 IF F$=" YOUR" THEN 20900
1330 IF F$=" THE" THEN 2090
1332 IF F$=" COMPUTERS" THEN 21010
1333 IF F$=" COMPUTER" THEN 21010
1334 IF F$=" CRAZY" THEN 21020
1336 IF F$=" INSANE" THEN 21020
1338 IF F$=" PROBLEM" THEN 21035
1340 IF F$=" ALWAYS" THEN 15400
1342 IF F$=" NEVER" THEN 21050
1344 IF F$=" UNDERSTAND" THEN 21060
1346 IF F$=" BOTHERS" THEN 21070
1348 IF F$=" MAD" THEN 21080
1350 IF F$=" ANGRY" THEN 21090
1351 IF F$=" DISTURBED" THEN 21035
1352 IF F$=" LOVE" THEN 7900
1354 IF F$=" HATE" THEN 21100
1356 IF F$=" DEPRESSED" THEN 21114
1358 IF F$=" DOWN" THEN 21114
1360 IF F$=" HIM" THEN 21150
1362 IF F$=" HER" THEN 21160
1364 IF F$=" ANGER" 21090
1366 IF F$=" THEM" THEN 10600
1368 IF F$=" MY" THEN 21170
1370 IF T=D THEN 1395
1375 GOTO 1306
1395 D$=LEFT$(C$,7)
1400 D$=LEFT$(C$,6)
1450 IF D$="LIKE W" THEN 5300
1500 IF D$="I CANN" THEN 3800
1550 IF D$= "I DO N" THEN 4700
1600 D$=LEFT$(C$,5)
1700 IF D$="I NEE" THEN 5300
1800 IF D$="MAYBE" THEN 6600
1900 IF D$="PERHA" THEN 7100
2000 D$=LEFT$(C$,4)
2050 IF D$="THEY“ THEN 10600
2100 IF D$="I FE" THEN 7900
2150 IF D$="WHAT" THEN 19600
2200 IF D$="I AM" THEN 9000
2300 IF D$="I WA" THEN 9700
2400 D$=LEFT$(C$,3)
2450 IF D$="WHO" THEN 5300
2500 IF D$="YES" THEN 9900
2550 IF D$="TO “ THEN 19200
2600 IF D$="YOU" THEN 10100
2700 IF D$="THE" THEN 10300
2800 IF D$="WHY" THEN 10700
2900 IF D$="TOD" THEN 11300
2950 IF D$="BEC" THEN 13400
3000 D$=LEFT$(C$,2)
3100 IF D$="NO" THEN 4700
3200 IF D$="MY" THEN 11600
3300 IF D$="ME" THEN 11850
3400 IF D$="IM" THEN 9000
3500 IF D$="IT" THEN 12000
3550 IF D$="HE" THEN 12300
3600 IF D$="SH" THEN 12700
3700 GOTO 17400
3800 PRINT
3900 PRINT "WHY CANT YOU?"
4000 PRINT
4100 INPUT C$
4200 D$=LEFTS(C$,2)
4300 IF D$="BE" THEN 13400
4400 IF D$="FO" THEN 13900
4600 GOTO 1395
4700 PRINT
4800 PRINT "WHY NOT?"
4900 INPUT C$
5000 D$=LEFT$(C$,4)
5100 IF D$="IT B" THEN 16700
5200 GOTO 4300
5300 PRINT
5400 PRINT "IN THIS NEED"
5402 PRINT "NOT FULFILLED"
5500 INPUT C$
5600 D$=LEFT$(C$,3)
5700 IF D$="WHY" THEN 4700
5800 IF D$="I G" THEN 17000
5900 IF D$="I D" THEN 16300
6000 IF D$="SOM" THEN 17000
6200 D$=LEFT$(C$,2)
6300 IF D$="YE" THEN 13000
6400 IF D$="NO" THEN 16300
6500 GOTO 1280
6600 PRINT
6700 PRINT "MAYBE?"
6750 PRINT
6800 PRINT "TELL ME MORE"
6900 INPUT C$
7000 GOTO 1395
7100 PRINT
7200 PRINT "PERHAPS YOU NEED"
7250 PRINT "TO OPEN UP MORE "
7300 INPUT C$
7400 D$=LEFT$(C$,3)
7500 IF D$="PER" THEN 7700
7600 GOTO 1280
7700 PRINT
7750 PRINT "IS THAT ALL YOU"
7775 PRINT "CAN TELL ME?"
7800 GOTO 14650
7900 PRINT
7950 PRINT "GO WITH THAT FEELING"
8000 PRINT
8001 PRINT "HOW LONG HAVE YOU"
8050 PRINT "FELT THIS WAY?"
8100 INPUT C$
8200 D$=LEFT$(C$,3)
8300 IF D$="FOR" THEN 14800
8400 IF D$="SIN" THEN 9000
8500 IF D$="EVE" THEN 15500
8600 IF D$="WHY" THEN 4700
8700 IF D$="ALW" THEN 15500
8800 IF D$="ABO" THEN 7700
8900 GOTO 2900
9000 PRINT
9050 PRINT "EXPAND ON THAT?"
9075 PRINT "PLEASE ?""
9100 INPUT C$
9200 D$=LEFT$(C$,5)
9300 IF D$=" IT ST" THEN 7950
9400 IF D$=" IT BE" THEN 14800
9500 IF D$=" IT AL" THEN 14800
9550 PRINT
9600 GOTO 1395
9700 PRINT
9750 PRINT "WHY DO YOU WANT THAT?"
9800 INPUT C$
9810 D$=LEFT$(C$,2)
9820 IF D$="BE" THEN 13400
9830 IF D$="IT" THEN 12000
9850 IF D$="FO" THEN 14600
9885 GOTO 9000
9900 PRINT
9950 PRINT "WHAT?"
10000 PRINT: GOTO 1280
10100 PRINT: PRINT "WHAT ABOUT ME?"
10150 INPUT C$
10175 D$=LEFT$(C$,3)
10180 IF D$="YOU" THEN 8000
10190 IF D$="YES" THEN 1275
10195 PRINT
10196 PRINT "TELL ME MORE"
10200 GOTO 1280
10300 PRINT
10400 PRINT "WHAT ABOUT ";C$;"?"
10500 GOTO 1280
10600 PRINT
10650 PRINT "DO THEY THREATEN YOU?"
10675 GOTO 10900
10700 PRINT
10750 PRINT "BECAUSE I'M YOUR"
10800 PRINT "ANALYST. DO I"
10825 PRINT "THREATEN YOU?"
10900 INPUT C$
10950 D$=LEFT$(C$,2)
11000 IF D$="YE" THEN 10100
11050 IF D$="NO" THEN 11200
11100 GOTO 1280
11200 PRINT
11250 PRINT "GOOD": GOTO 1275
11300 PRINT
11350 PRINT "IS TODAY THE"
11375 PRINT "FIRST TIME?"
11400 INPUT C$
11450 IF C$="NO" THEN 7900
11500 IF C$="YES" THEN 13900
11600 PRINT
11650 E$=MID$(C$,3,40)
11700 PRINT
11750 PRINT "TELL ME MORE ABOUT"
11751 PRINT "YOUR";E$;""
11800 GOTO 1280
11850 PRINT
11900 PRINT "WHAT ABOUT YOU?"
11950 GOTO 1280
12000 PRINT
12100 PRINT "THEN WHY DON’T"
12110 PRINT "YOU DO SOMETHING"
12115 PRINT "ABOUT IT?"
12130 INPUT C$
12150 IF C$="LIKE WHAT" THEN 19000
12155 IF C$="WHAT" THEN 19000
12250 GOTO 1395
12300 PRINT
12325 PRINT "DOES HE UNDERSTAND?"
12330 PRINT "THIS?"
12375 INPUT C$
12400 IF C$="YES" THEN 7900
12500 IF C$="NO" THEN 7100
12600 GOTO 1280
12700 PRINT
12750 PRINT "DOES SHE KNOW"
12800 PRINT "HOW YOU FEEL?"
12900 GOTO 12400
13000 PRINT
13100 PRINT "CAN I HELP YOU"
13200 PRINT "WITH THAT?"
13210 INPUT C$
13220 IF C$="YES" THEN 18400
13300 GOTO 1395
13400 PRINT
13450 PRINT "IS THAT THE ONLY"
13500 PRINT "ONLY REASON?"
13600 INPUT C$
13700 IF C$="YES" THEN 13900
13800 IF C$="NO" THEN 14425
13850 GOTO 5800
13900 PRINT
13950 PRINT "IS THAT WHY YOU"
13975 PRINT "CAME TO ME?"
14400 INPUT C$
14410 IF C$="YES" THEN 18100
14412 IF C$="NO" THEN 18700
14420 GOTO 14600
14425 PRINT
14450 PRINT "WHAT ELSE?"
14500 GOTO 1280
14600 PRINT
14650 PRINT "OH?"
14700 GOTO 1280
14800 PRINT
14850 PRINT "WERE YOU LIKE THIS"
14900 PRINT "WHEN YOU WERE A CHILD?"
15000 INPUT C$
15100 IF C$="YES" THEN 15400
15200 IF C$="NO" THEN 8000
15300 GOTO 1280
15400 PRINT
15450 PRINT "I'M SORRY TO"
15451 PRINT "HEAR THAT"
15500 PRINT
15600 PRINT "IS THAT TOO LONG?"
15700 GOTO 6750
15800 PRINT
15900 PRINT "IS THAT A PROBLEM?"
16000 INPUT C$
16100 IF C$="YES" THEN 13900
16200 IF C$="NO" THEN 14800
16300 PRINT
16400 PRINT "THEN WHY DID YOU"
16500 PRINT "BRING IT UP?"
16600 GOTO 1280
16700 PRINT
16710 PRINT "THAT'S NO EXCUSE"
16800 PRINT "IS IT?"
16900 GOTO 1280
17000 PRINT
17200 GOTO 1280
17300 PRINT "YOU BLEW IT"
17400 PRINT
17500 PRINT "DO YOU THINK"
17550 PRINT "THAT'S GOOD?"
17600 INPUT C$
17700 IF C$="YES" THEN 16300
17800 IF C$="NO" THEN 15800
17900 IF C$="WHY" THEN 10700
18000 GOTO 20000
18100 PRINT
18200 PRINT "NOW WE'RE GETTING"
18300 PRINT "SOMEWHERE"
18400 PRINT
18500 PRINT "DESCRIBE YOUR FEELINGS"
18600 GOTO 1280
18700 PRINT
18800 PRINT "THEN WHY?"
18900 GOTO 1280
19000 PRINT
19100 PRINT "LIKE DISCUSS IT"
19105 PRINT "WITH SOMEONE"
19150 GOTO 1280
19200 PRINT
19300 PRINT "DOES THAT HELP?"
19350 INPUT C$
19400 IF C$ = "YES" THEN 18100
19500 GOTO 1395
19600 PRINT
19650 PRINT "IS IT IMPORTANT?"
19700 INPUT C$
19750 IF C$="YES“ THEN 19900
19775 IF C$="NO“ THEN 16300
19800 GOTO 1395
19900 PRINT:PRINT "WHY?": GOTO 1280
20000 PRINT
20100 PRINT "DO YOU THINK THAT'S"
20125 PRINT "A PROPER ANSWER"
20150 INPUT C$
20200 IF C$ = "YES" THEN 16700
20250 IF C$ = "NO" THEN 14600
20275 PRINT
20300 PRINT "CAN YOU BE MORE DEFINITE?"
20500 GOTO 1280
20600 PRINT
20700 PRINT "ME? WHY?"
20800 GOTO 1280
20900 H$=MID$(G$, T, D)
20950 PRINT
20975 PRINT "WHAT ABOUT MY";H$
20980 GOTO 1280
20990 H$=MID$(G$, T, D)
20995 PRINT
20996 PRINT "TELL ME MORE"
20997 PRINT "ABOUT THE";H$
21000 GOTO 1280
21010 PRINT
21011 PRINT "DON'T KNOCK COMPUTERS-"
21010 PRINT "THEY'RE THE BEST THING"
21011 PRINT "THAT EVER HAPPENED TO"
21012 PRINT "YOU HUMANS."
21013 GOTO 1285
21020 PRINT
21021 PRINT "WE SAY DISTURBED"
21022 PRINT "IN MY BUSINESS"
21030 GOTO 1280
21035 PRINT
21036 PRINT "THAT'S WHAT WE'RE"
21037 PRINT "HERE FOR. GO ON."
21040 GOTO 1280
21050 PRINT
21051 PRINT "NEVER SAY NEVER"
21055 GOTO 1280
21060 PRINT
21065 PRINT "I UNDERSTAND"
21067 G0T0 1285
21070 PRINT
21071 PRINT "DON'T LET IT BOTHER YOU"
21075 GOTO 1280
21080 PRINT
21081 PRINT "MAD? DESCRIBE THIS?"
21085 GOTO 1280
21090 PRINT
21091 PRINT "DESCRIBE THIS ANGER?"
21095 GOTO 1280
21100 PRINT
21101 PRINT "ARE THESE YOUR"
21105 PRINT "TRUE FEELINGS?"
21110 GOTO 1280
21114 PRINT
21115 PRINT "WHEN DID YOU START"
21125 PRINT "FEELING DEPRESSED?"
21130 GOTO 1280
21150 PRINT
21151 PRINT "IS HE RESPONSIBLE ?"
21155 GOTO 1280
21160 PRINT
21161 PRINT "IS SHE RESPONSIBLE?"
21165 GOTO 1280
21170 H$=MID$(G$,T,D)
21175 PRINT
21180 PRINT "TELL ME MORE"
21190 PRINT "ABOUT YOUR";H$
21200 G0T0 1285

Posted in ,

meestereric

Leave a Comment