1 PRINT TAB(33);"H-I-Q"
2 PRINT TAB(15);"CREATIVE COMPUTING  MORRISTOWN, NEW JERSEY"
3 PRINT:PRINT:PRINT
4 DIM B(70),T(9,9)
5 PRINT "HERE IS THE BOARD:": PRINT
6 PRINT "          !    !    !"
7 PRINT "         13   14   15": PRINT
8 PRINT "          !    !    !"
9 PRINT "         22   23   24": PRINT
10 PRINT "!    !    !    !    !    !    !"
11 PRINT "29   30   31   32   33   34   35": PRINT
12 PRINT "!    !    !    !    !    !    !"
13 PRINT "38   39   40   41   42   43   44": PRINT
14 PRINT "!    !    !    !    !    !    !"
15 PRINT "47   48   49   50   51   52   53": PRINT
16 PRINT "          !    !    !"
17 PRINT "         58   59   60": PRINT
18 PRINT "          !    !    !"
19 PRINT "         67   68   69": PRINT
20 PRINT "TO SAVE TYPING TIME, A COMPRESSED VERSION OF THE GAME BOARD"
22 PRINT "WILL BE USED DURING PLAY.  REFER TO THE ABOVE ONE FOR PEG"
24 PRINT "NUMBERS.  OK, LET'S BEGIN."
28 REM *** SET UP BOARD
29 FOR R=1 TO 9
30 FOR C=1 TO 9
31 IF (R-4)*(R-5)*(R-6)=0 THEN 40
32 IF (C-4)*(C-5)*(C-6)=0 THEN 40
35 T(R,C)=-5
36 GOTO 50
40 IF (R-1)*(C-1)*(R-9)*(C-9)=0 THEN 35
42 T(R,C)=5
50 NEXT C
60 NEXT R
65 T(5,5)=0: GOSUB 500
70 REM *** INPUT MOVE AND CHECK ON LEGALITY
75 FOR W=1 TO 33
77 READ M
79 DATA 13,14,15,22,23,24,29,30,31,32,33,34,35,38,39,40,41
81 DATA 42,43,44,47,48,49,50,51,52,53,58,59,60,67,68,69
83 B(M)=-7: NEXT W
86 B(41)=-3
100 INPUT "MOVE WHICH PIECE";Z
110 IF B(Z)=-7 THEN 140
120 PRINT "ILLEGAL MOVE, TRY AGAIN...": GOTO 100
140 INPUT "TO WHERE";P
150 IF B(P)=0 THEN 120
153 IF B(P)=-7 THEN 120
156 IF Z=P THEN 100
160 IF ((Z+P)/2)=INT((Z+P)/2) THEN 180
170 GOTO 120
180 IF (ABS(Z-P)-2)*(ABS(Z-P)-18)<>0 THEN 120
190 GOSUB 1000
200 GOSUB 500
210 GOSUB 1500
220 GOTO 100
500 REM *** PRINT BOARD
510 FOR X=1 TO 9
520 FOR Y=1 TO 9
525 IF (X-1)*(X-9)*(Y-1)*(Y-9)=0 THEN 550
530 IF (X-4)*(X-5)*(X-6)=0 THEN 570
540 IF (Y-4)*(Y-5)*(Y-6)=0 THEN 570
550 REM
560 GOTO 610
570 IF T(X,Y)<>5 THEN 600
580 PRINT TAB(Y*2);"!";
590 GOTO 610
600 PRINT TAB(Y*2);"O";
610 REM
615 NEXT Y
620 PRINT
630 NEXT X
640 RETURN
1000 REM *** UPDATE BOARD
1005 C=1: FOR X=1 TO 9
1020 FOR Y=1 TO 9
1030 IF C<>Z THEN 1220
1040 IF C+2<>P THEN 1080
1045 IF T(X,Y+1)=0 THEN 120
1050 T(X,Y+2)=5
1060 T(X,Y+1)=0: B(C+1)=-3
1070 GOTO 1200
1080 IF C+18<>P THEN 1130
1085 IF T(X+1,Y)=0 THEN 120
1090 T(X+2,Y)=5: T(X+1,Y)=0: B(C+9)=-3
1120 GOTO 1200
1130 IF C-2<>P THEN 1170
1135 IF T(X,Y-1)=0 THEN 120
1140 T(X,Y-2)=5: T(X,Y-1)=0: B(C-1)=-3
1160 GOTO 1200
1170 IF C-18<>P THEN 1220
1175 IF T(X-1,Y)=0 THEN 120
1180 T(X-2,Y)=5: T(X-1,Y)=0: B(C-9)=-3
1200 B(Z)=-3: B(P)=-7
1210 T(X,Y)=0: GOTO 1240
1220 C=C+1
1225 NEXT Y
1230 NEXT X
1240 RETURN
1500 REM*** CHECK IF GAME IS OVER
1505 F=0
1510 FOR R=2 TO 8
1520 FOR C=2 TO 8
1530 IF T(R,C)<>5 THEN 1580
1535 F=F+1
1540 FOR A=R-1 TO R+1
1545 T=0
1550 FOR B=C-1 TO C+1
1560 T=T+T(A,B)
1561 NEXT B
1564 IF T<>10 THEN 1567
1565 IF T(A,C)<>0 THEN 1630
1567 NEXT A
1568 FOR X=C-1 TO C+1
1569 T=0
1570 FOR Y=R-1 TO R+1
1571 T=T+T(Y,X)
1572 NEXT Y
1573 IF T<>10 THEN 1575
1574 IF T(R,X)<>0 THEN 1630
1575 NEXT X
1580 NEXT C
1590 NEXT R
1600 REM *** GAME IS OVER
1605 PRINT "THE GAME IS OVER."
1610 PRINT "YOU HAD";F;"PIECES REMAINING."
1611 IF F<>1 THEN 1615
1612 PRINT "BRAVO!  YOU MADE A PERFECT SCORE!"
1613 PRINT "SAVE THIS PAPER AS A RECORD OF YOUR ACCOMPLISHMENT!"
1615 PRINT: INPUT "PLAY AGAIN (YES OR NO)";A$
1617 IF A$="NO" THEN 2000
1618 RESTORE: GOTO 28
1620 STOP
1630 RETURN
2000 PRINT: PRINT "SO LONG FOR NOW.": PRINT
2010 END