Black Hole is a game based on a machine language program on my Elf II which uses the RCA 1802 Microprocessor. I understand it was originally called “Teaser.” The challenge of rewriting it in Basic for the small memory could not be resisted. The program takes a little over 1K of memory.
Black Hole
You are in space looking at your computer screen which shows a star surrounded by black holes.
0 0 0 0 * 0 0 0 0
To escape you must get the pattern to be a black hole surrounded by stars.
* * * * 0 * * * *
You can only fire at stars. The stars explode, leaving a black hole, but they also produce new stars in other locations. What the galaxy will look like after you fire at a star is important.
1 x . x 2 x . x 3 x . . . x . . . x . . . . . . x x . . . . . x x 4 . . x 5 x . . 6 x x . . . . . . . . . . . . . x . . . x . . . x 7 x . x 8 x . . . . x x . x 9
The number is the star fired upon. The x’s are the holes changed to stars or stars changed to holes (the reverse of what they used to be). The .’s are the star or holes that are unaffected.
For convenience sake the computer displays the star numbers in a block next to the galaxy pattern. Examples are:
0 0 0 1 2 3 0 * 0 1 2 3
0 * 0 4 5 6 Shoot star 5 * 0 * 4 5 6
0 0 0 7 8 9 will result in 0 * 0 7 8 9
this
Do not end with all black holes or you will be lost in space forever!
0 0 0 0 0 0 0 0 0
The lowest possible number of turns to solve the problem is eleven. There are many ways to solve it; here are two:
5.2.8.1.7.3.5.9.2.8.5
5.2.1.3.8.7.5.2.9.8.5
You cannot read the program listing and figure out how to solve it. It is very challenging game which will give hours of fascinating fun.
5 REM BLACK HOLE WRITTEN BY BILL ECKEL APRIL
2, 1981
10 DIM X(9)
14 FOR I = 1 TO 9
16 LET X(I) = 0
18 NEXT I
20 LET X(5) = 1
25 CLS
30 PRINT, " BLACK HOLE"
32 PRINT
34 PRINT
35 LET I = 1
40 PRINT ,;
42 FOR A = 1 TO 3
44 IF X(I) = 1 THEN PRINT "*";
46 IF X(I) = 0 THEN PRINT "O";
48 LET I = I + 1
49 PRINT " ";
50 NEXT A
52 PRINT ,; I - 3; " " I - 2, " "; I - 1
53 PRINT
54 IF NOT I = 10 THEN GOTO 40
56 PRINT
58 PRINT
60 GOSUB 1000
65 PRINT "WHICH STAR?"
70 INPUT S
75 IF S 1 OR S 9 THEN GOTO 70
78 IF X(S) = 0 THEN GOTO 70
85 LET X(S) = 0
90 GOSUB S * 100
95 GOTO 25
100 LET B = 2
110 GOSUB 980
120 LET B = 4
130 GOSUB 980
140 LET B = 5
150 GOSUB 980
160 RETURN
200 LET B = 1
210 GOSUB 980
220 LET B = 3
230 GOSUB 980
240 RETURN
300 LET B = 2
310 GOSUB 980
320 LET B = 5
330 GOSUB 980
340 LET B = 6
350 GOSUB 980
360 RETURN
400 LET B = 1
410 GOSUB 980
420 LET B = 7
430 GOSUB 980
440 RETURN
500 LET B = 2
510 GOSUB 980
520 LET B = 4
530 GOSUB 980
540 LET B = 6
550 GOSUB 980
560 LET B = 8
570 GOSUB 980
580 RETURN
600 LET B = 3
610 GOSUB 980
620 LET B = 9
630 GOSUB 980
640 RETURN
700 LET B = 4
710 GOSUB 980
720 LET B = 5
730 GOSUB 980
740 LET B = 8
750 GOSUB 980
760 RETURN
800 LET B = 7
810 GOSUB 980
820 LET B = 9
830 GOSUB 980
840 RETURN
900 LET B = 5
910 GOSUB 980
920 LET B = 6
930 GOSUB 980
940 LET B = 8
950 GOSUB 980
960 RETURN
980 IF X(B) = 0 THEN GOTO 986
983 IF X(B) = 1 THEN X(B) = 0
984 RETURN
986 LET X(B) = 1
990 RETURN
1000 FOR I = 1 TO 9
1010 IF X(I) = 1 THEN GOTO 1050
1020 NEXT I
1025 PRINT "YOU BLEW IT"
1030 PRINT "YOU ARE LOST IN SPACE FOREVER"
1040 STOP
1050 IF X(5) = 1 THEN RETURN
1060 FOR I = 1 TO 4
1070 IF X(I) = 0 THEN RETURN
1080 NEXT I
1090 FOR I = 6 TO 9
1100 IF X(I) = 0 THEN RETURN
1110 NEXT I
1120 PRINT "CONGRATULATIONS"
1130 PRINT "YOU FOUND THE BLACK HOLE"
1140 STOP
SAMPLE RUN
BLACK HOLE
0 0 0 1 2 3
0 * 0 4 5 6
0 0 0 7 8 9
WHICH STAR?
5
------------------------------
BLACK HOLE
0 * 0 1 2 3
* 0 * 4 5 6
0 * 0 7 8 9
WHICH STAR?
2
------------------------------
BLACK HOLE
* 0 * 1 2 3
* 0 * 4 5 6
0 * 0 7 8 9
WHICH STAR?
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.