10 REM A clever Chinese 'mindreader' 20 REM (C)1997 SPROW 30 : 40 MODE3 50 PRINT"Chinese 'mindreader'"''"Generating tables..." 60 DIMbox%(4*8*6) 70 REM Fill the 1st box with odd nos. 80 FORodd%=1TO63STEP2 90 box%(1+(odd% DIV2))=odd% 100 NEXT 110 : 120 REM Use rules to fill the rest 130 FORtable%=0TO4 140 FORline%=1TO(32DIV(2^table%)) 150 FORindex%=1TO(2^table%) 160 where%=((line%-1)*(2^table%))+index% 170 IFline% MOD2=0 THENbox%((32*table%)+where%+32)=box%((32*table%)+where%) ELSEbox%((32*table%)+where%+32)=box%((32*table%)+where%)+(2^table%) 180 NEXT:NEXT:NEXT 190 VDU11:PRINTSTRING$(39," ") 200 VDU11,11,11 210 : 220 REM Now print out tabulated boxes 230 FORrow%=0TO11 240 IFrow% MOD4=0 THENPRINT''" Table ";2*(row% DIV4)+1;SPC(27);"Table ";2*(row% DIV4)+2 250 PRINT'SPC(10); 260 FORcolumn%=0TO15 270 IFcolumn%=8 THENPRINT;SPC(10); 280 PRINT;FNpad(box%(1+(column% AND7)+(32*SGN(column% AND8))+(64*(row% DIV4))+(8*(row% MOD4)))); 290 NEXT:NEXT 300 : 310 REM Pop the big question 320 PRINT' 330 REPEAT 340 PRINT"Think of a number between 0 & 63... "; 350 key%=INKEY(150):result%=0 360 VDU11:PRINTSTRING$(39," "):VDU11 370 : 380 REM Interrogate the user next 390 FORtable%=1TO6 400 PRINT"Does your number appear in 'Table ";table%;"' ? (Y/N)" 410 REPEAT 420 key%=GET AND&DF 430 IFkey%=ASC"Y" THENresult%=result%+box%(1+32*(table%-1)) 440 UNTILkey%=ASC"N" ORkey%=ASC"Y" 450 VDU11 460 NEXT 470 : 480 REM Here's my prediction 490 PRINT"Well then,the number you chose must be ";result%;" " 500 key%=INKEY(250):VDU11 510 UNTIL0 520 : 530 DEFFNpad(number%) 540 =STRING$(3-LEN(STR$number%)," ")+STR$number% 550 : 560 REM The rules for the box contents 570 : 580 REM The first is simply all odd 590 REM numbers between 1 and 64. 600 : 610 REM T2R1C1=T1R1C1+1 620 REM T2R1C2=no change from T1R1C2 630 REM T2R1C3=T1R1C3+1 640 REM T2R1C4=no change from T1R1C4 650 REM ie.alternate elements 660 : 670 REM Table 3 is the same EXCEPT 680 REM It's do 2 skip 2 do 2 skip 2 690 REM and you add 2 (instead of 1) 700 REM and additions are based on T2 710 : 720 REM Table 4 is the same EXCEPT 730 REM It's do 4 skip 4 do 4 skip 4 740 REM and you add 4 (instead of 2) 750 REM and additions are based on T3 760 : 770 REM See the pattern? 780 REM It's a rather cumbersome 790 REM way to convert to/from binary