Trailing-Edge
-
PDP-10 Archives
-
AP-5155A-BM
-
binary/ttt.cpl
There are no other files named ttt.cpl in the archive.
10. /* TTT.CPL -- WRITTEN BY JOHN XENAKIS, 1975 */;
20. INIT: ;
30. RANDOM()=0;
40. PUT SKIP LIST('TIC-TAC-TOE');
50. PUT SKIP LIST('CPL WILL PLAY A RANDOM MOVE WHENEVER IT HAS A CHOICE.');
60. PUT SKIP LIST('NOTE: THERE IS ONE METHOD FOR YOU TO WIN.');
70. DECLARE (BOARD,BOARDI)(9) CHAR(1);
80. DECLARE (POSS,VALMVE,EVEN,NINLIS)(9);
90. DO I = 1 TO 9;
100. BOARDI(I)=SUBSTR('123456789',I,1);
110. EVEN(I)=SUBSTR('246800000',I,1);
120. NINLIS(I)=SUBSTR('323242323',I,1);
130. END;
140. DECLARE (LIST,MOVLST)(8,3);
150. DO I=1 TO 8;
160. DO J=1 TO 3;
170. LIST(I,J)=SUBSTR('123456789147258369159357',3*I-3+J,1);
180. END;
190. END;
200. DECLARE VALROW(8),INLIST(9,4,2), TEMP CHAR(81) VAR;
210. TEMP='1141710012510000136181002142000022527282';
220. TEMP=TEMP!!'23620000314383003253000033637300';
230. DO I=1 TO 9;
240. DO J=1 TO 4;
250. DO K=1 TO 2;
260. INLIST(I,J,K)=SUBSTR(TEMP,8*(I-1)+2*(J-1)+K,1);
270. END;END;END;
280. DECLARE SPCASE(9,9);
290. TEMP='00400T3T0000000103700U000U2001000007000000000';
300. TEMP=TEMP!!'3000009009U000U0037090000000T0T00607';
310. DECLARE TEMP1 CHAR(10) VAR;
320. DO I=1 TO 9;
330. DO J=1 TO 9;
340. TEMP1 = SUBSTR(TEMP,9*(I-1)+J,1);
350. IF TEMP1='T' THEN TEMP1='-3';
360. IF TEMP1='U' THEN TEMP1='-1';
370. SPCASE(I,J)=TEMP1;
380. END;END;
390. DECLARE NEWVAL(0:3,0:3);
400. TEMP='0012001E40001600000000001E3000000000000000000000';
410. DO I=0 TO 3;
420. DO J=0 TO 3;
430. NEWVAL(I,J)=SUBSTR(TEMP,12*I+3*J+1,3);
440. END;END;
450. DECLARE RSTATE(8,0:1);
460. DECLARE ANSWER CHAR(20) VAR;
470. START: DO I=1 TO 9;
480. BOARD(I)=BOARDI(I);
490. VALMVE(I)=0;
500. IF I<9 THEN DO;
510. VALROW(I)=0;
520. RSTATE(I,0),RSTATE(I,1)=0;
530. END;END;
540. COUNT,MAXV,POSSN=0;
550. MQ: PUT SKIP LIST('DO YOU WISH TO MOVE FIRST?');
560. READ FILE(SYSIN) INTO(ANSWER);
570. IF ANSWER='N'!ANSWER='NO' THEN GO TO CMOVM;
580. ELSE GO TO OBOARD;
590. ;
600. /* THE HUMAN MOVES NEXT */;
610. HMOVE: PUT SKIP LIST('MOVE:');
620. READ FILE(SYSIN) INTO(ANSWER);
630. ON ERROR GO TO ILMOVE;
640. MOVE=ANSWER;
650. IF MOVE=0 THEN GOTO START;
660. IF BOARD(MOVE)>'9' THEN GO TO ILMOVE;
670. ON ERROR SYSTEM;
680. BOARD(MOVE)='Y';
690. COUNT=COUNT+1;
700. CALL ADJUST(MOVE,0);
710. GO TO CMOVM;
720. ILMOVE: ON ERROR SYSTEM;
73