Trailing-Edge
-
PDP-10 Archives
-
decuslib10-01
-
43,50162/mattac.mac
There are 2 other files named mattac.mac in the archive. Click here to see a list.
TITLE MATTAC
XALL
AC=0
PNT=10
IX=1
RND=11
TST=6
ID=2
BIX=4
ZZ=12
Y=7
X=130
O=117
HLOOP=5
CNT=3
OPDEF TYPE [TTCALL 3,0]
OPDEF TYPE1 [TTCALL 1,0]
LOC 41 ;DEFAULT UUO,DDT AND REENTER POINTS = ST1
XWD 0,ST1
LOC 74
XWD 0,ST1
LOC 124
XWD 0,ST1
LOC 137
XWD 0,2
RELOC
START: TYPE [ASCIZ/
MATRIX TIC-TAC-TOE (V.2 12-70 MEK)
/]
ST1: TYPE [ASCIZ/DO YOU WANT THE INSTRUCTIONS TYPED (Y=YES)? /]
TTCALL 4,AC
TTCALL 11,
TYPE CR
CAIN AC,"Y"
TYPE INS
TYPE [ASCIZ/DO YOU WANT A LIST OF ACCEPTED MOVES TYPED (Y=YES)?/]
TTCALL 4,AC
TTCALL 11,
TYPE CR
CAIN AC,"Y"
TYPE MVTYP
SETOM MFLAG
PLAY1: TYPE [ASCIZ /WILL YOU PLAY 'X' OR 'O'? /]
TTCALL 4,AC
TTCALL 11,
TYPE CR
CAIN AC,"X"
JRST PLX
CAIN AC,"O"
JRST PLO
TYPE [ASCIZ/PLEASE PLAY 'X' OR 'O'.
/]
JRST PLAY1
PLX: MOVEM AC,PPLAY#
MOVEI AC,"O"
MOVEM AC,CPLAY#
JRST XXX
PLO: MOVEM AC,PPLAY
MOVEI AC,"X"
MOVEM AC,CPLAY
XXX: JSR PLSTAT
GO: MOVEI AC," "
MOVEI IX,^D100
CLEAR1: MOVEM AC,A(IX)
SOJGE IX,CLEAR1
TYPE [ASCIZ/THE BOARD HAS BEEN CLEARED.
/]
JRST YMOVE
PPLAY: "?"
CPLAY: "?"
PLSTAT: 0
TYPE [ASCIZ/COMPUTER PLAYS '/]
TYPE1 CPLAY
TYPE [ASCIZ/' PLAYER PLAYS '/]
TYPE1 PPLAY
TYPE [ASCIZ/'
/]
TYPE CR
JRSTF @PLSTAT
CLR: 0
SETZM TEST
MOVE RND,[XWD TEST,TEST+1]
BLT RND,TEST+^D99 ;CLEAR TEST - TEST + 99
JRSTF @CLR
BLKTST: 0
MOVEI ZZ,10
MOVEI ID,^D99
MOVE Y,TEST(ID)
CAIN Y,@ZZ
JRST MOVOK
SOJN ID,.-3
SOJN ZZ,.-5
JRSTF @BLKTST
MOVOK: SETOM CPL
MOVEM PNT,A(ID)
MOVE RND,ID
JRST BLK
TEST:INPT: BLOCK ^D100
;RANDOM MOVE GENERATOR
RAN: MSTIME RND,
ANDI RND,177
CAILE RND,^D99
JRST RAN
MOVE AC,A(RND)
CAIE AC," "
JRST RAN
JSR CMOVE
SETOM CPL
JRST DRTST
;COMPUTER MOVE TYPEOUT SUBROUTINE
CMOVE: 0
TYPE [ASCIZ/COMPUTER MOVES /]
MOVE AC,CPLAY
MOVEM AC,A(RND)
MOVEI AC,"A"
IDIVI RND,^D10
ADD AC,RND
TYPE1 AC
ADDI RND+1,60
TYPE1 RND+1
TYPE CR
JRSTF @CMOVE
;THE MOVTST SUBROUTINE TESTS ALL POSSIBLE MOVE COMBINATIONS
;TO ASSURE THAT A LEGAL MOVE HAS BEEN MADE.
DEFINE COMP (A)
< MOVE AC,MTEST(BIX)
CAMN AC,INPT
JSR A
ADDI BIX,1>
MOVTST: TTCALL 11,
MOVE AC,INPT
MOVE AC,MTEST(BIX)
CAMN AC,INPT
EXIT
ADDI BIX,1
COMP RESTAR
COMP FBOARD
MOVE PNT,[POINT 7,INPT]
ILDB Y,PNT
CAIGE Y,"A"
JRST ERRMZ
CAILE Y,"J"
JRST ERRMZ
ILDB ZZ,PNT
CAIGE ZZ,"0"
JRST ERRMZ
CAILE ZZ,"9"
JRST ERRMZ
MOVE TST,INPT ;INPT HAS MOVE IN ASCII
TLZ TST,777760 ;CLEAR FIRST TWO ASCII CHARACTERS TO BUILD MOVE MASK
SKIPE TST
JRST ERRMZ
SUBI ZZ,60
SUBI Y,101
IMULI Y,12
ADDI Y,A
ADD ZZ,Y
MADDR: MOVE TST,@ZZ
CAIN TST," "
JRST OK
CAMN TST,PPLAY
TYPE [ASCIZ/YOU HAVE ALREADY USED THAT MOVE.
/]
CAME TST,PPLAY
TYPE [ASCIZ/THE COMPUTER HAS ALREADY USED THAT MOVE.
/]
YMOVE: SETZB BIX,INPT
MOVE PNT,[POINT 7,INPT]
SETZM MFLAG#
TYPE [ASCIZ/YOUR MOVE IS - /]
TTYIN: TTCALL 4,AC
CAIN AC,15
JRST MOVTST
IDPB AC,PNT
JRST TTYIN
OK: MOVE TST,PPLAY
MOVEM TST,@MADDR
SETZM PASS2
SETZM PASS3
SETZM PASS4
SETZM CPL#
SETZM CPLA#
JSR HSUM
SETOM CPLA
SETOM PASS1# ;PASS ONE TESTS FOR 4 IN A ROW FOR COMPUTER.
JSR CLR
JSR HSUM
JSR CLR
SETZM PASS1
JSR HSUM
JSR CLR
TWO: SETOM PASS2
JSR HSUM
JSR CLR
SETOM PASS1
JSR HSUM
JSR CLR
THREE: SETOM PASS3
SETZM PASS2
SETZM PASS1
JSR HSUM
JSR CLR
SETOM PASS1
JSR HSUM
JSR CLR
SETZM PASS3
FOUR: SETOM PASS4
SETZM PASS1
JSR HSUM
JSR CLR
SETOM PASS1
JSR HSUM
DRTST: MOVEI IX,^D99
MOVEI AC," "
TSTA: CAME AC,A(IX)
JRST TSTX
SKIPN CPL
JRST RAN
JRST YMOVE
TSTX: SOJGE IX,TSTA
TYPE [ASCIZ/THE GAME IS A DRAW. /]
JRST PCON
MTEST: ASCII /EXIT/
ASCII /RESTA/
ASCII /BOARD/
ERRMZ: SKIPN MFLAG
TYPE [ASCIZ/INVALID ENTRY, TRY AGAIN.
/]
JRST YMOVE
;RESTART CONTROL SUBROUTINE
RESTAR: 0
TYPE CR
JSR PLSTAT
JRST GO
;BOARD TYPEOUT SUBROUTINE
FBOARD: 0
TYPE CR
HD: TYPE [ASCIZ/ 0 1 2 3 4 5 6 7 8 9
/]
MOVEI IX,0
MOVEI AC,"A"
FBD1: HRLI IX,-12
TYPE1 AC
TYPE1 SP
FBD2: TYPE1 DASH
TYPE1 A(IX)
AOBJN IX,FBD2
TYPE1 DASH
TYPE1 SP
TYPE1 AC
TYPE CR
ADDI AC,1
CAIE AC,"K"
JRST FBD1
XCT HD
SETOM MFLAG
JRSTF @FBOARD
DASH: 055
SP: 40
;WIN TESTING SUBROUTINE - THE STATUS OF A MOVE COMBINATION
;IS LOADED INTO AC BY THE SUMMING ROUTINE WHICH THEN JSR'S
;HERE TO SEE IF THIS MOVE COMBINATION CONTAINS A WIN.
WINTST: 0
MOVEI PNT,@PPLAY
IMULI PNT,5
CAIN AC,5*X
JRST XWIN
CAIN AC,5*O
JRST OWIN
JRSTF @WINTST
XWIN: CAMN AC,PNT
JRST PWIN
JRST CWIN
OWIN: CAMN AC,PNT
JRST PWIN
CWIN: TYPE [ASCIZ/COMPUTER HAS WON. /]
JRST PCON
PWIN: TYPE [ASCIZ/YOU HAVE WON. /]
PCON: TYPE [ASCIZ/DO YOU WANT A FINAL BOARD TYPEOUT? (Y=YES) /]
TTCALL 4,AC
TTCALL 11,
MOVEM AC,TEMP#
MOVEI AC,"*"
MOVEM AC,@13
MOVEM AC,@14
MOVEM AC,@15
MOVEM AC,@16
MOVEM AC,@17
MOVE AC,TEMP
CAIN AC,"Y"
JSR FBOARD
PCONX: TYPE [ASCIZ/WOULD YOU LIKE TO PLAY ANOTHER GAME? (Y=YES) /]
TTCALL 4,AC
TTCALL 11,
TYPE CR
CAIN AC,"Y"
JRST GO
EXIT
;SUMMING NETWORK - THIS SUBROUTINE ADDS ALL WIN COMBINATIONS
;AND DOES A JSR TO WINTST FOR EACH ONE TO TEST FOR A WIN.
HSUM: 0
SETZM TSTLOC
MOVEI HLOOP,12
MOVEI CNT,0
MOVEI IX,A
LOOPA: HRLI CNT,-6
LOOPB: MOVEI AC,0
ADD AC,0(IX)
ADD AC,1(IX)
ADD AC,2(IX)
ADD AC,3(IX)
ADD AC,4(IX)
DEFINE SETUP
< MOVEI 13,@.-5
MOVEI 14,@.-5
MOVEI 15,@.-5
MOVEI 16,@.-5
MOVEI 17,@.-5
JSR WINTST
SKIPE CPLA
JSR CHECK>
SETUP
AOJ IX,
AOBJN CNT,LOOPB
ADDI IX,4
SOJN HLOOP,LOOPA
VSUM: MOVEI HLOOP,12
MOVEI IX,0
LOOPC: HRLI CNT,-6
LOOPD: MOVEI AC,0
ADD AC,A(IX)
ADD AC,B(IX)
ADD AC,C(IX)
ADD AC,D(IX)
ADD AC,E(IX)
SETUP
ADDI IX,12
AOBJN CNT,LOOPD
SUBI IX,^D59
SOJN HLOOP,LOOPC
RSUM: MOVEI HLOOP,6
MOVEI IX,0
LOOPE: HRLI CNT,-6
LOOPF: MOVEI AC,0
ADD AC,A+4(IX)
ADD AC,B+3(IX)
ADD AC,C+2(IX)
ADD AC,D+1(IX)
ADD AC,E (IX)
SETUP
ADDI IX,12
AOBJN CNT,LOOPF
SUBI IX,^D59
SOJN HLOOP,LOOPE
LSUM: MOVEI HLOOP,6
MOVEI IX,0
LOOPG: HRLI CNT,-6
LOOPH: MOVEI AC,0
ADD AC,A (IX)
ADD AC,B+1(IX)
ADD AC,C+2(IX)
ADD AC,D+3(IX)
ADD AC,E+4(IX)
SETUP
ADDI IX,12
AOBJN CNT,LOOPH
SUBI IX,^D59
SOJN HLOOP,LOOPG
SKIPE TSTLOC#
JSR BLKTST
JRSTF @HSUM
CHECK: 0
DEFINE TEST (X)
< MOVE Y,@X
CAIE Y," "
JRST .+4
SUBI X,A
SETOM TSTLOC
AOS TEST(X)>
MOVE PNT,CPLAY
CAIE PNT,"X"
JRST XTEST
OTEST: SKIPE PASS1
JRST XTEST+2
SKIPE PASS2#
JRST COMP2
SKIPE PASS3#
JRST COMP3
SKIPE PASS4#
JRST COMP4
CAIE AC,4*O+40
JRSTF @CHECK
JRST BLOCK1
COMP2: CAIE AC,3*O+2*40
JRSTF @CHECK
JRST BLOCK1
COMP2A: CAIN AC,3*X+2*40
JRST BLOCK1
JRSTF @CHECK
COMP3: CAIE AC,2*O+3*40
JRSTF @CHECK
JRST BLOCK1
COMP3A: CAIN AC,2*X+3*40
JRST BLOCK1
JRSTF @CHECK
COMP4: CAIE AC,1*O+4*40
JRSTF @CHECK
JRST BLOCK1
COMP4A: CAIN AC,1*X+4*40
JRST BLOCK1
JRSTF @CHECK
BLOCK1: TEST 15
TEST 16
TEST 14
TEST 17
TEST 13
JRSTF @CHECK
BLK: JSR CMOVE
SETZM CPLA
JSR HSUM
JRST YMOVE
XTEST: SKIPE PASS1
JRST OTEST+2
SKIPE PASS2
JRST COMP2A
SKIPE PASS3
JRST COMP3A
SKIPE PASS4
JRST COMP4A
CAIN AC,4*X+40
JRST BLOCK1
JRSTF @CHECK
;RESERVE 100 LOCATIONS FOR THE BOARD MATRIX
A: BLOCK 12
B: BLOCK 12
C: BLOCK 12
D: BLOCK 12
E: BLOCK 12
F: BLOCK ^D10*5
;ASCII TEXT LIST
INS: ASCIZ/
MATRIX TIC-TAC-TOE IS PLAYED ON A TEN BY TEN MATRIX IN A MANNER
SIMILAR TO ORDINARY TIC-TAC-TOE. THE PLAYER AND THE COMPUTER WILL
ALTERNATELY PLACE A MOVE AT ONE OF THE MATRIX COORDINATES. EACH
WILL TRY TO PLACE FIVE MOVES IN A ROW TO EFFECT A WIN. THE PLAYER
WILL ALWAYS BE GIVEN THE FIRST MOVE. THIS FORCES THE COMPUTER TO
PLAY DEFENSIVELY AND GIVES THE PLAYER A REASONABLE PROBABILITY OF
WINNING. THERE ARE 192 WIN COMBINATIONS ON THE BOARD. GOOD LUCK.
/
MVTYP: ASCIZ/
THE AVAILABLE MOVES ARE:
(A0-J9) -BOARD COORDINATES AT WHICH THE PLAYER WISHES TO PLACE
HIS MOVE.
EXIT -TERMINATES THE GAME.
BOARD -PRINTS MATRIX SHOWING ALL MOVES THAT HAVE BEEN MADE .
RESTART -CLEARS THE BOARD AND RESTARTS THE GAME.
/
CR: ASCIZ/
/
END START