Copyright © 2010
Yohanes Nugroho
10 REM ANIMAL VEGETABLE MINERAL 20 REM Written by A.Sill 30 REM FOR WROX PRESS 40 REM (c) 1992 50 REM 60 DIM AVG$(5000) 70 CLS 80 A$ = "ANIMAL VEGETABLE MINERAL" 100 PRINT A$ 120 PRINT: PRINT " Animal Vegetable Mineral is probably one of the simplest and earliest programs": PRINT "to feature artificial intelligence. It asks you questions about an animal, vegetable" 130 PRINT "or a mineral which you have thought of. It then learns as the program continues -": PRINT "a feat not matched very often. The program is VERY simple, and very short, and is a" 135 PRINT "great example of the use and power of arrays." 140 PRINT " Press Q to quit at a (Y)es or (N)o prompt." 150 RAND = 0 160 PRINT: INPUT "Press any key "; A$ 190 RAND = RAND - VAL(RIGHT$(TIME$, 2)) 210 REM 220 N = 1: B = 1 230 AVG$(1) = "a carrot" 240 CLS 250 PRINT "Think of an Animal, Vegetable or a Mineral "; 260 FOR A = 1 TO 2000: IF (A / 400) = INT(A / 400) THEN PRINT "."; 270 NEXT A 280 IF AVG$(2 * N) <> "" THEN GOTO 430 290 PRINT : PRINT "Is it "; AVG$(N); " ?" 300 INPUT " (Y)es or (N)o ? "; A$ 320 IF A$ = "Y" Or A$="y" THEN GOTO 355 330 IF A$ = "Q" Or A$="q" THEN GOTO 520 340 IF A$ = "N" Or A$="n" THEN GOTO 360 350 GOTO 300 355 PRINT : PRINT " Phew - I got one right for once !": PRINT 357 GOTO 250 360 AVG$(2 * N) = AVG$(N) 370 PRINT : INPUT "Then what is it "; G$ 380 AVG$(2 * N + 1) = G$ 390 PRINT : PRINT "Give me a question that would be true for "; 400 PRINT AVG$(2 * N + 1); ", but false for "; AVG$(2 * N) 410 PRINT : INPUT " : "; AVG$(N) 420 GOTO 240 430 PRINT : PRINT AVG$(N); 440 INPUT " (Y)es or (N)o ? "; B$ 460 IF B$ = "Q" OR B$ = "q" THEN GOTO 520 470 IF B$ = "Y" OR B$ = "y" OR B$ = "N" OR B$ = "n" THEN GOTO 480 475 GOTO 440 480 N = 2 * N + ABS(B$ = "Y" OR B$ = "y") 490 GOTO 280