-
Notifications
You must be signed in to change notification settings - Fork 0
/
HI-Q.BAS
141 lines (141 loc) · 4 KB
/
HI-Q.BAS
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
10 PRINT CHR$(26):WIDTH 80:PRINT TAB(33);"HI-Q":PRINT
20 PRINT TAB(15);"CREATIVE COMPUTING MORRISTOWN, NEW JERSEY"
22 PRINT:PRINT
30 PRINT "HI-Q IS A PUZZLE GAME PLAYED ON A NUMBERED BOARD. FOR A PRINTED"
31 PRINT "COPY OF THE GAME BOARD, MAKE SURE THE PRINTER IS ON AND PAPER IS"
32 PRINT "CORRECTLY POSITIONED. THEN ENTER 'RETURN': ";:INPUT XX$
40 DIM B(70),T(9,9)
45 PRINT:PRINT:PRINT "--- Printing ---":PRINT:PRINT
50 LPRINT "HERE IS THE BOARD:":LPRINT
60 LPRINT " ! ! !"
70 LPRINT " 13 14 15": LPRINT
80 LPRINT " ! ! !"
90 LPRINT " 22 23 24": LPRINT
100 LPRINT "! ! ! ! ! ! !"
110 LPRINT "29 30 31 32 33 34 35": LPRINT
120 LPRINT "! ! ! ! ! ! !"
130 LPRINT "38 39 40 41 42 43 44": LPRINT
140 LPRINT "! ! ! ! ! ! !"
150 LPRINT "47 48 49 50 51 52 53": LPRINT
160 LPRINT " ! ! !"
170 LPRINT " 58 59 60": LPRINT
180 LPRINT " ! ! !"
190 LPRINT " 67 68 69": LPRINT
195 LPRINT CHR$(12)
200 PRINT "TO SAVE TYPING TIME, A COMPRESSED VERSION OF THE GAME BOARD"
210 PRINT "WILL BE USED DURING PLAY. REFER TO THE ABOVE ONE FOR PEG"
220 PRINT "NUMBERS. OK, LET'S BEGIN."
230 REM *** SET UP BOARD
240 FOR R=1 TO 9
250 FOR C=1 TO 9
260 IF (R-4)*(R-5)*(R-6)=0 THEN 300
270 IF (C-4)*(C-5)*(C-6)=0 THEN 300
280 T(R,C)=-5
290 GOTO 320
300 IF (R-1)*(C-1)*(R-9)*(C-9)=0 THEN 280
310 T(R,C)=5
320 NEXT C
330 NEXT R
340 T(5,5)=0: GOSUB 560
350 REM *** INPUT MOVE AND CHECK ON LEGALITY
360 FOR W=1 TO 33
370 READ M
380 DATA 13,14,15,22,23,24,29,30,31,32,33,34,35,38,39,40,41
390 DATA 42,43,44,47,48,49,50,51,52,53,58,59,60,67,68,69
400 B(M)=-7: NEXT W
410 B(41)=-3
420 INPUT "MOVE WHICH PIECE";Z
430 IF B(Z)=-7 THEN 450
440 PRINT "ILLEGAL MOVE, TRY AGAIN...": GOTO 420
450 INPUT "TO WHERE";P
460 IF B(P)=0 THEN 440
470 IF B(P)=-7 THEN 440
480 IF Z=P THEN 420
490 IF ((Z+P)/2)=INT((Z+P)/2) THEN 510
500 GOTO 440
510 IF (ABS(Z-P)-2)*(ABS(Z-P)-18)<>0 THEN 440
520 GOSUB 730
530 GOSUB 560
540 GOSUB 990
550 GOTO 420
560 REM *** PRINT BOARD
570 FOR X=1 TO 9
580 FOR Y=1 TO 9
590 IF (X-1)*(X-9)*(Y-1)*(Y-9)=0 THEN 620
600 IF (X-4)*(X-5)*(X-6)=0 THEN 640
610 IF (Y-4)*(Y-5)*(Y-6)=0 THEN 640
620 REM
630 GOTO 680
640 IF T(X,Y)<>5 THEN 670
650 PRINT TAB(Y*2);"!";
660 GOTO 680
670 PRINT TAB(Y*2);"O";
680 REM
690 NEXT Y
700 PRINT
710 NEXT X
720 RETURN
730 REM *** UPDATE BOARD
740 C=1: FOR X=1 TO 9
750 FOR Y=1 TO 9
760 IF C<>Z THEN 950
770 IF C+2<>P THEN 820
780 IF T(X,Y+1)=0 THEN 440
790 T(X,Y+2)=5
800 T(X,Y+1)=0: B(C+1)=-3
810 GOTO 930
820 IF C+18<>P THEN 860
830 IF T(X+1,Y)=0 THEN 440
840 T(X+2,Y)=5: T(X+1,Y)=0: B(C+9)=-3
850 GOTO 930
860 IF C-2<>P THEN 900
870 IF T(X,Y-1)=0 THEN 440
880 T(X,Y-2)=5: T(X,Y-1)=0: B(C-1)=-3
890 GOTO 930
900 IF C-18<>P THEN 950
910 IF T(X-1,Y)=0 THEN 440
920 T(X-2,Y)=5: T(X-1,Y)=0: B(C-9)=-3
930 B(Z)=-3: B(P)=-7
940 T(X,Y)=0: GOTO 980
950 C=C+1
960 NEXT Y
970 NEXT X
980 RETURN
990 REM*** CHECK IF GAME IS OVER
1000 F=0
1010 FOR R=2 TO 8
1020 FOR C=2 TO 8
1030 IF T(R,C)<>5 THEN 1210
1040 F=F+1
1050 FOR A=R-1 TO R+1
1060 T=0
1070 FOR B=C-1 TO C+1
1080 T=T+T(A,B)
1090 NEXT B
1100 IF T<>10 THEN 1120
1110 IF T(A,C)<>0 THEN 1330
1120 NEXT A
1130 FOR X=C-1 TO C+1
1140 T=0
1150 FOR Y=R-1 TO R+1
1160 T=T+T(Y,X)
1170 NEXT Y
1180 IF T<>10 THEN 1200
1190 IF T(R,X)<>0 THEN 1330
1200 NEXT X
1210 NEXT C
1220 NEXT R
1230 REM *** GAME IS OVER
1240 PRINT "THE GAME IS OVER."
1250 PRINT "YOU HAD";F;"PIECES REMAINING."
1260 IF F<>1 THEN 1290
1270 PRINT "BRAVO! YOU MADE A PERFECT SCORE!"
1280 PRINT "SAVE THIS PAPER AS A RECORD OF YOUR ACCOMPLISHMENT!"
1290 PRINT: INPUT "PLAY AGAIN (YES OR NO)";A$
1300 IF LEFT$(A$,1)="N" THEN 1340
1310 RESTORE: GOTO 230
1320 STOP
1330 RETURN
1340 PRINT: PRINT "SO LONG FOR NOW.": PRINT
1350 RUN "MENU"