5 REM http://vintage-basic.net/bcg/animal.bas
10 PRINT TAB(32);"ANIMAL"
20 PRINT TAB(15);"CREATIVE COMPUTING  MORRISTOWN, NEW JERSEY"
30 PRINT: PRINT: PRINT
40 PRINT "PLAY 'GUESS THE ANIMAL'"
45 PRINT
50 PRINT "THINK OF AN ANIMAL AND THE COMPUTER WILL TRY TO GUESS IT."
60 PRINT
70 @(0) = 4
80 @(1) = DUP("\QDoes it swim\Y2\N3\")
90 @(2) = DUP("\Afish")
100 @(3) = DUP("\Abird")
110 N=@(0)
120 REM          MAIN CONTROL SECTION
130 A = ASK("ARE YOU THINKING OF AN ANIMAL? ")
140 IF COMP(A, "list")=0 THEN 600
150 IF PEEK(A, 0) # ORD("y") THEN 120
160 K=1
170 GOSUB 390
180 IF LEN(@(K)) = 0 THEN 999
190 IF COMP(CLIP(@(K), LEN(@(K))-2), "\Q") = 0 THEN 170
200 PRINT "Is it a ";SHOW(CHOP(@(K),2));
210 A = ASK("? ")
230 IF PEEK(A,0)=ORD("y") THEN PRINT : PRINT "WHY NOT TRY ANOTHER ANIMAL?": GOTO 120
240 V = ASK("The animal you were thinking of was a ")
250 PRINT "Please type in a question that would distinguish a ";
260 PRINT SHOW(V);" from a ";SHOW(CHOP(@(K),2));
270 X = ASK("? ")
280 PRINT "For a ";SHOW(V);
290 A=ASK(" the answer would be ")
300 IF ((PEEK(A,0) # ORD("y")) * (PEEK(A,0) # ORD("n"))) + (LEN(A) > 1) THEN 280
310 IF PEEK(A,0) = ORD("y") THEN B=DUP("n")
320 IF PEEK(A,0) = ORD("n") THEN B=DUP("y")
330 Z=@(0)
340 @(0)=Z+2
350 @(Z)=@(K)
360 @(Z+1)=JOIN("\A", V)
370 @(K)=JOIN("\Q", X, "\", A, STR(Z+1), "\", B, STR(Z), "\")
380 GOTO 120
390 REM     SUBROUTINE TO PRINT QUESTIONS
400 Q=@(K)
410 FOR Z=2 TO LEN(Q)-1
415 IF PEEK(Q,Z) = ORD("\") THEN C=ASK("? ") : UNLOOP : GOTO 440
420 PRINT CHR(PEEK(Q,Z));
430 NEXT Z
440 IF ((PEEK(C,0) # ORD("y")) * (PEEK(C,0) # ORD("n"))) + (LEN(C) > 1) THEN 410
450 T=JOIN("\",C)
455 FOR X=2 TO LEN(Q)-2
460 IF COMP(CLIP(CHOP(Q,X),LEN(Q)-X-2),T) = 0 THEN UNLOOP: GOTO 480
470 NEXT X
475 STOP
480 FOR Y=X+1 TO LEN(Q) - 1
490 IF PEEK(Q,Y)= ORD("\") THEN UNLOOP: GOTO 510
500 NEXT Y
505 STOP
510 K=VAL(CLIP(CHOP(Q,X+2),LEN(Q)-Y))
520 RETURN
600 PRINT:PRINT "ANIMALS I ALREADY KNOW ARE:"
605 X=0
610 FOR I=1 TO 200
615 IF (@(I)<0)=0 THEN GOTO 650
620 IF COMP(CLIP(@(I),LEN(@(I))-2), "\A") THEN 650
624 PRINT TAB(15*X);
630 FOR Z=2 TO LEN(@(I))-1
640 IF PEEK(@(I),Z) # ORD("\") THEN PRINT CHR(PEEK(@(I),Z));
645 NEXT Z: X=X+1: IF X=4 THEN X=0: PRINT
650 NEXT I
660 PRINT
670 PRINT
680 GOTO 120
999 END


