Artificial Intelligence for the ZX-81

Author(s): Gene G. Buza
Publication: Synchro-Sette
Pub Details: Synchro-Sette v1 n2 (Volume 1, Issue 2)
Date: May 1982
Pages: 4-5
Cartoon of a man talking with a computer
Cartoon of a man talking with a computer

You may have heard of some of the programs that make computers give seemingly intelligent or human-like response.

The ELIZA or DR. CHIPS programs for other microcomputers simulate a doctor psychoanalyzing a patient. These programs are so human-like as to confuse actual doctors when they are asked to tell them apart from their human counterparts.

In order for a computer to engage in an intelligent conversation with its user, it uses basically 2 different types of algorithms (computer formula routines).

The first type is a KEYWORD SEARCH algorithm that looks at the sentence the user typed in, checks it for proper sentence structure and then identifies key words or phrases in that sentence in much the same way that the 1K program INSTRING (APR-82 cassette) can single out words.

Upon finding a key word or phrase, it the cross-references this information to the second algorithm type, the RANDOM RESPONSE GENERATOR. This algoritm gives a response sentence, sometimes interjecting words from the user’s sentence or past sentences. This response sentence may be one of three or more response sentence shells (missing key words) picked by the computer program at random. This is done so that the simulated conversation does not easily become repetitive.

The following program, instead of giving intelligent sentences, can generate up to 625 nonsensical messages using a total of 21 words or phrases using the programming techniques outlined in the READ, DATA & RESTORE article of APRIL, 1982.

Change the DATA lines if you wish to create your own messages or add additional DATA to give a larger assortment of sentences (don’t forget to increase the RND routines).

16K RAM Required:

 10 LET M = 1
20 LET A = 0
30 SCROLL
40 RAND 0
99 REM * SENTENCE SUBJECT *
100 LET A$ = "SUPERMAN,MICKEY
MOUSE,DICK TRACY,DARTH
VADER,PORKY PIG,"
110 LET E$ = A$
120 GOSUB 1000
199 REM * VERB OR PHRASE *
200 LET B$ = "SPITS ALL OVER,
HATES,KISSES,SITS ON,
DROPS,"
210 LET E$ = B$
220 GOSUB 1000
299 REM * OBJECT OR PHRASE *
300 LET C$ = "GIRLFRIEND,DOG,
COMPUTER, TOENAILS,
FOOTBALL,"
310 PRINT "HIS "
320 SCROLL
330 LET E$ = C$
340 GOSUB 1000
399 REM * PREDICATE *
400 LET D$ = "WHILE DRINKING
BEER.,LIKE A MANIAC.,AND
ENJOYS IT.,BUT IS SORRY
LATER.,WITH A VENGEANCE.,"
410 LET E$=D$
420 GOSUB 1000
430 SCROLL
439 REM * RESEED RANDOM GEN-
ERATOR ROUTINE *

ED note – if this is not done, the messages become repetitious – changing (RND*100) in line 440 to a lower number, increases the chance of repeat messages. This and the routine in lines 1010 to 1030 reseed the random generator as RAND does not work well enough alone. Try the progam by eliminating these lines and see what happens.

440 IF INT (RND*100)<>5 THEN
GOTO440
450 RUN
999 REM * RANDOM GENERATOR *
1000 RAND
1010 FOR I = 1 TO INT (RND*10)
1020 LET X = (RND*65535)
1030 NEXT I
1039 REM * PICK RANDOM DATA *
1040 LET X = INT (RND*5) + 1
1050 FOR N = 1 TO LEN E$
1060 IF E$(N) = "," THEN GOTO
2000
1070 NEXT N
1080 RETURN
1999 REM * FIND SEPARATOR *
2000 LET A = A + 1
2010 IF A = X THEN GOTO 3000
2020 LET M = N + 1
2030 GOTO1070
2999 REM * FIND RANDOM DATA *
3000 PRINT E$(M TO N - 1);" ";
3010 LET A = 0
3020 LET M = 1
3030 GOTO 1080

End the program by pressing the BREAK key.

Cartoon: "According to this Synohro-Sette program, we only have enough money to make 3 more payments on this thing!"
Cartoon: "According to this Synohro-Sette program, we only have enough money to make 3 more payments on this thing!"

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.