The Best of Creative Computing Volume 1 (published 1976)

Page 232 << PREVIOUS >> NEXT Jump to page:
Go to contents Go to thumbnails

Computer-Based Experiments in Cognitive Psychology (BASIC program code for Neisser's Visual Search and Pandemonium)

graphic of page

PROGRAM LISTING
0 REM NEISSER'S VISUAL SEARCH AND PANDEMONIUM
2
4 RANDOMIZE
6 
8 REM D$ CONTAINS THE LETTERS A-Z
10 DIM D$(26)
12 REM B HOLDS 3 FEATURE-EXTRACTION LEVELS FOR 26 LETTERS
14 DIM B(26,3)
16 REM FOR EACH OF 20 TRIALS, 0 TELLS WHICH OF THE 50 SETS
18 REM OF SIX CHARACTERS HOLDS THE ANOMALY
22 DIM L$(5),L(5),R(5)
24 REM A$ AND R$ HOLD THE ANGULAR AND THE ROUND CONTEXT LETTERS
26 DIM A$(6),R$(6)
28 REM C$ AND C HOLD THE CONTEXT CHARACTERS ACTUALLY USED
30 DIM C$(6),C(6)
32 REM E$ AND E HOLD A SET OF SIX LETTERS TO BE PRINTED
34 DIM E$(6),E(6)
36 DIM T$(11),T(11),U(11)
38 REM V(I) IS THE NUMBER OF LEVELS TAKEN TO RECOGNIZE THE I'TH LETTER
40 DIM V(26)
42
44 REM FOR THE L, C, AND E ARRAYS, THE STRING ARRAY HOLDS THE 
46 REM ACTUAL LETTER, WHILE THE NUMERIC ARRAY HOLDS ITS
48 REM POSITION IN THE ALPHABET
50
60 REM FNT FINDS THE TIME OF DAY IN SECONDS. NOTE, THIS
62 REM FUNCTION WILL PROBABLY VARY FROM COMPUTER TO COMPUTER.

64 REM IN MANY VERSIONS OF BASIC. IT MAY BE DEFINED AS:

66 REM DEF FNT=TIME(0)
68 DEF FNA(X)=INT(X*RND+1)
70 DEF FNT
72 LET C$=CLX$
74 LET FNT=3600*VAL(SEG$(C$,1,2)) 
76 LET FNT=FNT+60*VAL(SEG$(C$,4,5))+VAL(SEG$(C$,7,8))
78 FNEND
80
82
100 FOR M=1 TO 26
110 READ D$(M)
120 NEXT M
130 FOR M=1 TO 26
140 FOR M1=1 TO 3
150 READ B(M,M1)
160 NEXT M1
170 NEXT M
180 FOR M=1 TO 6
190 READ A$(M)
200 NEXT M
210 FOR M=1 TO +
220 READ R$(M)
230 NEXT M
240 PRINT " TYPE 1 FOR A SIMULATION, 2 TO TEST SUBJECT AND SIMULATE";
250 INPUT Z4
260 IF Z=1 THEN 340
270 LET Z4=0
280 
290 REM WHEN THE FOLLOWING ROUTINE IS FINISHED, T9 WILL CONTAIN
300 REM THE NUMBER OF TARGET LETTERS, THE L$ ARRAY WILL CONTAIN THE
310 REM LETTERS, AND THE L ARRAY WILL CONTAIN THE LETTERS'

320 REM ALPHABET POSITIONS
330 
340 PRINT
350 PRINT  "TARGET: TYPE 1 FOR Q, 2 FOR Z, 3 FOR Q OR Z."

360 PRINT " OR 4 IF YOU WISH TO INPUT YOUR OWN";
370 INPUT T
380 IR T>G THEN 35
390 ON T GOTO 550,590,630,400
400 PRINT 
410 PRINT " HOW MANY DIFFERENT TARGET LETTERS";
420 INPUT T9
430 PRINT " TYPE THEN ONE TO A LINE"

440 FOR T1=1 TO T9
450 INPUT L$(T1)
460 FOR R=1 TO 26
470 IF D$(R)=L$(T1) THEN 520
480 NEXT R
490 PRINT "SORRY, '";L$(T1)'"; IS NOT A LETTER."

500 PRINT "PLEASE TYPE IT OVER";
510 GOTO 450
520 LET L(T1)=R
530 NEXT T1
540 GOTO 700
550 LET T9=1
560 LET L$(T9)="Q"

570 LET L(T9)=17
580 GOT O 700
590 LET T9=1
600 LET L$(T9)="Z"

610 LET L(T9)=26
620 GOTO 700
630 LET T9=2
640 LET L$(1)="Q"

650 LET L(1)=17
660 LET L$(2)="Z"

670 LET L(2)=26
680
690
700 PRINT 
710 PRINT "TYPE 1 IF THE GOAL IS THE PRESENCE OF TARGET LETTER,"

720 PRINT "2 IF IT IS THE ABSENCE";
730 INPUT T7
740 IF T7<>2 THE 790
750 PRINT 
760 PRINT "TYPE 1 IF PANDEMONIUM IS TO STOP SCANNING A LINE UPON"

770 PRINT "REACHING A TARGET, 2 IF IT SHOULD SCAN THE ENTIRE LINE"

780 INPUT Z6
790 PRINT
800 PRINT "CONTEXT: TYPE 1 FOR ROUND, 2 FOR ANGULAR, 3 IF YOU"

810 PRINT "WISH TO INPUT YOUR OWN";
820 INPUT C
830 IF C>3 THEN 800
840 ON C GOTO 850,890,930
850 FOR M=1 TO 6
860 LET C$(M)=R$(M)
870 NEXT M
880 GOTO 950
890 FOR M=1 TO 6
900 LET C$(M)=A$(M)
910 NEXT M
920 GOTO 950
930 PRINT "TYPE THE SIX LETTERS, SEPARATED BY COMMAS";
940 INPUT C$(1),C$(2),C$(3),C$(4),C$(5),C$(6)
950 FOR M=1 TO 6
960 FOR M1=1 TO 26
970 IF C$(M)=D$(M1) THEN 1010
980 NEXT M1
990 PRINT "SORRY, '";C$(M)'"' IS NOT A LETTER."

1000 GOTO 930
1010 LET C(M)=M1
1020 NEXT M
1030 
1040 REM SET UP THE T ARRAY TO CONTAIN THE CONTEXT
1050 REM LETTERS AND THE TARGET LETTERS
1060
1070 FOR M=1 TO 6
1080 LET T(M)=C(M)
1090 LET T$(M)=C$(M)
1100 NEXT M
1110 REM T1 IS THE LENGTH OF THE T ARRAY
1120 LET T1=6+T9
1130 FOR M=7 TO T1
1140 LET T$(M)=L$(M-6)
1150 LET T(M)=L(M-6)
1160 NEXT M
1170 PRINT
1180 PRINT "WOULD YOU LIKE A PRINTOUT OF THE SEARCH PROCEDURE?"

1190 PRINT "TYPE 1 FOR YES, 0 FOR NO";
1200 INPUT Z
1210 IF Z=0 THEN 1240
1220 PRINT 
1230 PRINT 
1240 FOR M=1 TO T1
1250 IF Z=0 THEN 1290
1260 PRINT 
1270 PRINT 
1280 PRINT "PANDEMONIUM SEES: '";T$(M);"'"

1290 FOR I=1 TO T1
1300 LET U(I)=0
1310 NEXT I
1320 FOR M1=1 TO 3
1330 IF Z=0 THEN 1360
1340 PRINT "LEVEL";M1
1350 PRINT "ELIMINATES: ";
1360 LET B=B(T(M),M1)
1370 REM B IS LEVEL M1 FOR THE LETTER T$(M
1380 REM NOW FIND WHICH OF THE T1 LETTERS THIS LEVEL ELIMINATES
1390 FOR M2=1 TO T1
1400 IF U(M2)=1 THEN 1450
1410 IF B(T(M2),M1)
1420 IF Z=0 THEN 1440
1430 PRINT " ";T$(M2);
1440 LET U(M2)=1
1450 NEXT M2
1460 
1470 LET P1=P2=0
1480 IF Z=0 THEN 1510
1490 PRINT 
1500 PRINT "POSSIBILITIES REMAINING:";
1510 FOR M2=1 TO T1
1520 IF U(M2)=1 THEN 1610
1530 IF Z=0 THEN 1550
1540 PRINT " ";T$(M2)
1550 IF M2<=6 THEN 1590
1560 LET P2=1
1570 REM THE LETTER MIGHT STILL BE A TARGET
1580 GOTO 1610
1590 LET P1=1
1600 REM THE LETTER MIGHT STILL BE CONTEXT
1610 NEXT M2
1620 IF Z=0 THEN 1640
1630 PRINT 
1640 IF P1+P2=2 THEN 1710
1650 IF Z=0 THEN 1720
1660 IF P2=1 THEN 1690
1670 PRINT "THE CHARACTER IS CONTEXT"

1680 GOTO 1720
1690 PRINT "THE CHARACTER IS A TARGET"

1700 GOTO 1720
1710 NEXT M1
1720 LET V(T(M))=M1
1730 NEXT M
1740
1750
1760 FOR M=1 TO 20
1770 IF M>6 THEN 1800
1780 LET A=FNA(6)
1790 GOTO 1810
1800 LET A=6+FNA(14)
1810 IF 0(A)<>0 THEN 1770
1820 READ 0(A)
1830 NEXT M
1840 FOR I=1 TO 20
1850 PRINT 
1860 PRINT 
1870 PRINT 
1880 PRINT " PROBLEM"; I
1890 PRINT

Page 232 << PREVIOUS >> NEXT Jump to page:
Go to contents Go to thumbnails