Compucolor.org – Virtual Media

Listing of file='ASKME.BAS;01' on disk='vmedia/chip_24-sector.ccvf'

100 REM ---FILE NAME "ASKME"; W. RUST, APRIL 1979
200 REM ---HOUSEKEEPING
210 CLEAR 200
220 DIM K$(6,6),P$(40),T$(5),V$(10)
230 DIM KI(5),KJ(5),PF(5),W$(12)
300 REM ---DISPLAY INSTRUCTIONS
310 PLOT 27,24,14,6,6,12,3,25,0:PRINT "> ASK ME <"
320 PLOT 15,6,5,3,10,3
330 PRINT "A DEMONSTRATION OF COMPUTER INTELLIGENCE"
340 PRINT :PRINT :PLOT 6,3
350 PRINT "YOU WILL ASK QUESTIONS FOR THE COMPUTER TO ANSWER."
360 PRINT "THERE WILL BE A LIST OF TOPICS TO TALK ABOUT."
370 PRINT :PLOT 6,7
380 PRINT "DO NOT USE PLURAL NOUNS.  KEEP WORDING SIMPLE."
390 PRINT
400 PRINT "USE PUNCTUATION ONLY AT THE END OF YOUR QUESTIONS."
410 PRINT
420 PRINT "TO END THE PROGRAM, TYPE 'STOP'."
460 PRINT :PLOT 6,2
461 PRINT "EXAMPLES OF SUITABLE QUESTIONS:":PRINT
462 PRINT "  HOW BIG IS A BRICK?"
463 PRINT "  WHAT DOES A SNOWBALL TASTE LIKE?"
464 PRINT "  WHAT COLOR IS A DOLLAR BILL?"
465 PRINT "  TELL ME ABOUT A CAT."
466 PRINT "  IS A LEMON RED?"
480 PRINT :PLOT 6,5
481 PRINT "HIT 'RETURN' TO CONTINUE!  ";:INPUT Q$
500 REM ---READ KEYWORDS INTO ARRAY
505 RESTORE
510 DATA CHERRY,LEMON,BRICK,SNOWBALL,DOLLAR,CAT
512 DATA RED,YELLOW,BROWN,WHITE,GREEN,BLACK
514 DATA "2 CM","6 CM","6 X 9 X 20 CM","8 CM","6 X 15 CM"
515 DATA "30 CM TALL AND 10 CM WIDE"
516 DATA 4G,110G,2400G,250G,1G,1500G
518 DATA TART,BITTER,SCRATCHY,COLD,FLAT,FUZZY
520 DATA FOOD,FLAVOR,CONSTRUCTION,"HITTING SCHOOL TEACHERS"
521 DATA "ABOUT 13 CENTS","CATCHING MICE"
550 FOR I= 0TO 5
551 FOR J= 0TO 5
552 READ K$(I,J):NEXT J:NEXT I
600 REM ---READ POINTERS INTO ARRAY
605 RESTORE 610:REM  1ST CHAR IS POINTER INDEX
610 DATA 0NAME,0OBJECT,0ITEM,0THING
612 DATA 1COLOR,1HUE
614 DATA 2SIZE,2DIAMETER,2DIMENSION,2LONG,2LENGTH,2WIDE
615 DATA 2WIDTH,2HEIGHT,2BIG,2LARGE,2TALL
616 DATA 3WEIGH,3WEIGHS,3WEIGHT,3MASS,3HEAVY
618 DATA 4TASTE,4TASTES,4FLAVOR
620 DATA 5USE,5USED,5PURPOSE,5VALUE,5FUNCTION,5GOOD,5WORTH
621 DATA 5USEFUL
640 H= 32:REM  POINTERS-1
650 FOR N= 0TO H:READ P$(N):NEXT N
660 REM ---READ VERIFIERS INTO ARRAY
665 RESTORE 670
670 DATA IS,ARE,WAS,WERE,DO,DOES,WILL,CAN
675 FOR N= 0TO 7:READ V$(N):NEXT N
680 REM ---READ TRIVIAL WORDS INTO ARRAY
685 RESTORE 690
690 DATA A,AN,THE,OF
695 FOR N= 0TO 3:READ T$(N):NEXT N
700 REM ---CREATE WORKING DISPLAY
710 PLOT 27,24,15,6,2,12,8
720 PRINT "OBJECTS FOR DISCUSSION:"
725 PRINT :PLOT 6,6
730 PRINT "  CHERRY, LEMON, BRICK, SNOWBALL, DOLLAR, CAT"
735 PRINT :PLOT 6,2
740 PRINT "CHARACTERISTICS (USE THESE WORDS, OR SYNONYMS):"
745 PRINT :PLOT 6,6
750 PRINT "  COLOR, SIZE, WEIGHT, TASTE, PURPOSE OR VALUE"
760 PLOT 14,6,5,3,0,14
770 PRINT "WHAT IS YOUR QUESTION?"
800 REM ---INPUT QUESTION
805 FOR N= 0TO 12:W$(N)= "":NEXT N
810 PLOT 6,3,3,0,16,11
820 INPUT "> ";Q$
830 IF LEFT$ (Q$,4)= "STOP"GOTO 5000
840 L1= LEN (Q$):IF L1< 3GOTO 800
850 REM ---REMOVE PUNC. AT END
860 C2= ASC (RIGHT$ (Q$,1)):IF C2> 64AND C2< 91GOTO 880
870 Q$= LEFT$ (Q$,L1- 1):GOTO 840
880 REM ---PICK OUT & COUNT WORDS
890 Q$= Q$+ " ":L1= LEN (Q$)
900 E1= 1:NW= 1
910 FOR X= 1TO L1
920 C1= ASC (MID$ (Q$,X,1)):IF C1= 32GOTO 940
930 GOTO 970
940 W$(NW)= MID$ (Q$,E1,X- E1)
950 IF X= L1GOTO 1000
960 E1= X+ 1:NW= NW+ 1
970 NEXT X
1000 REM ---TEST 1ST WORD
1010 F1= 0
1020 FOR N= 0TO 7:IF W$(1)= V$(N)THEN F1= 1
1025 NEXT N
1030 REM  IF FLAG F1=1 THEN ANSWER WILL BE YES OR NO
1040 REM ---TEST EACH WORD; SAVE KEYWORD & POINTER INFO
1050 NK= 0:NP= 0
1055 FOR W= 1TO NW
1060 REM ---TRIVIAL WORD?
1070 FOR T= 0TO 3
1080 IF W$(W)= T$(T)GOTO 1950
1090 NEXT T
1100 REM ---KEYWORD?
1110 FOR I= 0TO 5
1120 FOR J= 0TO 5
1130 IF W$(W)= K$(I,J)GOTO 1160
1140 NEXT J
1150 NEXT I:GOTO 1200
1160 NK= NK+ 1
1170 KI(NK)= I:KJ(NK)= J:REM  SAVE INDICES
1180 GOTO 1900
1200 REM ---POINTER WORD?
1210 FOR P= 0TO H
1220 PI= VAL (LEFT$ (P$(P),1)):REM  INDEX PORTION
1230 L= LEN (P$(P))
1240 P$= RIGHT$ (P$(P),L- 1):REM  POINTER PORTION
1250 IF W$(W)= P$GOTO 1300
1260 NEXT P:GOTO 1900
1300 NP= NP+ 1
1310 PF(NP)= PI:REM  SAVE INDEX
1900 REM ---JUMP OUT IF NP OR NK TOO BIG
1910 IF NP> 2OR NK> 2GOTO 2600
1950 NEXT W
2000 REM ---CHOOSE ANSWER TYPE
2020 ON NK+ 3* NP+ 1GOTO 2100,2300,2400,2100,2200,2400,2100,2500,2600,2100
2030 GOTO 2600
2100 REM ---ANS A
2110 A$= "SORRY, I CAN'T ANSWER THAT.  PLEASE TRY AGAIN."
2120 GOTO 3000
2200 REM ---ANS B
2210 A$= K$(PF(1),KJ(1))
2220 IF PF(1)= KI(1)THEN A$= K$(0,KJ(1))
2230 GOTO 3000
2300 REM ---ANS C
2310 IF KI(1)= 0GOTO 2330
2320 A$= K$(0,KJ(1)):GOTO 3000
2330 A$= "IT IS "+ K$(1,KJ(1))+ " AND "+ K$(4,KJ(1))
2340 GOTO 3000
2400 REM ---ANS D
2410 IF F1= 0GOTO 2600
2420 A$= "NO"
2430 IF KJ(1)= KJ(2)THEN A$= "YES"
2440 GOTO 3000
2500 REM ---ANS E
2510 IF PF(1)= PF(2)GOTO 2540
2520 A$= K$(PF(1),KJ(1))+ " AND "+ K$(PF(2),KJ(1))
2530 GOTO 3000
2540 A$= K$(PF(1),KJ(1)):GOTO 3000
2600 REM ---ANS F
2610 A$= "SORRY, YOUR QUESTION IS TOO COMPLICATED FOR ME."
2620 GOTO 3000
3000 REM ---PRINT ANSWER
3010 PLOT 6,7
3020 PRINT SPC( 3);A$
3050 PLOT 15,6,1
3060 PRINT "TO CONTINUE, HIT 'RETURN'.  ";
3070 INPUT Q$
3080 REM ---ERASE FIELD
3090 PLOT 14:FOR Y= 16TO 31:PLOT 3,0,Y,11:NEXT Y
3100 GOTO 800
5000 PLOT 15,27,11,6,6
5010 END
6000 REM ---LIST PGM ON PRINTER AT 300 BAUD
6010 PLOT 14,27,18,3,15,27,13:LIST :PRINT :POKE 33265,0:END
9999 END