SCR
LOMEM=768
2 TAB(17):PRINT "GOMOKO"
4 PRINT "CREATIVE COMPUTING MORRISTOWN NEW JERSEY"
5 PRINT:PRINT:PRINT
6 REM CONVERTED FOR THE APPLE 1 / REPICA 1
7 REM BY VINCE BRIEL JANUARY 25, 2007
8 REM A(I,J) IS NOW A((19*J+I)-19)
9 DIM A(365)
10 PRINT "WELCOME TO THE ORIENTAL GAME OF GOMOKO."
20 PRINT: PRINT "THE GAME IS PLAYED ON AN N BY N GRID"
25 PRINT "OF A SIZE THAT YOU SPECIFY. DURING YOUR"
30 PRINT "PLAY, YOU MAY COVER ONE GRID"
35 PRINT "INTERSECTION WITH A MARKER. THE OBJECT"
40 PRINT "OF THE GAME IS TO GET 5 ADJACENT"
50 PRINT "MARKERS IN A ROW -- HORIZONTALLY,"
55 PRINT "VERTICALLY, OR DIAGONALLY. ON THE BOARD"
60 PRINT "DIAGRAM, YOUR MOVES ARE MARKED WITH A"
70 PRINT "'1' AND THE COMPUTER MOVES WITH A '2'."
80 PRINT: PRINT "THE COMPUTER DOES NOT KEEP TRACK OF WHO"
90 PRINT "HAS WON. TO END THE GAME, TYPE -1,-1.": PRINT
110 PRINT "WHAT IS YOUR BOARD SIZE (7-19)";: INPUT N
115 IF N>6 THEN 117
116 GOTO 120
117 IF N<20 THEN 210
120 PRINT "I SAID, THE MINIMUM IS 7, THE MAXIMUM IS 19.": GOTO 110
210 FOR I=1 TO N:FOR J=1 TO N: A((19*J+I)-19)=0: NEXT J: NEXT I
300 PRINT: PRINT "WE ALTERNATE MOVES.  YOU GO FIRST...": PRINT
310 PRINT "YOUR PLAY (I,J)";: INPUT I,J
315 PRINT
320 IF I=-1 THEN 980
330 X=I: Y=J: GOSUB 910: IF L=1 THEN 410
340 PRINT "ILLEGAL MOVE.  TRY AGAIN...": GOTO 310
410 IF A((19*J+I)-19)=0 THEN 440
420 PRINT "SQUARE OCCUPIED.  TRY AGAIN...": GOTO 310
440 A((19*J+I)-19)=1
500 REM *** COMPUTER TRIES AN INTELLIGENT MOVE ***
510 V=0:FOR E=-1 TO 1: FOR F=-1 TO 1: IF E+F-E*F=0 THEN 590
540 X=I+F: Y=J+F: GOSUB 910
570 IF L=0 THEN 590
580 IF A((19*Y+X)-19)#1 THEN 590
582 IF V=1 THEN 590
585 V=1:K=X:M=Y:R=E:S=F
590 NEXT F: NEXT E:IF V#1 THEN 600
595 X=K:Y=M:E=R:F=S:GOTO 710
600 REM *** COMPUTER TRIES A RANDOM MOVE ***
610 X=RND(N)+1: Y=RND(N)+1: GOSUB 910: IF L=0 THEN 610
650 IF A((19*Y+X)-19)<>0 THEN 610
660 A((19*Y+X)-19)=2: GOSUB 810: GOTO 310
710 X=I-E: Y=J-F: GOSUB 910
750 IF L=0 THEN 610
760 GOTO 650
800 REM *** PRINT THE BOARD ***
810 FOR I=1 TO N: FOR J=1 TO N: PRINT A((19*J+I)-19);
840 NEXT J: PRINT: NEXT I: PRINT: RETURN
910 L=1: IF X<1 THEN 970
920 IF X>N THEN 970
930 IF Y<1 THEN 970
940 IF Y>N THEN 970
950 RETURN
970 L=0: RETURN
980 PRINT: PRINT "THANKS FOR THE GAME!!"
985 PRINT "PLAY AGAIN (1 FOR YES, 0 FOR NO)";: INPUT Q
990 IF Q=1 THEN 110
999 END
RUN
