Trailing-Edge
-
PDP-10 Archives
-
decus_20tap1_198111
-
decus/20-0020/tictac.gam
There are 2 other files named tictac.gam in the archive. Click here to see a list.
100' NAME--TICTAC
110'
120' DESCRIPTION--PLAYS GAME OF TIC-TAC-TOE
130'
140' SOURCE--UNKNOWN
150'
160' INSTRUCTIONS--TYPE "RUN" AND FOLLOW INSTRUCTIONS.
170'
180'
190' * * * * * * MAIN PROGRAM * * * * * * * * * * *
200'
210 PRINT "WELCOME TO TIME-SHARING TIC-TAC-TOE. THE BOARD IS LAID OUT"
220 PRINT "AS FOLLOWS:"
230 PRINT
240 PRINT "1 2 3"
250 PRINT "4 5 6"
260 PRINT "7 8 9"
270 PRINT
280 PRINT "WHEN THE MACHINE ASKS FOR YOUR MOVE, RESPOND WITH THE NUMBER"
290 PRINT "WHICH CORRESPONDS TO THE INTENDED SQUARE."
300 PRINT
310 DIM B(2,2)
320 FOR I = 0 TO 2
330 FOR J = 0 TO 2
340 LET B(I,J) = 0
350 NEXT J
360 NEXT I
370 LET P = 1
380 PRINT "DO YOU WANT ME TO GO FIRST (1 FOR YES, 0 FOR NO)";
390 INPUT F
400 IF F = 0 THEN 430
410 PRINT "I PLAY X, YOU PLAY O"
420 GO TO 540
430 PRINT "YOU PLAY X, I PLAY O"
440 PRINT "YOUR MOVE: ";
450 GOSUB 780
460 GOSUB 1100
470 GOSUB 2290
480 GOSUB 1500
490 IF M <> 0 THEN 710
500 GOSUB 2290
510 GOSUB 1500
520 GOSUB 2290
530 IF M <> 0 THEN 710
540 LET M = 5
550 IF B(1,1) = 0 THEN 710
560 LET M = 1
570 IF B(0,0) = 0 THEN 710
580 LET M = 3
590 IF B(0,2) = 0 THEN 710
600 LET M = 7
610 IF B(2,0) = 0 THEN 710
620 LET M = 9
630 IF B(2,2) = 0 THEN 710
640 LET M = 2
650 IF B(0,1) = 0 THEN 710
660 LET M = 4
670 IF B(1,0) = 0 THEN 710
680 LET M = 6
690 IF B(1,2) = 0 THEN 710
700 LET M = 8
710 GOSUB 790
720 PRINT "I MOVE"M
730 GOSUB 910
740 GOSUB 1100
750 GOSUB 2290
760 GOTO 440
770 REM SUBROUTINE TO INPUT MOVES
780 INPUT M
790 IF M > 9 THEN 810
800 IF M > 0 THEN 830
810 PRINT "MOVE NOT ON BOARD. MOVE AGAIN: ";
820 GOTO 780
830 LET M1 = INT((M-1)/3)
840 LET M2 = M - 3*M1 - 1
850 IF B(M1,M2) = 0 THEN 880
860 PRINT "SQUARE ALREADY TAKEN. MOVE AGAIN: ";
870 GOTO 780
880 LET B(M1,M2) = P
890 RETURN
900 REM SUBROUTINE TO PRINT OUT T-T-T BOARD
910 FOR I = 0 TO 2
920 PRINT
930 FOR J = 0 TO 2
940 IF B(I,J) <> 0 THEN 970
950 PRINT "- ";
960 GOTO 1040
970 IF B(I,J) <> 1 THEN 1000
980 PRINT "X ";
990 GOTO 1040
1000 IF B(I,J) <> 2 THEN 1030
1010 PRINT "O ";
1020 GOTO 1040
1030 PRINT "? ";
1040 NEXT J
1050 NEXT I
1060 PRINT
1070 PRINT
1080 RETURN
1090 REM SUBROUTINE TO DETECT THAT PLAYER P HAS WON
1100 IF B(0,0) <> P THEN 1170
1110 IF B(0,1) <> P THEN 1130
1120 IF B(0,2) = P THEN 1390
1130 IF B(1,0) <> P THEN 1150
1140 IF B(2,0) = P THEN 1390
1150 IF B(1,1) <> P THEN 1170
1160 IF B(2,2) = P THEN 1390
1170 IF B(0,1) <> P THEN 1200
1180 IF B(1,1) <> P THEN 1200
1190 IF B(2,1) = P THEN 1390
1200 IF B(0,2) <> P THEN 1250
1210 IF B(1,1) <> P THEN 1230
1220 IF B(2,0) = P THEN 1390
1230 IF B(1,2) <> P THEN 1250
1240 IF B(2,2) = P THEN 1390
1250 IF B(1,0) <> P THEN 1280
1260 IF B(1,1) <> P THEN 1280
1270 IF B(1,2) = P THEN 1390
1280 IF B(2,0) <> P THEN 1310
1290 IF B(2,1) <> P THEN 1310
1300 IF B(2,2) = P THEN 1390
1310 FOR I = 0 TO 2
1320 FOR J = 0 TO 2
1330 IF B(I,J) <> 0 THEN 1350
1340 RETURN
1350 NEXT J
1360 NEXT I
1370 PRINT "***** DRAW *****"
1380 GOTO 1430
1390 IF P = 2 THEN 1420
1400 PRINT "***** X WINS *****"
1410 GOTO 1430
1420 PRINT "***** O WINS *****"
1430 PRINT
1440 PRINT
1450 PRINT
1460 PRINT "NEW GAME:"
1470 PRINT
1480 GOTO 310
1490 REM SUBROUTINE TO DETERMINE WINNING MOVES AND FORCED BLOCKS
1500 IF B(0,0) <> P THEN 1630
1510 IF B(0,1) <> P THEN 1530
1520 IF B(0,2) = 0 THEN 2140
1530 IF B(0,2) <> P THEN 1550
1540 IF B(0,1) = 0 THEN 2120
1550 IF B(1,1) <> P THEN 1570
1560 IF B(2,2) = 0 THEN 2260
1570 IF B(2,2) <> P THEN 1590
1580 IF B(1,1) = 0 THEN 2180
1590 IF B(1,0) <> P THEN 1610
1600 IF B(2,0) = 0 THEN 2220
1610 IF B(2,0) <> P THEN 1630
1620 IF B(1,0) = 0 THEN 2160
1630 IF B(0,1) <> P THEN 1720
1640 IF B(0,0) <> P THEN 1660
1650 IF B(0,2) = 0 THEN 2140
1660 IF B(0,2) <> P THEN 1680
1670 IF B(0,0) = 0 THEN 2100
1680 IF B(1,1) <> P THEN 1700
1690 IF B(2,1) = 0 THEN 2240
1700 IF B(2,1) <> P THEN 1720
1710 IF B(1,1) = 0 THEN 2180
1720 IF B(0,2) <> P THEN 1810
1730 IF B(1,1) <> P THEN 1750
1740 IF B(2,0) = 0 THEN 2220
1750 IF B(2,0) <> P THEN 1770
1760 IF B(1,1) = 0 THEN 2180
1770 IF B(1,2) <> P THEN 1790
1780 IF B(2,2) = 0 THEN 2260
1790 IF B(2,2) <> P THEN 1810
1800 IF B(1,2) = 0 THEN 2200
1810 IF B(1,0) <> P THEN 1880
1820 IF B(2,0) <> P THEN 1840
1830 IF B(0,0) = 0 THEN 2100
1840 IF B(1,1) <> P THEN 1860
1850 IF B(1,2) = 0 THEN 2200
1860 IF B(1,2) <> P THEN 1880
1870 IF B(1,1) = 0 THEN 2180
1880 IF B(1,1) <> P THEN 1970
1890 IF B(2,2) <> P THEN 1910
1900 IF B(0,0) = 0 THEN 2100
1910 IF B(2,0) <> P THEN 1930
1920 IF B(0,2) = 0 THEN 2140
1930 IF B(2,1) <> P THEN 1950
1940 IF B(0,1) = 0 THEN 2120
1950 IF B(1,2) <> P THEN 1970
1960 IF B(1,0) = 0 THEN 2160
1970 IF B(1,2) <> P THEN 2000
1980 IF B(2,2) <> P THEN 2000
1990 IF B(0,2) = 0 THEN 2140
2000 IF B(2,0) <> P THEN 2050
2010 IF B(2,1) <> P THEN 2030
2020 IF B(2,2) = 0 THEN 2260
2030 IF B(2,2) <> P THEN 2050
2040 IF B(2,1) = 0 THEN 2240
2050 IF B(2,1) <> P THEN 2080
2060 IF B(2,2) <> P THEN 2080
2070 IF B(2,0) = 0 THEN 2220
2080 LET M = 0
2090 RETURN
2100 LET M = 1
2110 RETURN
2120 LET M = 2
2130 RETURN
2140 LET M = 3
2150 RETURN
2160 LET M = 4
2170 RETURN
2180 LET M = 5
2190 RETURN
2200 LET M = 6
2210 RETURN
2220 LET M = 7
2230 RETURN
2240 LET M = 8
2250 RETURN
2260 LET M = 9
2270 RETURN
2280 REM SUBROUTINE TO FLIP-FLOP PLAYER P
2290 IF P = 1 THEN 2320
2300 LET P = 1
2310 RETURN
2320 LET P = 2
2330 RETURN
2340 END