1 REM ***** BLACK BOX *****
2 REM A computerized version of the popular board game.
10 REM
11 REM by Bruce Ratoff, with credit to Kris Tuttle of Computer Mart
12 REM for the Apple II version on which the logic is based.
13 REM IMPORTANT: This program makes heavy use of ADM-3A cursor controls.
14 REM You must change the value of AT$ to the cursor address sequence
15 REM for your own terminal.  You should also change all occurrences of
16 REM CLS$ to the "clear screen" code for your terminal.
17 REM
18 REM
19 REM
20 AT$=CHR$(27)+"=": RX$=AT$+CHR$(54)+CHR$(92): WI$=SPACE$(10)+STRING$(10,8)
21 CLS$=CHR$(26)
30 RANDOMIZE
90 MK$="!#$%&'():*-=[{]}^~\|@`;+/?.>,<_"+CHR$(34)
100 PRINT CLS$;TAB(33);"BLACKBOX"
130 PRINT :  PRINT :  PRINT :  PRINT :  PRINT
131 PRINT  TAB(25);"32 31 30 29 28 27 26 25"
132 FOR I=1  TO 8:  PRINT  TAB(22);I;" .  .  .  .  .  .  .  . ";25-I:  NEXT I
133 PRINT  TAB(25);" 9 10 11 12 13 14 15 16"
140 DEF  FNR(Z)=INT(8*RND(1)+1)
150 PRINT AT$;CHR$(52);CHR$(62);"# OF ATOMS";WI$;:INPUT N:IF N<3  OR N>6  THEN 150
160 FOR J=0  TO 9:  FOR I=0  TO 9: B(I,J)=0:  NEXT I,J
170 FOR I=1  TO N
180 X=FNR(1): Y=FNR(1):  IF B(X,Y)<>0  THEN 180
190 B(X,Y)=1:  NEXT I
200 S=0: C=0
210 PRINT AT$;CHR$(54);" IN AT";WI$; :INPUT R:  IF R<1  THEN 480
215 IF R>32  THEN 230
220 ON  INT((R-1)/8+1)  GOTO 240,250,260,270
230 PRINT RX$;"ERROR     ":  GOTO 210
240 X=0: Y=R: U=1: V=0:  GOTO 280
250 X=R-8: Y=9: U=0: V=-1:  GOTO 280
260 X=9: Y=25-R: U=-1: V=0:  GOTO 280
270 X=33-R: Y=0: U=0: V=1
280 XN=X: YN=Y: X1=X+U: Y1=Y+V
290 IF U=0  THEN X2=X1-1: X3=X1+1: Y2=Y1: Y3=Y1:  GOTO 310
300 Y2=Y1-1: Y3=Y1+1: X2=X1: X3=X1
310 ON 8*B(X1,Y1)+B(X2,Y2)+2*B(X3,Y3)+1  GOTO 330,340,350,340
320 PRINT RX$;"HIT       ": S=S+1: Z=R: M$="H":  GOSUB 630:  GOTO 210
330 X=X1: Y=Y1:  GOTO 380
340 Z=1:  GOTO 360
350 Z=-1
360 IF U=0  THEN U=Z: V=0:  GOTO 380
370 U=0: V=Z
380 ON  INT((X+15)/8)  GOTO 420,400,430
390 STOP
400 ON  INT((Y+15)/8)  GOTO 440,280,450
410 STOP
420 Z=Y:  GOTO 460
430 Z=25-Y:  GOTO 460
440 Z=33-X:  GOTO 460
450 Z=8+X
460 IF Z=R  THEN  PRINT RX$;"REFLECTED": S=S+1: M$="R":  GOSUB 630:  GOTO 210
465 PRINT RX$;SPACE$(15);RX$;
470 PRINT "OUT AT";Z: S=S+2:  GOSUB 630:  GOTO 210
480 PRINT AT$;CHR$(52);CHR$(52);"WHERE DO YOU THINK THE ATOMS ARE?"
490 C=0
500 FOR Q=1  TO N
510 PRINT AT$;CHR$(54);" ATOM #";Q;"(ROW,COLUMN)";WI$;
520 INPUT J,I
525 M$="?":  GOSUB 750
530 IF B(I,J)=0  THEN S=S+5:  GOTO 540
535 C=C+1
540 NEXT Q
550 FOR J=1  TO 8:  FOR I=1  TO 8
560 IF B(I,J)=1  THEN M$="*":  GOSUB 750
570 NEXT I,J
590 PRINT AT$;CHR$(53);" YOU GUESSED ";C;" OUT OF ";N;" ATOMS CORRECTLY"
600 PRINT "YOUR SCORE FOR THIS ROUND WAS ";S;" POINTS. "
610 INPUT "CARE TO TRY AGAIN";A$
620 IF  LEFT$(A$,1)="Y"  OR  LEFT$(A$,1)="y"  THEN 90 :ELSE 999
630 IF Z<>R  THEN M$=LEFT$(MK$,1):MK$=MID$(MK$,2)
640 ON  INT((R-1)/8+1)  GOTO 650,660,670,680
650 PRINT AT$;CHR$(38+R);CHR$(52);M$:  GOTO 690
660 PRINT AT$;CHR$(48);CHR$(30+3*R);M$:  GOTO 690
670 PRINT AT$;CHR$(63-R);CHR$(84);M$:  GOTO 690
680 PRINT AT$;CHR$(37);CHR$(153-3*R);M$
690 IF R=Z  THEN  RETURN
700 ON  INT((Z-1)/8+1)  GOTO 710,720,730,740
710 PRINT AT$;CHR$(38+Z);CHR$(52);M$:  RETURN
720 PRINT AT$;CHR$(48);CHR$(30+3*Z);M$:  RETURN
730 PRINT AT$;CHR$(63-Z);CHR$(84);M$:  RETURN
740 PRINT AT$;CHR$(37);CHR$(153-3*Z);M$:  RETURN
750 PRINT AT$;CHR$(38+J);CHR$(54+3*I);M$:  RETURN
999 END
6682 NULL(30+3*Z);M$:  RETURN
730 PRINT AT
