_TITLE "Othello by Donald L. Foster Jr."
SCREEN _NEWIMAGE(1010, 736, 256)
_PALETTECOLOR 1, _RGB32(150, 150, 150) ' Grey
_PALETTECOLOR 2, _RGB32(0, 70, 0) ' Green
_PALETTECOLOR 3, _RGB32(1, 1, 1) ' Lt Black
A = 1: B = 2: C = 4: D = 4: E = 4: F = 4: O = 2: T = 0
C(1) = 15: C(2) = 0
D(4, 4) = 2: D(4, 5) = 1: D(5, 4) = 1: D(5, 5) = 2
F(1) = 2: F(2) = 2
Z$ = "C=X;60F10D60G10L60H10U60E10"
LINE (0, 0)-(736, 736), 2, BF: LINE (7, 7)-(729, 729), 0, BF: LINE (737, 0)-(1010, 737), 1, BF
X = 0
FOR Z = 1 TO 8
W = 0
FOR Y = 1 TO 8
LINE (10 + W, 10 + X)-(96 + W, 96 + X), 2, BF
A(Z, Y) = 53 + W: B(Z, Y) = 53 + X
IF D(Z, Y) > 0 THEN CIRCLE (A(Z, Y), B(Z, Y)), 37, C(D(Z, Y)): PAINT (A(Z, Y), B(Z, Y)), C(D(Z, Y))
W = W + 90
NEXT
X = X + 90
NEXT
CIRCLE (188, 188), 10, 3: PAINT (188, 188), 3: CIRCLE (548, 188), 10, 3: PAINT (548, 188), 3: CIRCLE (188, 548), 10, 3: PAINT (188, 548), 3: CIRCLE (548, 548), 10, 3: PAINT (548, 548), 3
COLOR 15, 1
LOCATE 3, 101: PRINT "O T H E L L O";
LINE (820, 90)-(926, 196), 2, BF: LINE (827, 97)-(919, 189), 0, BF: LINE (830, 100)-(916, 186), 2, BF
LOCATE 14, 106: PRINT "Player:";
COLOR 0, 1
LOCATE 20, 100: PRINT "Player: 1 Score:";
LOCATE 22, 100: PRINT "Player: 2 Score:";
STARTGAME:
CIRCLE (873, 143), 37, C(A): PAINT (873, 143), C(A)
COLOR 15, 1
LOCATE 14, 113: PRINT A;
COLOR 0, 1
LOCATE 20, 118: PRINT F(1);
LOCATE 22, 118: PRINT F(2);
IF T = 0 THEN GOTO LINE310
CURSOR1:
IF D(C, D) = 1 THEN V = 15 ELSE IF D(C, D) = 2 THEN V = 0 ELSE V = 2
IF D(E, F) = 1 THEN W = 0 ELSE IF D(E, F) = 2 THEN W = 15 ELSE W = 1
LINE (A(C, D) - 10, B(C, D) - 10)-(A(C, D) + 10, B(C, D) + 10), V, BF
LINE (A(E, F) - 10, B(E, F) - 10)-(A(E, F) + 10, B(E, F) + 10), W, BF
GETINPUT:
A$ = INKEY$
IF A$ = "" THEN GOTO GETINPUT
IF (F = 8) * (A$ = CHR$(0) + CHR$(77)) THEN C = E: D = F: F = 1: GOTO CURSOR1
IF A$ = CHR$(0) + CHR$(77) THEN C = E: D = F: F = F + 1: GOTO CURSOR1
IF (F = 1) * (A$ = CHR$(0) + CHR$(75)) THEN C = E: D = F: F = 8: GOTO CURSOR1
IF A$ = CHR$(0) + CHR$(75) THEN C = E: D = F: F = F - 1: GOTO CURSOR1
IF (E = 1) * (A$ = CHR$(0) + CHR$(72)) THEN C = E: D = F: E = 8: GOTO CURSOR1
IF A$ = CHR$(0) + CHR$(72) THEN C = E: D = F: E = E - 1: GOTO CURSOR1
IF (E = 8) * (A$ = CHR$(0) + CHR$(80)) THEN C = E: D = F: E = 1: GOTO CURSOR1
IF A$ = CHR$(0) + CHR$(80) THEN C = E: D = F: E = E + 1: GOTO CURSOR1
IF ASC(A$) = 18 THEN GOTO LINE460
IF ASC(A$) <> 13 THEN GOTO GETINPUT
IF D(E, F) > 0 THEN GOTO GETINPUT
G = 0: H = 0: I = 0: J = 0: K = 0: L = 0: M = 0: N = 0
LINE180:
IF E - G - 1 >= 1 THEN
IF D(E - G - 1, F) = B THEN G = G + 1: GOTO LINE180 ELSE IF D(E - G - 1, F) = 0 THEN G = 0
ELSE G = 0
END IF
LINE190:
IF F + H + 1 <= 8 THEN
IF D(E, F + H + 1) = B THEN H = H + 1: GOTO LINE190 ELSE IF D(E, F + H + 1) = 0 THEN H = 0
ELSE H = 0
END IF
LINE200:
IF E + I + 1 <= 8 THEN
IF D(E + I + 1, F) = B THEN I = I + 1: GOTO LINE200 ELSE IF D(E + I + 1, F) = 0 THEN I = 0
ELSE I = 0
END IF
LINE210:
IF F - J - 1 >= 1 THEN
IF D(E, F - J - 1) = B THEN J = J + 1: GOTO LINE210 ELSE IF D(E, F - J - 1) = 0 THEN J = 0
ELSE J = 0
END IF
LINE220:
IF (E - K - 1 >= 1) * (F + K + 1 <= 8) THEN
IF D(E - K - 1, F + K + 1) = B THEN K = K + 1: GOTO LINE220 ELSE IF D(E - K - 1, F + K + 1) = 0 THEN K = 0
ELSE K = 0
END IF
LINE230:
IF (E + L + 1 <= 8) * (F + L + 1 <= 8) THEN
IF D(E + L + 1, F + L + 1) = B THEN L = L + 1: GOTO LINE230 ELSE IF D(E + L + 1, F + L + 1) = 0 THEN L = 0
ELSE L = 0
END IF
LINE240:
IF (E + M + 1 <= 8) * (F - M - 1 >= 1) THEN
IF D(E + M + 1, F - M - 1) = B THEN M = M + 1: GOTO LINE240 ELSE IF D(E + M + 1, F - M - 1) = 0 THEN M = 0
ELSE M = 0
END IF
LINE250:
IF (E - N - 1 >= 1) * (F - N - 1 >= 1) THEN
IF D(E - N - 1, F - N - 1) = B THEN N = N + 1: GOTO LINE250 ELSE IF D(E - N - 1, F - N - 1) = 0 THEN N = 0
ELSE N = 0
END IF
IF (G = 0) * (H = 0) * (I = 0) * (J = 0) * (K = 0) * (L = 0) * (M = 0) * (N = 0) THEN GOTO GETINPUT
O = A: F(A) = F(A) + 1: D(E, F) = A: CIRCLE (A(E, F), B(E, F)), 37, C(A): PAINT (A(E, F), B(E, F)), C(A)
IF G > 0 THEN FOR Z = 1 TO G: D(E - Z, F) = A: CIRCLE (A(E - Z, F), B(E - Z, F)), 37, C(A): PAINT (A(E - Z, F), B(E - Z, F)), C(A): NEXT
IF H > 0 THEN FOR Z = 1 TO H: D(E, F + Z) = A: CIRCLE (A(E, F + Z), B(E, F + Z)), 37, C(A): PAINT (A(E, F + Z), B(E, F + Z)), C(A): NEXT
IF I > 0 THEN FOR Z = 1 TO I: D(E + Z, F) = A: CIRCLE (A(E + Z, F), B(E + Z, F)), 37, C(A): PAINT (A(E + Z, F), B(E + Z, F)), C(A): NEXT
IF J > 0 THEN FOR Z = 1 TO J: D(E, F - Z) = A: CIRCLE (A(E, F - Z), B(E, F - Z)), 37, C(A): PAINT (A(E, F - Z), B(E, F - Z)), C(A): NEXT
IF K > 0 THEN FOR Z = 1 TO K: D(E - Z, F + Z) = A: CIRCLE (A(E - Z, F + Z), B(E - Z, F + Z)), 37, C(A): PAINT (A(E - Z, F + Z), B(E - Z, F + Z)), C(A): NEXT
IF L > 0 THEN FOR Z = 1 TO L: D(E + Z, F + Z) = A: CIRCLE (A(E + Z, F + Z), B(E + Z, F + Z)), 37, C(A): PAINT (A(E + Z, F + Z), B(E + Z, F + Z)), C(A): NEXT
IF M > 0 THEN FOR Z = 1 TO M: D(E + Z, F - Z) = A: CIRCLE (A(E + Z, F - Z), B(E + Z, F - Z)), 37, C(A): PAINT (A(E + Z, F - Z), B(E + Z, F - Z)), C(A): NEXT
IF N > 0 THEN FOR Z = 1 TO N: D(E - Z, F - Z) = A: CIRCLE (A(E - Z, F - Z), B(E - Z, F - Z)), 37, C(A): PAINT (A(E - Z, F - Z), B(E - Z, F - Z)), C(A): NEXT
F(A) = F(A) + G + H + I + J + K + L + M + N: F(B) = F(B) - G - H - I - J - K - L - M - N
LOCATE 20, 118: PRINT F(1);
LOCATE 22, 118: PRINT F(2);
LINE310:
E(1) = 0: E(2) = 0
FOR Z = 1 TO 8: FOR Y = 1 TO 8: T(Z, Y) = 0: NEXT: NEXT
S = 0
FOR Z = 1 TO 8
FOR Y = 1 TO 8
IF D(Z, Y) = A THEN E(A) = E(A) + 1: GOTO ENDLOOP
IF D(Z, Y) = B THEN E(B) = E(B) + 1: GOTO ENDLOOP
G = 0: H = 0: I = 0: J = 0: K = 0: L = 0: M = 0: N = 0
LINE320:
IF Z - G - Z >= 1 THEN
IF D(Z - G - 1, Y) = O THEN G = G + 1: GOTO LINE320 ELSE IF D(Z - G - 1, Y) = 0 THEN G = 0
ELSE G = 0
END IF
LINE330:
IF Y + H + 1 <= 8 THEN
IF D(Z, Y + H + 1) = O THEN H = H + 1: GOTO LINE330 ELSE IF D(Z, Y + H + 1) = 0 THEN H = 0
ELSE H = 0
END IF
LINE340:
IF Z + I + 1 <= 8 THEN
IF D(Z + I + 1, Y) = O THEN I = I + 1: GOTO LINE340 ELSE IF D(Z + I + 1, Y) = 0 THEN I = 0
ELSE I = 0
END IF
LINE350:
IF Y - J - 1 >= 1 THEN
IF D(Z, Y - J - 1) = O THEN J = J + 1: GOTO LINE350 ELSE IF D(Z, Y - J - 1) = 0 THEN J = 0
ELSE J = 0
END IF
LINE360:
IF (Z - K - 1 >= 1) * (Y + K + 1 <= 8) THEN
IF D(Z - K - 1, Y + K + 1) = O THEN K = K + 1: GOTO LINE360 ELSE IF D(Z - K - 1, Y + K + 1) = 0 THEN K = 0
ELSE K = 0
END IF
LINE370:
IF (Z + L + 1 <= 8) * (Y + L + 1 <= 8) THEN
IF D(Z + L + 1, Y + L + 1) = O THEN L = L + 1: GOTO LINE370 ELSE IF D(Z + L + 1, Y + L + 1) = 0 THEN L = 0
ELSE L = 0
END IF
LINE380:
IF (Z + M + 1 <= 8) * (Y - M - 1 >= 1) THEN
IF D(Z + M + 1, Y - M - 1) = O THEN M = M + 1: GOTO LINE380 ELSE IF D(Z + M + 1, Y - M - 1) = 0 THEN M = 0
ELSE M = 0
END IF
LINE390:
IF (Z - N - 1 >= 1) * (Y - N - 1 >= 1) THEN
IF D(Z - N - 1, Y - N - 1) = O THEN N = N + 1: GOTO LINE390 ELSE IF D(Z - N - 1, Y - N - 1) = 0 THEN N = 0
ELSE N = 0
END IF
IF (G > 0) + (H > 0) + (I > 0) + (J > 0) + (K > 0) + (L > 0) + (M > 0) + (N > 0) THEN S = 1: T(Z, Y) = 1
ENDLOOP:
NEXT
NEXT
IF T = 0 THEN T = 1: GOTO CURSOR1
IF (S = 1) * (O = A) THEN GOTO LINE1000
IF O = A THEN O = B: GOTO LINE310
IF (S = 1) * (O = B) THEN C = E: D = F: E = 4: F = 4: GOTO CURSOR1
IF E(1) > E(2) THEN R = 1 ELSE IF E(1) < E(2) THEN R = 2 ELSE R = 3
COLOR 15, 1
LOCATE 32, 98
IF R < 3 THEN
PRINT "Player"; R; "is the Winner !!";
CIRCLE (873, 143), 37, C(R): PAINT (873, 143), C(R)
LOCATE 14, 113: PRINT R;
END IF
IF R = 3 THEN PRINT " There has been a Tie.";
LOCATE 34, 101: PRINT "Play Another Game ?";
ANOTHERGAME:
A$ = INKEY$: IF A$ = "" THEN GOTO ANOTHERGAME
IF (A$ = "y") + (A$ = "Y") THEN RUN
IF (A$ = "n") + (A$ = "N") THEN END
GOTO ANOTHERGAME
LINE460:
IF D(E, F) = 1 THEN V = 15 ELSE IF D(E, F) = 2 THEN V = 0 ELSE V = 2
LINE (A(E, F) - 10, B(E, F) - 10)-(A(E, F) + 10, B(E, F) + 10), V, BF
FOR Z = 1 TO 8
FOR Y = 1 TO 8
IF T(Z, Y) = 1 THEN LINE (A(Z, Y) - 10, B(Z, Y) - 10)-(A(Z, Y) + 10, B(Z, Y) + 10), 7, BF
NEXT
NEXT
LINE480:
A$ = INKEY$
IF A$ = "" THEN GOTO LINE480
IF ASC(A$) <> 127 THEN GOTO LINE480
FOR Z = 1 TO 8
FOR Y = 1 TO 8
IF T(Z, Y) = 1 THEN LINE (A(Z, Y) - 10, B(Z, Y) - 10)-(A(Z, Y) + 10, B(Z, Y) + 10), 6, BF
NEXT
NEXT
C = E: D = F: GOTO CURSOR1
LINE1000:
C = E: D = F: E = 4: F = 4
SWAP A, B: GOTO STARTGAME