Thwart

This file is part of and Synchro-Sette September 1983. Download the collection to get this file.
Developer(s): Gene G. Buza
Date: September 1983
Type: Program
Platform(s): TS 1000
Tags: Game

This is a two-player Connect-Four game (played on a 4×4 grid of columns A–D, rows 1–4) where a human competes against a computer AI. The board is drawn using block graphics characters and direct memory POKEs to display computer (value 10) and human (value 1) tokens as ZX81 inverse characters. The AI uses a layered decision tree: it first checks for an immediate win, then blocks the human’s winning threats across rows, columns, and eight diagonal patterns, falling back to random column selection when no tactical move is found. Board state is tracked in four numeric arrays A(), B(), C(), D() with values 0 (empty), 1 (human), or 10 (computer), and tokens are dropped to the lowest empty slot by scanning from row 1 upward. Memory addresses for POKing display characters are computed at startup by reading the system variable at addresses 16396–16397 to locate the display file.


Program Structure

The program is divided into clearly separated functional blocks:

  1. Lines 5–99: Initialisation — sets FAST mode, dimensions arrays, computes display-file POKE addresses, defines blank-row string.
  2. Lines 100–200: Title / “who goes first” menu.
  3. Lines 1000–1999: Subroutine to draw the board grid and column labels using block graphics.
  4. Lines 2000–2080: Main game loop — alternates computer and human moves, calls AI and checking subroutines.
  5. Lines 4000–4540: Human-threat detection (block human wins across, down, diagonal).
  6. Lines 6000–6993: Computer-win detection (win across, down, diagonal) and fallback random-with-retry.
  7. Lines 7000–7460: “Find Level” — drops a token into the chosen column by scanning for the lowest empty slot and POKEing the display.
  8. Lines 7500–7830: Computer-win check and end-of-game handler.
  9. Lines 8000–8510: Human-win check and end-of-game handler.
  10. Lines 9000–9499: Opening-move heuristics (first two plies of the game).
  11. Lines 9998–9999: SAVE the program, then RUN (developer utility line).

Board Representation

The 4×4 grid is stored in four numeric arrays A(), B(), C(), D(), each of length 14 (indices 1–4 used for board state, indices 11–14 used as display POKE address tables). Cell values are:

ValueMeaning
0Empty
1Human token
10Computer token

Row 1 is the bottom of each column; tokens fall to the lowest available slot. Win conditions check for three aligned cells summing to 3 (human wins) or 30 (computer wins), a neat trick that avoids separate ownership flags.

Display-File POKE Technique

At lines 80–96 the program reads the ZX81 system variable DFILE pointer from addresses 16396–16397 (PEEK 16396+256*PEEK 16397) and pre-computes absolute display-file addresses for each of the 16 board cells, storing them in array slots 11–14 of each column array. For example, A(11)=104+X targets cell A4 (the visual bottom row). When a move is made, subroutine 7000 scans upward through rows 1–4 to find the lowest empty slot N, then executes POKE A(N+9),CD where CD is 128 (computer, inverse space = solid block) or 136 (human, inverse “H”-like character). This bypasses PRINT entirely for token placement.

AI Decision Hierarchy

On the computer’s turn the main loop at lines 2007–2019 calls subroutines in priority order:

  1. 9000: Opening book — special-cases the first two moves to favour central columns B and C.
  2. 6000: Computer-win search — checks all rows, columns, and 16 named diagonal patterns for a two-in-a-row opportunity (sum = 20) with an empty third cell.
  3. 4000: Human-threat blocking — mirrors the win-search logic for human pieces (sum = 2), covering rows, columns, and the same diagonal patterns.
  4. 6300: Fallback with retry — if no tactical move was found, picks a random column (CHR$(38+INT(RND*4))) and retries up to 4 times if that column is tactically undesirable.

Key BASIC Idioms

  • P$ holds the chosen column letter (“A”–”D”). Setting it to "" signals “no move chosen yet”; subroutines return early via IF P$<>"" THEN RETURN.
  • FM is a move counter used to gate the opening-book subroutine (IF FM<=2).
  • CT sums all 16 board cells; when CT>77 (all cells contain at least some token — maximum 16×10=160, but a full board of mixed pieces would reach various values) a draw is declared. The threshold 77 seems empirically chosen to detect a near-full board.
  • Z$="% " (two characters) is used as a 28-character blank to erase status lines quickly.
  • INKEY$ polling at line 2050 accepts only codes 38–41 (ZX81 character codes for letters A–D).
  • Line 130 accepts only codes 29–30 (ZX81 character codes for “1” and “2”) for the first-player choice.

Win-Detection Symmetry

Subroutines 7500 (computer win, sum=30) and 8000 (human win, sum=3) are structurally identical, checking the same eight diagonal expressions, all four columns vertically, and rows across adjacent column pairs. This parallel structure makes the logic easy to audit but doubles the code length for win checking.

Content

Appears On

Cassette to accompany the September 1983 issue of Synchro-Sette.

Related Products

Related Articles

Related Content

Image Gallery

Thwart

Source Code

   5 FAST 
   6 LET FM=0
  10 DIM A$(28)
  20 LET A=.689655
  30 POKE 16418,0
  40 DIM A(14)
  50 DIM B(14)
  60 DIM C(14)
  70 DIM D(14)
  80 LET X=PEEK 16396+256*PEEK 16397
  81 LET A(11)=104+X
  82 LET B(11)=111+X
  83 LET C(11)=118+X
  84 LET D(11)=125+X
  85 LET A(12)=269+X
  86 LET B(12)=276+X
  87 LET C(12)=283+X
  88 LET D(12)=290+X
  89 LET A(13)=434+X
  90 LET B(13)=441+X
  91 LET C(13)=448+X
  92 LET D(13)=455+X
  93 LET A(14)=599+X
  94 LET B(14)=606+X
  95 LET C(14)=613+X
  96 LET D(14)=620+X
  99 LET Z$="% "
 100 GOSUB 1000
 110 PRINT AT 22,0;"WHO GOES FIRST",,"HUMAN(1) OR COMPUTER (2)?";AT 23,6;"%1";AT 23,22;"%2"
 115 SLOW 
 120 LET B$=INKEY$
 130 IF CODE B$<29 OR CODE B$>30 THEN GOTO 110
 140 PRINT AT 22,0;A$;AT 23,0;A$
 150 IF B$="2" THEN PRINT AT 22,0;"OK HUMAN, I 'LL GO FIRST :::";
 160 IF B$="1" THEN PRINT AT 22,0;"GO AHEAD HUMAN, YOU 'LL LOSE";AT 23,0;"ANYWAY :::"
 170 FOR N=1 TO 50
 180 NEXT N
 190 PRINT AT 22,0;A$;AT 23,0;A$
 200 GOTO 2000
 999 GOTO 999
 1010 CLS 
 1020 FOR N=0 TO 28
 1030 PRINT AT 0,N;Z$;AT A*N,0;Z$;AT 5,N;Z$;AT A*N,7;Z$;AT 10,N;Z$;AT A*N,14;Z$;AT 15,N;Z$;AT A*N,21;Z$;AT 20,N;Z$;AT A*N,28;Z$
 1040 NEXT N
 1050 PRINT AT 1,1;"A1";AT 1,8;"B1";AT 1,15;"C1";AT 1,22;"D1"
 1060 PRINT AT 6,1;"A2";AT 6,8;"B2";AT 6,15;"C2";AT 6,22;"D2"
 1070 PRINT AT 11,1;"A3";AT 11,8;"B3";AT 11,15;"C3";AT 11,22;"D3"
 1080 PRINT AT 16,1;"A4";AT 16,8;"B4";AT 16,15;"C4";AT 16,22;"D4"
 1090 FOR N=0 TO 20
 1100 PRINT AT N,0;" :";AT N,28;": "
 1110 NEXT N
 1120 PRINT AT 0,29;"''% ''";AT 1,30;"% ";AT 2,30;"% ";AT 4,29;":   :";AT 5,29;"% % % ";AT 6,29;":   :";AT 8,29;":   :";AT 9,29;": .. :";AT 10,29;"': :'";AT 12,29;".''''.";AT 13,29;":....:";AT 14,29;":   :";AT 16,29;":''''.";AT 17,29;":....'";AT 18,29;":  '.";AT 20,29;"''% ''";AT 21,30;"% ";AT 22,30;"% "
 1999 RETURN 
 2000 IF B$="1" THEN GOTO 2020
 2001 REM % %C%O%M%P%U%T%E%R% %F%I%R%S%T% %M%O%V%E% 
 2002 LET P$=CHR$ (INT (2*RND)+39)
 2003 LET FM=1
 2004 GOTO 2007
 2005 REM % %C%O%M%P%U%T%E%R% %M%O%V%E% 
 2006 LET P$=""
 2007 LET SC=10
 2008 LET CD=128
 2009 IF P$<>"" THEN GOTO 2017
 2010 IF FM<=2 THEN GOSUB 9000
 2011 IF P$<>"" AND FM<=3 THEN GOTO 2018
 2012 GOSUB 6000
 2013 IF P$<>"" THEN GOTO 2017
 2014 GOSUB 4000
 2015 IF P$<>"" THEN GOTO 2018
 2016 GOSUB 6300
 2018 GOSUB 7000
 2019 GOSUB 7500
 2027 REM % %H%U%M%A%N% %M%O%V%E% 
 2028 PRINT AT 22,0;"YOUR MOVE, HUMAN :::"
 2029 LET B$=""
 2030 LET CD=136
 2035 LET FM=FM+1
 2040 LET SC=1
 2050 LET P$=INKEY$
 2060 IF CODE P$<38 OR CODE P$>41 THEN GOTO 2050
 2065 PRINT AT 22,0;A$
 2070 GOSUB 7000
 2075 GOSUB 8000
 2080 GOTO 2005
 4000 REM % %H%U%M%A%N% %A%C%R%O%S%S% 
 4001 IF A(4)+B(4)=2 AND C(4)=0 THEN LET P$="C"
 4002 IF C(4)+B(4)=2 AND A(4)=0 THEN LET P$="A"
 4003 IF C(4)+B(4)=2 AND D(4)=0 THEN LET P$="D"
 4004 IF C(4)+D(4)=2 AND B(4)=0 THEN LET P$="B"
 4005 IF B(4)+D(4)=2 AND C(4)=0 THEN LET P$="B"
 4006 IF A(4)+C(4)=2 AND B(4)=0 THEN LET P$="B"
 4007 IF P$<>"" THEN RETURN 
 4010 FOR N=3 TO 1 STEP -1
 4015 IF B(N)=0 AND B(N+1)<>0 AND A(N)+C(N)=2 THEN LET P$="B"
 4020 IF A(N)=0 AND A(N+1)<>0 AND B(N)+C(N)=2 THEN LET P$="A"
 4025 IF C(N)=0 AND C(N+1)<>0 AND B(N)+D(N)=2 THEN LET P$="C"
 4030 IF B(N)=0 AND B(N+1)<>0 AND C(N)+D(N)=2 THEN LET P$="B"
 4040 IF C(N)=0 AND C(N+1)<>0 AND A(N)+B(N)=2 THEN LET P$="C"
 4050 IF D(N)=0 AND D(N+1)<>0 AND C(N)+B(N)=2 THEN LET P$="D"
 4060 NEXT N
 4070 IF P$<>"" THEN RETURN 
 4080 REM % %C%H%E%C%K% %H%U%M%A%N% %U%P%/%D%O%W%N% 
 4090 FOR N=2 TO 1 STEP -1
 4100 IF A(N+1)+A(N+2)=2 AND A(N)=0 THEN LET P$="A"
 4110 IF B(N+1)+B(N+2)=2 AND B(N)=0 THEN LET P$="B"
 4120 IF C(N+1)+C(N+2)=2 AND C(N)=0 THEN LET P$="C"
 4130 IF D(N+1)+D(N+2)=2 AND D(N)=0 THEN LET P$="D"
 4140 NEXT N
 4150 IF P$<>"" THEN RETURN 
 4160 REM % %C%H%E%C%K% %H%U%M%A%N% %D%I%A%G%O%N%A%L% 
 4165 LET NI=0
 4170 IF (A(3)+B(2)=2) AND (C(2)<>0) THEN LET P$="C"
 4175 IF A(4)+C(2)=2 AND B(4)<>0 AND B(3)=0 THEN LET P$="B"
 4180 IF (B(3)+C(2)=2) AND (D(2)<>0) AND D(1)=0 THEN LET P$="D"
 4181 IF (B(3)+D(1)=2) AND (C(2)=0) AND C(3)<>0 THEN LET P$="C"
 4182 IF (C(2)+D(1)=2) AND (B(3)=0) AND B(4)<>0 THEN LET P$="B"
 4183 IF P$<>"" THEN RETURN 
 4185 IF A(3)+C(1)=2 AND B(3)<>0 AND B(2)=0 THEN LET P$="B"
 4186 IF A(3)+B(2)=2 AND C(2)<>0 AND C(1)=0 THEN LET P$="C"
 4187 IF C(1)+B(2)=2 AND A(4)<>0 AND A(3)=0 THEN LET P$="A"
 4188 IF P$<>"" THEN RETURN 
 4190 IF (A(4)+B(3)=2) AND (C(3)<>0) AND C(2)=0 THEN LET P$="C"
 4191 IF (A(4)+C(2)=2) AND (B(4)<>0) AND B(3)=0 THEN LET P$="B"
 4192 IF P$<>"" THEN RETURN 
 4195 IF B(4)+D(2)=2 AND C(4)<>0 AND C(3)=0 THEN LET P$="C"
 4196 IF B(4)+C(3)=2 AND D(3)<>0 AND D(2)=0 THEN LET P$="D"
 4197 IF D(2)+C(3)=2 AND B(4)=0 THEN LET P$="B"
 4198 IF P$<>"" THEN RETURN 
 4210 IF (C(4)+B(3)=2) AND (A(3)<>0) AND A(2)=0 THEN LET P$="A"
 4211 IF (C(4)+A(2)=2) AND (B(4)<>0) AND B(3)=0 THEN LET P$="B"
 4212 IF (B(3)+A(2)=2) AND (C(4)=0) THEN LET P$="C"
 4213 IF P$<>"" THEN RETURN 
 4215 IF B(2)+D(4)=2 AND C(4)<>0 AND C(3)=0 THEN LET P$="C"
 4216 IF B(2)+C(3)=2 AND D(4)=0 THEN LET P$="D"
 4217 IF D(4)+C(3)=2 AND B(2)=0 AND B(3)<>0 THEN LET P$="B"
 4218 IF P$<>"" THEN RETURN 
 4225 IF B(1)+D(3)=2 AND C(3)<>0 AND C(2)=0 THEN LET P$="C"
 4226 IF B(1)+C(2)=2 AND D(4)<>0 AND D(3)=0 THEN LET P$="D"
 4227 IF D(3)+C(2)=2 AND B(2)<>0 AND B(1)=0 THEN LET P$="B"
 4228 IF P$<>"" THEN RETURN 
 4230 IF (C(3)+B(2)=2) AND (A(2)<>0) AND A(1)=0 THEN LET P$="A"
 4231 IF (C(3)+A(1)=2) AND (B(3)<>0) AND B(2)=0 THEN LET P$="B"
 4232 IF (B(2)+A(1)=2) AND (C(4)<>0) AND C(3)=0 THEN LET P$="C"
 4250 IF P$<>"" THEN RETURN 
 4300 FOR N=3 TO 1 STEP -1
 4310 IF A(N)+B(N)=2 AND C(N+1)=0 AND P$="C" THEN GOTO 4500
 4320 IF A(N)+C(N)=2 AND B(N+1)=0 AND P$="B" THEN GOTO 4500
 4330 IF B(N)+C(N)=2 AND A(N+1)=0 AND P$="A" THEN GOTO 4500
 4340 IF B(N)+C(N)=2 AND D(N+1)=0 AND P$="D" THEN GOTO 4500
 4350 IF C(N)+D(N)=2 AND B(N+1)=0 AND P$="B" THEN GOTO 4500
 4360 IF B(N)+D(N)=2 AND C(N+1)=0 AND P$="C" THEN GOTO 4500
 4370 NEXT N
 4380 IF P$<>"" THEN RETURN 
 4500 REM % %F%I%N%D% %R%A%N%D%O%M% %B%O%X% 
 4510 LET P$=CHR$ (38+INT (RND*4))
 4520 IF NI>4 THEN RETURN 
 4530 LET NI=NI+1
 4540 GOTO 4300
 6000 REM % %C%O%M%P%U%T%E%R:.%S% %M%O%V%E% 
 6001 LET RI=0
 6005 LET CT=A(1)+A(2)+A(3)+A(4)+B(1)+B(2)+B(3)+B(4)+C(1)+C(2)+C(3)+C(4)+D(1)+D(2)+D(3)+D(4)
 6010 IF CT>77 THEN GOTO 7060
 6015 LET P$=""
 6016 REM % %C%O%M%P%U%T%E%R% %W%I%N% %A%C%R%O%S%S% 
 6020 FOR N=4 TO 1 STEP -1
 6030 IF C(N)=0 AND A(N)+B(N)=20 THEN LET P$="C"
 6040 IF A(N)=0 AND B(N)+C(N)=20 THEN LET P$="A"
 6060 IF B(N)=0 AND C(N)+D(N)=20 THEN LET P$="B"
 6070 IF D(N)=0 AND B(N)+C(N)=20 THEN LET P$="D"
 6080 NEXT N
 6090 IF P$<>"" THEN GOTO 6991
 6095 REM % %C%O%M%P%U%T%E%R% %W%I%N% %D%O%W%N% 
 6100 FOR N=1 TO 2
 6110 IF A(N+2)+A(N+1)=20 AND A(N)=0 THEN LET P$="A"
 6120 IF B(N+2)+B(N+1)=20 AND B(N)=0 THEN LET P$="B"
 6130 IF C(N+2)+C(N+1)=20 AND C(N)=0 THEN LET P$="C"
 6140 IF D(N+2)+D(N+1)=20 AND D(N)=0 THEN LET P$="D"
 6145 IF P$<>"" THEN GOTO 6991
 6147 REM % %C%O%M%P%U%T%E%R% %W%I%N% %D%I%A%G%O%N%A%L% 
 6150 IF (A(2)+B(3)=20) AND (C(1)=0) THEN LET P$="C"
 6151 IF (A(2)+C(4)=20) AND (B(3)=0) AND (B(4)<>0) THEN LET P$="B"
 6152 IF (B(3)+C(4)=20) AND (A(2)=0) AND (A(3)<>0) THEN LET P$="A"
 6155 IF (A(4)+C(2)=20) AND (B(4)<>0) AND B(3)=0 THEN LET P$="B"
 6156 IF (A(4)+B(3)=20) AND (C(3)<>0) AND C(2)=0 THEN LET P$="C"
 6157 IF (C(2)+B(3)=20) AND (A(1)<>0) THEN LET P$="A"
 6160 IF (B(4)+C(3)=20) AND (D(3)<>0) AND D(2)=0 THEN LET P$="D"
 6161 IF (B(4)+D(2)=20) AND (C(4)<>0) AND C(3)=0 THEN LET P$="C"
 6162 IF (C(3)+D(2)=20) AND (B(4)=0) THEN LET P$="B"
 6165 IF (B(4)+C(3)=20) AND (D(3)<>0) AND (D(2)=0) THEN LET P$="D"
 6166 IF (D(2)+C(3)=20) AND (B(4)=0) THEN LET P$="B"
 6167 IF (B(4)+D(2)=20) AND (C(4)<>0) AND (C(3)=0) THEN LET P$="C"
 6170 IF (D(4)+C(3)=20) AND (B(3)<>0) AND (B(2)=0) THEN LET P$="B"
 6171 IF (D(4)+B(2)=20) AND (C(4)<>0) AND (C(3)=0) THEN LET P$="C"
 6172 IF (C(3)+B(2)=20) AND (D(4)=0) THEN LET P$="D"
 6175 IF (A(3)+B(2)=20) AND (C(2)<>0) AND (C(1)=0) THEN LET P$="C"
 6176 IF (A(3)+C(1)=20) AND (B(3)<>0) AND (B(2)=0) THEN LET P$="B"
 6177 IF (B(2)+C(1)=20) AND (A(4)<>0) AND (A(3)=0) THEN LET P$="A"
 6180 IF (B(3)+C(2)=20) AND (D(2)<>0) AND (D(1)=0) THEN LET P$="D"
 6181 IF (B(3)+D(1)=20) AND (C(3)<>0) AND (C(2)=0) THEN LET P$="C"
 6182 IF (C(2)+D(1)=20) AND (B(4)<>0) AND (B(3)=0) THEN LET P$="B"
 6185 IF (D(3)+B(1)=20) AND (C(3)<>0) AND (C(2)=0) THEN LET P$="C"
 6186 IF (D(3)+C(2)=20) AND (B(2)<>0) AND (B(1)=0) THEN LET P$="B"
 6187 IF (B(1)+C(2)=20) AND (D(2)<>0) AND (D(3)=0) THEN LET P$="D"
 6190 IF (C(3)+A(1)=20) AND (B(3)<>0) AND (B(2)=0) THEN LET P$="B"
 6191 IF (C(3)+B(2)=20) AND (A(2)<>0) AND (A(1)=0) THEN LET P$="A"
 6192 IF (A(1)+B(2)=20) AND (C(2)<>0) AND (C(3)=0) THEN LET P$="C"
 6200 RETURN 
 6300 IF P$="" THEN LET P$=CHR$ (38+INT (RND*4))
 6305 LET RI=0
 6310 FOR N=3 TO 1 STEP -1
 6320 IF A(N)+B(N)=2 AND C(N+1)=0 AND P$="C" THEN GOTO 6500
 6325 IF B(N)+D(N)=2 AND C(N+1)=0 AND P$="C" THEN GOTO 6500
 6330 IF C(N)+B(N)=2 AND A(N+1)=0 AND P$="A" THEN GOTO 6500
 6335 IF C(N)+A(N)=2 AND B(N+1)=0 AND P$="B" THEN GOTO 6500
 6340 IF C(N)+D(N)=2 AND B(N+1)=0 AND P$="B" THEN GOTO 6500
 6345 IF C(N)+B(N)=2 AND D(N+1)=0 AND P$="D" THEN GOTO 6500
 6350 NEXT N
 6360 GOTO 6990
 6500 LET P$=CHR$ (38+INT (RND*4))
 6510 IF RI>4 THEN GOTO 6991
 6520 LET RI=RI+1
 6530 GOTO 6310
 6991 LET CD=128
 6992 LET SC=10
 6993 RETURN 
 7000 REM % %F%I%N%D% %L%E%V%E%L% 
 7001 LET CT=A(1)+A(2)+A(3)+A(4)+B(1)+B(2)+B(3)+B(4)+C(1)+C(2)+C(3)+C(4)+D(1)+D(2)+D(3)+D(4)
 7005 IF CT>77 THEN GOTO 7060
 7010 IF P$="A" THEN GOTO 7100
 7020 IF P$="B" THEN GOTO 7200
 7030 IF P$="C" THEN GOTO 7300
 7040 IF P$="D" THEN GOTO 7400
 7060 PRINT AT 22,0;"YOUR LUCKY. IT 'S A DRAW ::"
 7070 GOTO 7810
 7100 IF A(1)<>0 THEN GOTO 7200
 7105 REM % %F%I%N%D%S% %B%O%X% 
 7110 FOR N=1 TO 4
 7120 IF A(N)<>0 THEN GOTO 7140
 7130 NEXT N
 7140 POKE A(N+9),CD
 7150 LET A(N-1)=SC
 7160 RETURN 
 7200 IF B(1)<>0 THEN GOTO 7300
 7210 FOR N=1 TO 4
 7220 IF B(N)<>0 THEN GOTO 7240
 7230 NEXT N
 7240 POKE B(N+9),CD
 7250 LET B(N-1)=SC
 7260 RETURN 
 7300 IF C(1)<>0 THEN GOTO 7400
 7310 FOR N=1 TO 4
 7320 IF C(N)<>0 THEN GOTO 7340
 7330 NEXT N
 7340 POKE C(N+9),CD
 7350 LET C(N-1)=SC
 7360 RETURN 
 7400 IF D(1)<>0 THEN GOTO 7100
 7410 FOR N=1 TO 4
 7420 IF D(N)<>0 THEN GOTO 7440
 7430 NEXT N
 7440 POKE D(N+9),CD
 7450 LET D(N-1)=SC
 7460 RETURN 
 7500 REM % %C%O%M%P%U%T%E%R% %W%I%N% %U%P%/%D%O%W%N% 
 7505 FOR N=1 TO 2
 7510 IF A(N)+A(N+1)+A(N+2)=30 THEN GOTO 7800
 7520 IF B(N)+B(N+1)+B(N+2)=30 THEN GOTO 7800
 7530 IF C(N)+C(N+1)+C(N+2)=30 THEN GOTO 7800
 7540 IF D(N)+D(N+1)+D(N+2)=30 THEN GOTO 7800
 7542 NEXT N
 7545 REM % %C%O%M%P%U%T%E%R% %W%I%N% %A%C%R%O%S%S% 
 7550 FOR N=1 TO 4
 7560 IF A(N)+B(N)+C(N)=30 THEN GOTO 7800
 7570 IF B(N)+C(N)+D(N)=30 THEN GOTO 7800
 7580 NEXT N
 7585 REM % %C%O%M%P%U%T%E%R% %W%I%N% %D%I%A%G%O%N%A%L% 
 7590 IF (A(1)+B(2)+C(3)=30) OR (A(2)+B(3)+C(4)=30) OR (A(4)+B(3)+C(2)=30) OR (B(3)+C(2)+D(1)=30) THEN GOTO 7800
 7600 IF (B(2)+C(3)+D(4)=30) OR (B(1)+C(2)+D(3)=30) OR (A(3)+B(2)+C(1)=30) OR (B(4)+C(3)+D(2)=30) THEN GOTO 7800
 7799 RETURN 
 7800 REM % %C%O%M%P%U%T%E%R% %W%I%N% 
 7805 PRINT AT 22,0;"I WIN (OF COURSE)";AT 23,0;"PRESS ENTER FOR A NEW GAME.";
 7810 PAUSE 40000
 7820 CLS 
 7830 RUN 
 8000 REM % %H%U%M%A%N% %W%I%N% %U%P%/%D%O%W%N% 
 8005 FOR N=1 TO 2
 8010 IF A(N)+A(N+1)+A(N+2)=3 THEN GOTO 8500
 8020 IF B(N)+B(N+1)+B(N+2)=3 THEN GOTO 8500
 8030 IF C(N)+C(N+1)+C(N+2)=3 THEN GOTO 8500
 8040 IF D(N)+D(N+1)+D(N+2)=3 THEN GOTO 8500
 8045 REM % %H%U%M%A%N% %W%I%N% %A%C%R%O%S%S% 
 8050 FOR N=1 TO 4
 8060 IF A(N)+B(N)+C(N)=3 THEN GOTO 8500
 8070 IF B(N)+C(N)+D(N)=3 THEN GOTO 8500
 8080 NEXT N
 8085 REM % %H%U%M%A%N% %W%I%N% %D%I%A%G%O%N%A%L% 
 8090 IF (A(1)+B(2)+C(3)=3) OR (A(2)+B(3)+C(4)=3) OR (A(4)+B(3)+C(2)=3) OR (B(3)+C(2)+D(1)=3) THEN GOTO 8500
 8100 IF (B(2)+C(3)+D(4)=3) OR (B(1)+C(2)+D(3)=3) OR (A(3)+B(2)+C(1)=3) OR (B(4)+C(3)+D(2)=3) THEN GOTO 8500
 8499 RETURN 
 8500 REM % %H%U%M%A%N% %W%I%N% 
 8505 PRINT AT 22,0;"WHAT LUCK, IT WON 'T HAPPEN AGAIN";AT 23,0;"PRESS ENTER FOR A NEW GAME.";
 8510 GOTO 7810
 9000 IF B(4)=1 THEN LET P$="C"
 9010 IF C(4)=1 THEN LET P$="B"
 9020 IF P$<>"" THEN GOTO 9498
 9030 IF B(4)=10 AND C(4)=0 AND D(4)=0 AND A(4)=0 THEN LET P$="C"
 9040 IF C(4)=10 AND B(4)=0 AND D(4)=0 AND A(4)=0 THEN LET P$="B"
 9050 IF P$<>"" THEN GOTO 9498
 9100 IF B(4)=10 AND B(3)=0 THEN LET P$="B"
 9110 IF C(4)=10 AND C(3)=0 THEN LET P$="C"
 9120 IF P$<>"" THEN GOTO 9498
 9130 IF A(4)=1 AND B(4)=0 THEN LET P$="B"
 9140 IF D(4)=1 AND C(4)=0 THEN LET P$="C"
 9150 IF P$<>"" THEN GOTO 9498
 9160 IF B(4)=10 AND B(3)=0 THEN LET P$="B"
 9170 IF C(4)=10 AND C(3)=0 THEN LET P$="C"
 9498 LET FM=FM+1
 9499 RETURN 
 9998 SAVE "THWAR%T"
 9999 RUN 

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.

Scroll to Top