A Conversation With My 35-year-old Chatbot (Part 2 — Technical Details)

Cathy Pearl
4 min readJul 29, 2019

In Part 1, I introduced the chatbot I programmed when I was 12, on my Commodore 64. It includes a video demo of the chatbot in action.

This post is all about the technical side of things: how the program worked, and how I was able to run it, 35 years later.

Code Breakdown

The Conversation program itself is only 36 lines of code. The rest is composed of DATA statements, where the query / responses are stored. Here’s the whole program (minus the DATA statements):

10 rem ** conversation **
20 poke53281,1:poke53280,6:print””
30 dl= 1342
40 f=1000:diman$(f),bn$(f),cn$(f),dn$(f)
50 print””:goto120
60 print””chr$(147)dl”data”cz$;a$;cz$”,”cz$;b$;cz$
70 printdl+1"data”cz$;c$;cz$”,”cz$;e$;cz$
80 print”30 dl=”;dl+2
90 print”run30"
100 poke631,19:poke632,13:poke633,13:poke634,13:poke635,13
110 poke198,6:end
120 print:print”? “;:gosub470:a$=in$:ifa$=””thena$=x$:print”? “;a$
130 ifa$=”quit”then410
140 ifa$=”clear”thenprint””;:goto120
300 restore:x$=a$:fori=1to(dl/2)-499.5
310 readan$(i),bn$(i),cn$(i),dn$(i)
320 ifa$=an$(i)then420
330 nexti
340 print:print”i don’t understand.”
350 print”please enter three answers at the”:print”prompt:”
360 print”1: “;:gosub470:ifin$=””then120
370 b$=in$
380 print”2: “;:gosub470:c$=in$
390 print”3: “;:gosub470:e$=in$
400 cz$=chr$(34):goto60
410 open 15,8,15: print#15,”s0:conversation”:close15:save”0:conversation”,8:end
420 x=int(rnd(1)*3)+1:print
430 onxgoto440,450,460
440 print””;bn$(i):goto120
450 print””;cn$(i):goto120
460 print””;dn$(i):goto120
470 in$=””:il=255
480 print”-”;
490 geti$:ifi$=””then490
500 print” “;:in=asc(i$):ifin=13thenprint:return
510 ifin=20andlen(in$)thenin$=left$(in$,len(in$)-1):printi$;:goto480
520 if(inand127)❤2orlen(in$)=ilthen480
530 printi$;:poke212,0:in$=in$+i$:goto480

Line 20 sets the screen and border colors. Line 30 keeps track of what line of code to start at for the next new DATA statement.

Line 120 prints the opening “?” and gets the user input.

Lines 300–320 begin reading in the responses in the DATA statements, and compares whether the user input matches; if yes, it goes to line 420, which chooses one of the three responses at random, and prints it.

If nothing matches, lines 340–400 ask the user for the new responses, then goes to line 60 to add them to the code.

Lines 60–70 print the new DATA statement with responses the user has added, then modifies line 30 with the new next line number to start with.

Here are some of the DATA statements:

1000 data"hi","hello!"
1001 data"hi there!","good evening!"
1002 data"how are you?","fine! and you?"
1003 data"great.. i think.","fine, if you like being me, which i don't."

The user string, plus three possible responses, are stored across two lines of code. In this example,“hi” is the string a user might type in, followed by three possible responses (“hello!”, “hi there”, and “good evening”). The next user string is “how are you?” followed by its three possible responses. I had about 170 possible user responses programmed in.

That’s it!

Running the Code on a PC in 2019

I used to have a lot of Commodore 64s. I had the one from my childhood, plus a bunch of them given to me by people who knew I had an interest. My husband began to ask me if we were going to be opening our own Computer History Museum.

In 2007, I finally managed to transfer all my old files to my PC, and get rid of all of the original hardware. I used an X1541 cable that I bought from a guy in Hungary. It connected the Commodore’s disk drive to my PC’s serial port, and I was able to copy all my disks.

Recently I started to wonder about the chatbot I’d written all those years ago. I installed the C64 Forever emulator, which allowed me to load in those disk images…and run them! One of fun things about the emulator is that it simulates the sound of the disk drive as the files are loading.

Now I was able to run the chatbot. But how could I look at the code? I could type LIST in the emulator and watch a screenful of code at a time, but there was no way to export it. To make it a readable text file, I used DirMaster, which lets you load in a program from the disk file, and convert it into ASCII.

Now I could examine the data statements and peer into my teenage brain. I could also break down the mechanics of the code.

I hope you’ve enjoyed this little trip down nostalgia lane with me, especially if you were a Commodore programmer. Those early days of learning BASIC lit a fire in me, and though I didn’t know it at the time, led to a career teaching computers how to talk.

Video of the chatbot in action, in 2019!

Cathy Pearl is the author of the book “Designing Voice User Interfaces: Principles of Conversational Experiences” from O’Reilly Media, and is head of conversation design outreach at Google. She’s been working on voice user interfaces for 20 years, but is still waiting for her computer to be able to have a chat about life, the universe, and everything.



Cathy Pearl

UX Lead on Google Gemini. Author of "Designing Voice User Interfaces" from O'Reilly (More at https://cathypearl.com)