_TITLE "Score Four by Donald L. Foster Jr."
SCREEN _NEWIMAGE(1010, 735, 256)
_PALETTECOLOR 14, _RGB32(255, 215, 0)
DIM t(100)
a = 1: b = 2
e(1) = 1: e(2) = 14
z$(1) = "(A)": z$(2) = "(B)": z$(3) = "(C)": z$(4) = "(D)"
FOR z = 1 TO 4: FOR y = 1 TO 4: f(z, y) = 1: NEXT: t(64 + z) = z: NEXT
PRINT: PRINT " (1) (2) (3) (4)"
v = 0: w = 0
FOR z = 1 TO 4
x = 0
LOCATE 8 + w, 3: PRINT z$(z)
FOR y = 1 TO 4
PSET (123 + x, 193 + v), 15: DRAW "u142r4d142c4r40l80"
u = 0
FOR t = 1 TO 4
a(z, y, t) = 125 + x: b(z, y, t) = 175 + v - u
u = u + 34
NEXT
x = x + 175
NEXT
v = v + 173: w = w + 11
NEXT
LINE (730, 20)-(990, 715), 4, BF
LINE (730, 20)-(990, 715), 15, B
COLOR 15, 4
LOCATE 4, 98: PRINT "S C O R E F O U R"
LOCATE 19, 94: PRINT "1: Normal or 2: Extended Play";
LOCATE 21, 97: PRINT "Enter Your Choice. [_]";
GETCHOICE:
a$ = INKEY$: IF a$ = "" THEN GOTO GETCHOICE
IF (ASC(a$) = 49) + (ASC(a$) = 50) THEN pl = VAL(a$): LOCATE 21, 118: PRINT a$;: GOTO GETCHOICE
IF ASC(a$) = 8 THEN LOCATE 21, 118: PRINT "_";: GOTO GETCHOICE
IF ASC(a$) <> 13 THEN GOTO GETCHOICE
LOCATE 19, 94: PRINT STRING$(29, 32);
LOCATE 21, 97: PRINT STRING$(24, 32);
LINE (830, 150)-(890, 210), 0, BF: LINE (830, 150)-(890, 210), 15, B
STARTGAME:
LOCATE 9, 104: PRINT "Player:"; a;
CIRCLE (860, 180), 17, e(a): PAINT (860, 180), e(a)
CIRCLE (855, 175), 3, 15: PAINT (855, 175), 15
LOCATE 16, 101: IF pl = 1 THEN PRINT " Normal Play"; ELSE PRINT " Extended Play";
LOCATE 37, 98: PRINT "Location of Peg? [_ ]";
GETROW:
a$ = INKEY$: IF a$ = "" THEN GOTO GETROW
IF (ASC(a$) < 65) + ((ASC(a$) > 68) * (ASC(a$) < 97)) + (ASC(a$) > 100) THEN GOTO GETROW
IF ASC(a$) > 90 THEN r = t(ASC(a$) - 32) ELSE r = t(ASC(a$))
IF (f(r, 1) > 4) * (f(r, 2) > 4) * (f(r, 3) > 4) * (f(r, 4) > 4) THEN GOTO GETROW
LOCATE 37, 116: PRINT MID$(z$(r), 2, 1); "_";
GETCOLUMN:
a$ = INKEY$: IF a$ = "" THEN GOTO GETCOLUMN
IF ASC(a$) = 8 THEN LOCATE 37, 116: PRINT "_ ";: GOTO GETROW
IF (VAL(a$) < 1) + (VAL(a$) > 4) THEN GOTO GETCOLUMN
c = VAL(a$): IF f(r, c) > 4 THEN GOTO GETCOLUMN
LOCATE 37, 117: PRINT a$;
GETENTER:
a$ = INKEY$: IF a$ = "" THEN GOTO GETENTER
IF ASC(a$) = 8 THEN LOCATE 37, 117: PRINT "_";: GOTO GETCOLUMN
IF ASC(a$) <> 13 THEN GOTO GETENTER
c(r, c, f(r, c)) = a
CIRCLE (a(r, c, f(r, c)), b(r, c, f(r, c))), 17, e(a): PAINT (a(r, c, f(r, c)), b(r, c, f(r, c))), e(a)
CIRCLE (a(r, c, f(r, c)) - 5, b(r, c, f(r, c)) - 5), 3, 15: PAINT (a(r, c, f(r, c)) - 5, b(r, c, f(r, c)) - 5), 15
f(r, c) = f(r, c) + 1
x(a) = 0
FOR z = 1 TO 4
FOR y = 1 TO 4
IF (c(z, y, 1) = a) * (c(z, y, 2) = a) * (c(z, y, 3) = a) * (c(z, y, 4) = a) THEN x(a) = x(a) + 1
IF (c(1, z, y) = a) * (c(2, z, y) = a) * (c(3, z, y) = a) * (c(4, z, y) = a) THEN x(a) = x(a) + 1
IF (c(z, 1, y) = a) * (c(z, 2, y) = a) * (c(z, 3, y) = a) * (c(z, 4, y) = a) THEN x(a) = x(a) + 1
NEXT
IF (c(1, 1, z) = a) * (c(2, 2, z) = a) * (c(3, 3, z) = a) * (c(4, 4, z) = a) THEN x(a) = x(a) + 1
IF (c(4, 1, z) = a) * (c(3, 2, z) = a) * (c(2, 3, z) = a) * (c(1, 4, z) = a) THEN x(a) = x(a) + 1
IF (c(1, z, 1) = a) * (c(2, z, 2) = a) * (c(3, z, 3) = a) * (c(4, z, 4) = a) THEN x(a) = x(a) + 1
IF (c(1, z, 4) = a) * (c(2, z, 3) = a) * (c(3, z, 2) = a) * (c(4, z, 1) = a) THEN x(a) = x(a) + 1
IF (c(z, 1, 1) = a) * (c(z, 2, 2) = a) * (c(z, 3, 3) = a) * (c(z, 4, 4) = a) THEN x(a) = x(a) + 1
IF (c(z, 1, 4) = a) * (c(z, 2, 3) = a) * (c(z, 3, 2) = a) * (c(z, 4, 1) = a) THEN x(a) = x(a) + 1
NEXT
IF (c(1, 1, 1) = a) * (c(2, 2, 2) = a) * (c(3, 3, 3) = a) * (c(4, 4, 4) = a) THEN x(a) = x(a) + 1
IF (c(1, 4, 4) = a) * (c(2, 3, 3) = a) * (c(3, 2, 2) = a) * (c(4, 1, 1) = a) THEN x(a) = x(a) + 1
IF (c(1, 1, 4) = a) * (c(2, 2, 3) = a) * (c(3, 3, 2) = a) * (c(4, 4, 1) = a) THEN x(a) = x(a) + 1
LOCATE 21, 98: PRINT "Player 1 patterns:"; x(1);
LOCATE 23, 98: PRINT "Player 2 patterns:"; x(2);
IF (pl = 1) * (x(a) >= 1) THEN t = a: GOTO WINNER:
v = 0
FOR z = 1 TO 4
FOR y = 1 TO 4
FOR x = 1 TO 4
IF c(z, y, x) > 0 THEN v = v + 1
NEXT
NEXT
NEXT
IF (pl = 2) * (v = 64) * (x(a) > x(b)) THEN t = a: GOTO WINNER
IF (pl = 2) * (v = 64) * (x(a) < x(b)) THEN t = b: GOTO WINNER
IF v = 64 THEN LOCATE 37, 98: PRINT "The Ended in a Tie!!!";: GOTO ANOTHERGAME
SWAP a, b: GOTO STARTGAME
WINNER:
LOCATE 37, 96: PRINT "Player"; t; "is the Winner!!!";
IF t <> a THEN
LOCATE 9, 104: PRINT "Player:"; t;
CIRCLE (860, 180), 17, e(t): PAINT (860, 180), e(t)
CIRCLE (855, 175), 3, 15: PAINT (855, 175), 15
END IF
ANOTHERGAME:
LOCATE 39, 100: PRINT "Play Another Game?"
GETANOTHERGAME:
a$ = INKEY$: IF a$ = "" THEN GOTO GETANOTHERGAME
IF (a$ = "y") + (a$ = "Y") THEN RUN
IF (a$ = "n") + (a$ = "N") THEN END
GOTO GETANOTHERGAME
SLEEP