$INTEGER*4                                                              00001000
$CONTROL FILE=1-10                                                      00002000
C       * THIS PROGRAM MODIFIED TO RUN ON HP3000 AND CONTRIBUTED   *    00003000
C       * BY MEL BAILEY, HP-RICHARDSON,TEXAS.... THIS VERSION USES *    00004000
C       * ALL DOUBLE INTEGERS AND IS EXTREMELY INEFFICIENT....     *    00005000
C       *                                                          *    00006000
C       *                                                          *    00007000
C       ****************************************************************00008000
C       *                                                               00009000
C       *    *****   *      ***   *****  *****      ***  *     *        00010000
C       *    *    *  *       *      *        *       *   *     *        00011000
C       *    *    *  *       *      *       *        *    *   *         00012000
C       *    *****   *       *      *      *         *    *   *         00013000
C       *    *    *  *       *      *     *          *     * *          00014000
C       *    *    *  *       *      *    *           *     * *          00015000
C       *    *****   *****  ***     *    *****      ***     *           00016000
C       *                                                               00017000
C       ****************************************************************00018000
C       *                                                               00019000
C       *      BLITZ IV IS THE FOURTH MAJOR VERSION OF A CHESS          00020000
C       *  PLAYING PROGRAM WRITTEN AT THE UNIVERSITY OF SOUTHERN        00021000
C       *  MISSISSIPPI BY ROBERT HYATT.  IT USES SHANNON'S TYPE         00022000
C       *  'A' ALPHA-BETA TREE SEARCHING STRATEGY WITH FORWARD          00023000
C       *  PRUNING.  ALL PARAMETERS CAN BE SET BY THE PLAYER (SEE       00024000
C       *  COMMENTS IN EACH MODULE WITH A NAME ENDING IN 'CMND')        00025000
C       *  TO CONTROL THE SPEED (AND QUALITY) OF PLAY.                  00026000
C       *                                                               00027000
C       *      MAIN IS THE DRIVER OF THE PROGRAM.  IT IS CONCERNED      00028000
C       *  WITH READING INPUT, CALLING APPROPRIATE ROUTINES, AND        00029000
C       *  OUTPUTTING THE COMPUTERS CHOSEN MOVE.  IT ALSO KEEPS         00030000
C       *  WITH MOVE TIMING TO MAINTAIN THE CHESS CLOCK TIMES FOR       00031000
C       *  BOTH SIDES.                                                  00032000
C       *                                                               00033000
C       ****************************************************************00034000
C                                                                       00035000
      IMPLICIT INTEGER*4 (A-Z)                                          00036000
      SYSTEM INTRINSIC TIMER, PROCTIME, XCONTRAP, COMMAND               00037000
      COMMON /BUFFER/ TEXT(30)                                          00038000
      CHARACTER*5 WHITE,BLACK,CCOLOR,HCOLOR                             00039000
      COMMON /BOARD/ BOARD(120)                                         00040000
      COMMON /PC CM/ CMNDS(10,3), NCMNDS, PCMODE, EXMODE                00041000
      COMMON /DATA/ CMOVE, SMOVE, HFROM8, HTO8, HTYPE8, MOVE            00042000
      COMMON /TREE/ TREE(400),START(10),STOP(10),WHICH(10),BACKUP(10),  00043000
     *FROM(10),TO(10),VALUE(10),TYPE(10),PLY                            00044000
      COMMON /PRUNE/ WIDTH(10), MIN(10), MAX(10),                       00045000
     * DEPTH, ORDER1, ORDER2                                            00046000
      COMMON /INFO/ TYPE8, VALUE8, TO8, FROM8                           00047000
      LOGICAL CHECK, DRAW, CQUERY                                       00048000
      COMMON /TRACE/ TRACE(20,10),TFLAG                                 00049000
      COMMON /TYPES/ NORMAL,CASTRT,CASTLF,ENPASS,PROMOTE                00050000
      COMMON /CLOK CM/ CLOCK,CTYPE,CQUERY,GELAP,CELAP,HELAP,            00051000
     *ELAPC,ELAPH,MOVES,SMOVES,SELAP,CTOTAL,HTOTAL,OPTIME               00052000
      COMMON /DUP/ PACK(8),POINT,BDSAVE(30,8)                           00053000
      INTEGER*4 BELL                                                    00054000
      INTEGER*2 OFF, DMY, IERR, IPARM                                   00055000
      COMMON /NAME CM/ NAME(5)                                          00056000
      COMMON /TRCE CM/ STRACE(20), TSCORE                               00057000
      COMMON /STAT CM/ NODES(10), NGEN, MAXPLY, PRIGHT                  00058000
      LOGICAL IN BOOK                                                   00059000
      LOGICAL CLOCK                                                     00060000
      COMMON /BOOK CM/ KEY ,IN BOOK                                     00061000
      COMMON /COLR CM/ CCOLOR, HCOLOR, COLOR                            00062000
      COMMON /HIST CM/ NMOVES, ANNOTE                                   00063000
      COMMON /BRK CM/ CSEC1, CSEC2, HSEC1, HSEC2                        00064000
      COMMON /SAVE CM/ SBOARD(100)                                      00065000
      COMMON /V CM/ VCMOVE                                              00066000
      COMMON /MOV TIM/ MELAP, MSEC1, MSEC2                              00067000
      LOGICAL PCMODE, EXMODE, AUTO                                      00068000
      COMMON /INIT/ INITIM                                              00069000
      COMMON /CHRSET/ ALPHA(44)                                         00070000
      EQUIVALENCE (BLANK,ALPHA(44)),(G,ALPHA(7)),(O,ALPHA(15))          00071000
      EQUIVALENCE (Y,ALPHA(25))                                         00072000
      COMMON /MOV CNT/ NCMOVS, NHMOVS                                   00073000
      COMMON /P V MOVE/ PVMOVE, OVMOVE                                  00074000
      CHARACTER*32 BFFR                                                 00075000
      DATA ZERO /0J/,WHITE/'WHITE'/,BLACK/'BLACK'/,BELL/%""J/         00076000
      DATA OFF / 0 /, AUTO / .FALSE./                                   00077000
C------------------------------< DETERMINE COLOR DESIRED AND            00078000
C------------------------------< INITIALIZE DATA AREA                   00079000
      BFFR="FILE FTN10;DEV=LP"                                          00080000
      BFFR[18:1]=%15C                                                   00081000
      CALL COMMAND(BFFR,IERR,IPARM)                                     00082000
      INITIM=TIMER/1000                                                 00083000
  888 WRITE(6,1)                                                        00084000
1     FORMAT(1X,'BLITZ IV HERE'/1X,'WHAT IS YOUR NAME?')                00085000
      READ(5,2)NAME                                                     00086000
2     FORMAT(5A4)                                                       00087000
      CALL SETIO(AUTO,$888)                                             00088000
      WRITE(6,3)                                                        00089000
3     FORMAT(1X,'SHOULD I PLAY WHITE?')                                 00090000
4     READ(5,5)ANS                                                      00091000
5     FORMAT(R1)                                                        00092000
      IF(ANS.NE.Y) GOTO 7                                               00093000
      HCOLOR=BLACK                                                      00094000
      CCOLOR=WHITE                                                      00095000
      COLOR=1                                                           00096000
7     IF(.NOT.AUTO)CALL SETGB                                           00097000
      CALL SAVE GB                                                      00098000
91    CALL CTIME(CSEC1)                                                 00099000
      IF(.NOT. AUTO .AND. NMOVES.GT.0) GO TO 911                        00100000
C                                                                       00101000
C------------------------------< IF RE-STARTING A GAME, CHECK TO SEE    00102000
C------------------------------< IF IT'S THE PROGRAM'S TURN TO MOVE.    00103000
C------------------------------< IF SO, CALCULATE MOVE.                 00104000
C                                                                       00105000
      I=1-MOD(NMOVES,2)                                                 00106000
      IF(I.EQ.COLOR) GO TO 20                                           00107000
911   CALL ETIME(HSEC1)                                                 00108000
C                                                                       00109000
C------------------------------< MAIN LOOP                              00110000
C                                                                       00111000
C                                                                       00112000
C------------------------------< IF THE CLOCK QUERY FLAG IS SET         00113000
C------------------------------< (CQUERY), THEN THE PROGRAM WILL        00114000
C------------------------------< ASK HOW MUCH TIME IT HAS ON THE        00115000
C------------------------------< CLOCK EVERY SO OFTEN.                  00116000
C                                                                       00117000
9     IF(CQUERY) CALL QUERY                                             00118000
      WRITE(6,10)BELL                                                   00119000
10    FORMAT(1X,A4)                                                     00120000
918   CALL SAVE GM                                                      00121000
      WRITE(6,12)NAME                                                   00122000
12    FORMAT(1X,'YOUR MOVE, ',5A4)                                      00123000
C                                                                       00124000
C------------------------------< IF IN THINK-AHEAD MODE, MAKE           00125000
C------------------------------< THE PREDICTED HUMAN RESPONSE           00126000
C------------------------------< AND THINK ON HIS TIME                  00127000
C                                                                       00128000
      CALL THINK($184,$182)                                             00129000
C                                                                       00130000
C------------------------------< INPUT COMMAND OR MOVE                  00131000
C                                                                       00132000
171   MOVE=(NCMOVS+NHMOVS)/2+1                                          00133000
      READ(5,18)TEXT                                                    00134000
      IF(TEXT(1).EQ.G.AND.TEXT(2).EQ.O) GO TO 20                        00135000
18    FORMAT(30R1)                                                      00136000
182   CALL OPTION($918)                                                 00137000
      CALL INMOVE(0,$918)                                               00138000
      NHMOVS=NHMOVS+1                                                   00139000
      MOVE=(NCMOVS+NHMOVS)/2+1                                          00140000
      CALL ETIME(HSEC2)                                                 00141000
      CALL CTIME(CSEC1)                                                 00142000
      GO TO 184                                                         00143000
184   ELAPH=HSEC2-HSEC1-OPTIME                                          00144000
      IF(ELAPH.LT.0) ELAPH=0                                            00145000
      NMOVES=NMOVES+1                                                   00146000
      WRITE(1@NMOVES)TEXT,ELAPH,ZERO                                    00147000
      HELAP=HELAP+ELAPH                                                 00148000
      IF(.NOT. CLOCK) GO TO 19                                          00149000
      WRITE(6,5579)ELAPH                                                00150000
5579  FORMAT(1X,'YOU TOOK',I4,' SECONDS TO MOVE')                       00151000
      IF(HELAP.GT.GELAP) WRITE(6,4499)NAME                              00152000
4499  FORMAT(1X,'YOU HAVE EXCEEDED TIME LIMIT, ',5A4)                   00153000
      CALL SETCLK                                                       00154000
19    HTO8=TO8                                                          00155000
      HFROM8=FROM8                                                      00156000
      HTYPE8=TYPE8                                                      00157000
      PLY=20                                                            00158000
      IF(TYPE8.NE.PROMOTE)  GO TO 1977                                  00159000
      BOARD(FROM8)=VALUE8                                               00160000
      TYPE8=1                                                           00161000
1977  CALL PMOVER                                                       00162000
      CALL SAVE GB                                                      00163000
      CALL SAVE GM                                                      00164000
20    CALL PREANL                                                       00165000
      ON CONTROLY CALL BRK ON                                           00166000
C                                                                       00167000
C------------------------------< EITHER:  A)  CALL BOOK TO FIND         00168000
C------------------------------<              THE MOVE,                 00169000
C------------------------------<          B)  CALL LOOK TO CALCULATE    00170000
C------------------------------<              THE MOVE, OR              00171000
C------------------------------<          C)  IF THINK-AHEAD HAS        00172000
C------------------------------<              FOUND THE RESPONSE,       00173000
C------------------------------<              USE THE TREE FOUND.       00174000
C                                                                       00175000
      CALL MATCH($6300)                                                 00176000
      IF(IN BOOK) CALL BOOK                                             00177000
      IF(IN BOOK) PRIGHT=PRIGHT+1                                       00178000
      IF(IN BOOK) GO TO 6300                                            00179000
6200  CALL CTIME(MSEC1)                                                 00180000
      CALL LOOK                                                         00181000
      CALL CTIME(MSEC2)                                                 00182000
      MELAP=MSEC2-MSEC1                                                 00183000
6300  TFLAG=0                                                           00184000
      CALL XCONTRAP(OFF,DMY)                                            00185000
      DO 162 I=1,20                                                     00186000
          STRACE(I)=TRACE(I,1)                                          00187000
162   CONTINUE                                                          00188000
      TSCORE=BACKUP(1)                                                  00189000
      OVMOVE=PVMOVE                                                     00190000
      P V MOVE = STRACE(3)                                              00191000
      IF(DEPTH.LT.3) PVMOVE=0                                           00192000
      PLY=1                                                             00193000
      IF(CMOVE+SMOVE.EQ.0) GO TO 47                                     00194000
      IF(CMOVE.NE.0) GO TO 126                                          00195000
      CMOVE=SMOVE                                                       00196000
      GO TO 207                                                         00197000
126   IF(SMOVE.EQ.0) GO TO 207                                          00198000
C                                                                       00199000
C------------------------------< CHECK TO ACCEPT/AVOID                  00200000
C------------------------------< STALEMATE OR DRAWING MOVES             00201000
C                                                                       00202000
      IF(.NOT. DRAW(SCORE)) GO TO 207                                   00203000
      WRITE(6,55332)SCORE                                               00204000
55332 FORMAT(1X,'DRAWING SCORE = ',I6)                                  00205000
210   CMOVE=SMOVE                                                       00206000
      SMOVE=-1                                                          00207000
C                                                                       00208000
C------------------------------< OUTPUT PROGRAM'S SELECTED MOVE         00209000
C                                                                       00210000
207   FROM8=CMOVE                                                       00211000
      CALL EXTRCT                                                       00212000
      CALL PMOVER                                                       00213000
      MTYPE=0                                                           00214000
      IF(CHECK(.TRUE.)) MTYPE=1                                         00215000
      IF(CMOVE.LT.0) MTYPE=2                                            00216000
      IF(BACKUP(1).EQ.9998) MTYPE=3                                     00217000
      CALL OUTMOV(FROM8,TO8,TYPE8,MTYPE,1,SBOARD)                       00218000
4321  FORMAT(30R1)                                                      00219000
      WRITE(6,282)TEXT                                                  00220000
282   FORMAT(/1X,'MY MOVE IS ',30R1/)                                   00221000
      CALL SAVE GB                                                      00222000
      NCMOVS=NCMOVS+1                                                   00223000
      VCMOVE=CMOVE                                                      00224000
      CALL CTIME(CSEC2)                                                 00225000
      ELAPC=CSEC2-CSEC1                                                 00226000
      IF(.NOT. CLOCK) GO TO 4479                                        00227000
      WRITE(6,3759)ELAPC                                                00228000
3759  FORMAT(1X,'I TOOK',I4,' SECONDS TO MOVE')                         00229000
      CALL SETCLK                                                       00230000
      IF(CELAP.GT.GELAP) WRITE(6,4488)NAME                              00231000
4488  FORMAT(1X,'I HAVE EXCEEDED THE TIME LIMIT, ',5A4)                 00232000
4479  NMOVES=NMOVES+1                                                   00233000
      WRITE(1@NMOVES)TEXT,ELAPC,ZERO                                    00234000
      CELAP=CELAP+ELAPC                                                 00235000
      CALL COMPRS                                                       00236000
      POINT=POINT+1                                                     00237000
      IF(POINT.GT.30) POINT=1                                           00238000
      DO 220 I=1,8                                                      00239000
          BDSAVE(POINT,I)=PACK(I)                                       00240000
220   CONTINUE                                                          00241000
      CALL ETIME(HSEC1)                                                 00242000
      IF(PCMODE) CALL EXEC PC                                           00243000
      CALL ETIME(HSEC1)                                                 00244000
      IF(SMOVE.EQ.-1) GO TO 47                                          00245000
      GO TO 9                                                           00246000
C                                                                       00247000
C------------------------------< GAME OVER, PRINT BOARD AND STOP        00248000
C                                                                       00249000
45    WRITE(6,46)HCOLOR                                                 00250000
46    FORMAT(1X,A5,' RESIGNS ')                                         00251000
      GO TO 9                                                           00252000
47    IF(CHECK(.FALSE.)) GO TO 49                                       00253000
      IF(MTYPE.EQ.2)  WRITE(6,221)NAME                                  00254000
221   FORMAT(1X,'I CLAIM A DRAW BY THE REPITITION OF'/                  00255000
     *1X,'  POSITIONS RULE, ',5A4)                                      00256000
      IF(MTYPE.NE.2)  WRITE(6,48)NAME                                   00257000
48    FORMAT(1X,'GAME IS A STALEMATE, ',5A4)                            00258000
      GO TO 9                                                           00259000
49    WRITE(6,99)NAME                                                   00260000
99    FORMAT(1X,'CHECKMATE!  CONGRATULATIONS, ',5A4)                    00261000
      GO TO 9                                                           00262000
      END                                                               00263000
$CONTROL SEGMENT=CMND                                                   00264000
      SUBROUTINE ACMND                                                  00265000
C                                                                       00266000
C       ************************************************************    00267000
C       *                                                          *    00268000
C       *      ACMND IS USED TO ANNOTATE THE GAME HISTORY FILE.    *    00269000
C       *  THIS IS DONE TO COMMENT PARTICULAR MOVES FOR LATER      *    00270000
C       *  REFERENCE WHEN EVALUATING THE GAME.  IF THE MACHINE     *    00271000
C       *  MAKES SOME STRANGE LOOKING MOVE, A COMMENT CAN BE EN-   *    00272000
C       *  TERED WITH THAT MOVE AS A REMINDER TO LATER CHECK OUT   *    00273000
C       *  THAT MOVE TO SEE WHY IT WAS MADE.                       *    00274000
C       *                                                          *    00275000
C       ************************************************************    00276000
C                                                                       00277000
      IMPLICIT INTEGER*4 (A-Z)                                          00278000
      COMMON /HIST CM/ NMOVES, ANNOTE                                   00279000
      COMMON /TREE/ DUMMY(480), PLY                                     00280000
      COMMON /CHRSET/ ALPHA(44)                                         00281000
      EQUIVALENCE (BLANK,ALPHA(44))                                     00282000
      INTEGER*4 DATA(32),TEXT(31)                                       00283000
      EQUIVALENCE (DUMMY(1),DATA(1)),(DUMMY(33),TEXT(1))                00284000
      DATA ZERO /0J/                                                    00285000
C                                                                       00286000
C------------------------------< DETERMINE WHICH MOVE TO ANNOTATE       00287000
C------------------------------< AND LOCATE IT.                         00288000
C                                                                       00289000
      WRITE(6,100)                                                      00290000
100   FORMAT(1X,'ANNOTATE WHICH MOVE?')                                 00291000
      CALL INPUT(MOVE)                                                  00292000
      MOVE=MOVE*2                                                       00293000
      IF(MOVE.GT.NMOVES.OR.MOVE.LE.0)  GO TO 998                        00294000
C                                                                       00295000
C------------------------------< READ THE COMMENT                       00296000
C                                                                       00297000
      WRITE(6,300)                                                      00298000
300   FORMAT(1X,'ENTER COMMENT')                                        00299000
400   READ(5,200,END=999)TEXT                                           00300000
200   FORMAT(31R1)                                                      00301000
      READ(1@MOVE)DATA                                                  00302000
      DO 500 I=1,31                                                     00303000
          IF(TEXT(I).NE.BLANK) GO TO 600                                00304000
500   CONTINUE                                                          00305000
      GO TO 999                                                         00306000
C                                                                       00307000
C------------------------------< SET THE MOVE'S POINTER TO THE COMMENT  00308000
C                                                                       00309000
600   DATA(32)=ANNOTE                                                   00310000
      WRITE(1@MOVE)DATA                                                 00311000
C                                                                       00312000
C------------------------------< WRITE THE COMMENT OUT                  00313000
C                                                                       00314000
      WRITE(1@ANNOTE)TEXT,ZERO                                          00315000
      MOVE=ANNOTE                                                       00316000
      ANNOTE=ANNOTE+1                                                   00317000
      GO TO 400                                                         00318000
  998 WRITE(6,900)                                                      00319000
  900 FORMAT(1X,"MOVE NOT MADE YET")                                    00320000
999   RETURN                                                            00321000
      END                                                               00322000
$CONTROL SEGMENT=ADJ                                                    00323000
      SUBROUTINE ADJUST                                                 00324000
C                                                                       00325000
C       ************************************************************    00326000
C       *                                                          *    00327000
C       *      ADJUST IS USED TO ADJUST THE CONSTRAINTS WHICH CON- *    00328000
C       *  TROL THE TIME USED TO CALCULATE MOVES.  THERE ARE THREE *    00329000
C       *  BASIC CONTROL FUNCTIONS SET BY THIS SUBROUTINE:         *    00330000
C       *                                                          *    00331000
C       *     1)  A VARIABLE 'TIMLIM' IS SET TO 2.5 TIMES THE      *    00332000
C       *         AVERAGE TIME THE MACHINE MUST USE TO STAY WITHIN *    00333000
C       *         THE LIMITS SET.  THIS IS USED IN SUBROUTINE      *    00334000
C       *         'LOOK'; WHEN THIS LIMIT IS REACHED, NO FURTHER   *    00335000
C       *         MOVES WILL BE EXAMINED.                          *    00336000
C       *                                                          *    00337000
C       *     2)  IF THE AVERAGE TIME/MOVE IS FASTER THAN RE-      *    00338000
C       *         QUIRED, THE FORWARD PRUNING WIDTHS WILL BE IN-   *    00339000
C       *         CREASED TO SLOW MOVE CALCUALTION DOWN.  IF THE   *    00340000
C       *         AVERAGE IS TOO SLOW, THE WIDTHS WILL BE REDUCED  *    00341000
C       *         TO SPEED MOVE CALCULATION UP.                    *    00342000
C       *                                                          *    00343000
C       *     3)  IF THE WIDTHS ARE INCREASED UP TO THE THRESHOLD, *    00344000
C       *         THEY ARE RESET TO THEIR ORIGINAL VALUE AND THE   *    00345000
C       *         SEARCH DEPTH IS INCREASED BY ONE.                *    00346000
C       *                                                          *    00347000
C       ************************************************************    00348000
C                                                                       00349000
      IMPLICIT INTEGER*4 (A-Z)                                          00350000
      COMMON /CLOK CM/ CLOCK,CTYPE,CQUERY,GELAP,CELAP,HELAP,            00351000
     *ELAPC,ELAPH,MOVES,SMOVES,SELAP,CTOTAL,HTOTAL,OPTIME               00352000
      COMMON /BOOK CM/ KEY ,IN BOOK                                     00353000
      LOGICAL IN BOOK, CLOCK, CQUERY                                    00354000
      COMMON /MOV CNT/ NCMOVS, NHMOVS                                   00355000
      COMMON /PRED CM/ PTEXT(30)                                        00356000
      COMMON /MOV TIM/ MELAP, MSEC1, MSEC2                              00357000
      COMMON /PRUNE/ WIDTH(10), MIN(10), MAX(10),                       00358000
     * DEPTH, ORDER1, ORDER2                                            00359000
      COMMON /BUFFER/ TEXT(30)                                          00360000
      COMMON /CHR SET/ ALPHA(44)                                        00361000
      EQUIVALENCE (ALPHAD,ALPHA(4)),(ALPHAL,ALPHA(12)),                 00362000
     *            (ALPHAS,ALPHA(19)),(ALPHAW,ALPHA(23))                 00363000
      COMMON /TIME CM/ TIMLIM, MAXTIM                                   00364000
      COMMON /DEBUG/ DEBUG                                              00365000
      LOGICAL DEBUG                                                     00366000
      INTEGER*4 TIME(3)                                                 00367000
      DATA TIME /180J,180J,180J/,COUNT /0J/,AVGTIM /0J/                 00368000
      DATA MVTIME / 180J/                                               00369000
C                                                                       00370000
C------------------------------< CALCULATE AVERAGE TIME PER MOVE        00371000
C                                                                       00372000
      CALL CTIME(END)                                                   00373000
      TIMLIM=360                                                        00374000
      IF(.NOT. CLOCK) RETURN                                            00375000
      IF(MELAP.EQ.0) GO TO 5                                            00376000
      TIME(3)=TIME(2)                                                   00377000
      TIME(2)=TIME(1)                                                   00378000
      TIME(1)=MELAP                                                     00379000
5     AVGTIM=(TIME(1)+TIME(2)+TIME(3))/3                                00380000
      LEFT=GELAP-CELAP-(MOVES-NCMOVS)*15                                00381000
C                                                                       00382000
C------------------------------< CALCULATE THE MAX TIME EVER TO         00383000
C------------------------------< TRY TO AVERAGE TO PREVENT THINK-AHEAD  00384000
C------------------------------< MATCHES FROM ADVANCING DEPTH TOO FAR.  00385000
C                                                                       00386000
      ABSMAX=1.5*SELAP/SMOVES                                           00387000
C                                                                       00388000
C------------------------------< CALCULATE TIME PROGRAM MUST AVERAGE    00389000
C                                                                       00390000
      OMTIME=MVTIME                                                     00391000
      MVTIME=LEFT/(MOVES-NCMOVS)                                        00392000
      IF(MVTIME.GT.ABSMAX) MVTIME=ABSMAX                                00393000
      IF(MVTIME.GT.OMTIME+30) MVTIME=OMTIME+30                          00394000
      OTLIM=TIMLIM                                                      00395000
      TIMLIM=2*MVTIME                                                   00396000
C                                                                       00397000
C------------------------------< IF LESS THAN 60 SECONDS REMAIN, PANIC  00398000
C------------------------------< AND SET THE LOOKAHEAD TO 3.            00399000
C                                                                       00400000
      IF(LEFT.LT.60) GO TO 2000                                         00401000
      TIMLIM=MIN0(LEFT-45,TIMLIM)                                       00402000
      IF(TIM LIM .LT. 30) TIM LIM = 30                                  00403000
C                                                                       00404000
C------------------------------< IF THE LAST MOVE TOOK AN ABNORMALLY LON00405000
C------------------------------< TIME, REDUCE THE LOOK-AHEAD EVEN       00406000
C------------------------------< IF THE AVERAGE IS OK.  IT CAN TAKE     00407000
C------------------------------< SEVERAL MOVES BEFORE THE AVERAGE       00408000
C------------------------------< INDICATES TIME PROBLEMS.               00409000
C                                                                       00410000
      IF(TIME(1).GE.OTLIM.AND.COUNT.EQ.0) GO TO 80                      00411000
      COUNT=COUNT+1                                                     00412000
      IF(COUNT.LT.3) RETURN                                             00413000
C                                                                       00414000
C------------------------------< COMPUTE THE DIFFERENCE.  IF THE        00415000
C------------------------------< PROGRAM IS WITHIN 15 SECONDS OF        00416000
C------------------------------< THE FORCED AVERAGE, NO ADJUSTMENT      00417000
C------------------------------< IS NECESSARY.                          00418000
C                                                                       00419000
      SURPLS=MVTIME-AVGTIM                                              00420000
      IF(IABS(SURPLS).LE.20) GO TO 50                                   00421000
C                                                                       00422000
C------------------------------< ADJUSTMENT OF MOVE TIME IS NEEDED.     00423000
C------------------------------< IT SHOULD BE NOTED THAT THE LAST       00424000
C------------------------------< THREE (3) MOVES ARE USED TO COMPUTE    00425000
C------------------------------< THE AVERAGE TIME PER MOVE.  THIS       00426000
C------------------------------< ALLOWS THE PROGRAM TO RESPOND TO       00427000
C------------------------------< TIME PROBLEMS WITHOUT ADJUSTING THE    00428000
C------------------------------< TUNING AFTER EACH MOVE (USUALLY        00429000
C------------------------------< GOES UP AND DOWN).                     00430000
C                                                                       00431000
C------------------------------< TO PREVENT VIOLENT TAMPERING WITH      00432000
C------------------------------< PRUNING WIDTHS DURING THE FIRST 30     00433000
C------------------------------< MOVES, THE WIDTHS ARE ADJUSTED BY      00434000
C------------------------------< INCREMENTS OF 1 UNTIL LESS THAN 30     00435000
C------------------------------< MINUTES REMAIN ON THE CLOCK. THEN      00436000
C------------------------------< THE WIDTHS ARE CHANGED MORE DRASTICALLY00437000
      ADD=1                                                             00438000
      IF(GELAP-CELAP.LE.30*60) ADD=IABS(SURPLS)/15                      00439000
      IF(SURPLS.LT.0) ADD=-ADD                                          00440000
C                                                                       00441000
C------------------------------< IF THE LAST MOVE TOOK NO TIME, THEN    00442000
C------------------------------< DO NOT REDUCE LOOKAHEAD FURTHER        00443000
C------------------------------< UNTILL WE FIND OUT HOW IT IS NOW.      00444000
C                                                                       00445000
      IF(MELAP.LE.1 .AND. ADD.LT.0) GO TO 50                            00446000
      DO 10 I=1,10                                                      00447000
          WIDTH(I)=WIDTH(I)+ADD                                         00448000
10    CONTINUE                                                          00449000
      IF(WIDTH(1).GT.MAX(1)) GO TO 60                                   00450000
      IF(WIDTH(1).LT.MIN(1)) GO TO 80                                   00451000
C                                                                       00452000
C------------------------------< IF THE DEBUG FLAG IS SET, OUTPUT THE   00453000
C------------------------------< ADJUSTED PARAMETERS AS THEY CHANGE.    00454000
C                                                                       00455000
50    IF(.NOT. DEBUG) GO TO 30                                          00456000
      LEFT1=LEFT/60                                                     00457000
      LEFT=MOD(LEFT,60)                                                 00458000
      WRITE(6,40)AVGTIM, LEFT1, LEFT, MVTIME, TIMLIM, SURPLS            00459000
40    FORMAT(1X,'AVG TIME/MOVE ',I5, ' SECS'/                           00460000
     *       1X,'TIME LEFT ON CLOCK ',I5,' MINS ',I2,' SECS'/           00461000
     *       1X,'MUST AVERAGE ',I5,' SECS/MOVE'/                        00462000
     *       1X,'MAXIMUM MOVE TIME IS ',I5,' SECS'/                     00463000
     *       1X,'DEVIATION FROM AVERAGE IS ',I5,' SECS'/)               00464000
      TEXT(1)=ALPHAS                                                    00465000
      TEXT(2)=ALPHAL                                                    00466000
      TEXT(3)=ALPHAD                                                    00467000
      CALL SCMND($20)                                                   00468000
20    TEXT(2)=ALPHAW                                                    00469000
      CALL SCMND($30)                                                   00470000
30    RETURN                                                            00471000
C                                                                       00472000
C------------------------------< MOVES ARE BEING COMPUTED TOO FAST      00473000
C------------------------------< AND THE WIDTHS ARE AT A REASONABLE     00474000
C------------------------------< UPPER LIMIT, CHECK TO SEE IF THE       00475000
C------------------------------< SEARCH DEPTH CAN BE INCREASED.         00476000
C                                                                       00477000
60    IF(AVGTIM*3.GT.MVTIME) GO TO 75                                   00478000
      IF(DEPTH.GE.10) GO TO 75                                          00479000
      DO 70 I=1,10                                                      00480000
          WIDTH(I)=MIN(I)                                               00481000
70    CONTINUE                                                          00482000
      DEPTH=DEPTH+1                                                     00483000
      COUNT=0                                                           00484000
      GO TO 50                                                          00485000
75    DO 78 I=1,10                                                      00486000
          WIDTH(I)=MAX(I)                                               00487000
78    CONTINUE                                                          00488000
      GO TO 50                                                          00489000
C                                                                       00490000
C------------------------------< MOVES ARE BEING COMPUTED TOO SLOWLY    00491000
C------------------------------< AND THE WIDTHS ARE AT A REASONABLE     00492000
C------------------------------< LOWER LIMIT, RESET THEM TO A HIGHER    00493000
C------------------------------< VALUE AND DECREASE THE SEARCH DEPTH.   00494000
C                                                                       00495000
80    IF(GELAP-CELAP.GT.30*60) GO TO 200                                00496000
85    DO 90 I=1,10                                                      00497000
          WIDTH(I)=MAX(I)                                               00498000
90    CONTINUE                                                          00499000
      IF(DEPTH.GT.2) DEPTH=DEPTH-1                                      00500000
      COUNT=0                                                           00501000
      GO TO 50                                                          00502000
C                                                                       00503000
C------------------------------< DON'T LOWER LOOK-AHEAD UNLESS WE       00504000
C------------------------------< ARE WITHIN 30 MINUTES OF THE UPPER     00505000
C------------------------------< TIME LIMIT.  THE MINIMUM SHOULD        00506000
C------------------------------< NEVER DROP BELOW 5.                    00507000
C                                                                       00508000
200   IF(DEPTH.GT.5) GO TO 85                                           00509000
      DO 110 I=1,10                                                     00510000
          WIDTH(I)=MIN(I)                                               00511000
110   CONTINUE                                                          00512000
      GO TO 50                                                          00513000
C                                                                       00514000
C------------------------------< IF THE PROGRAM EVER COMES HERE, IT     00515000
C------------------------------< IT COULD BEST BE DESCRIBED AS A        00516000
C------------------------------< PANIC SITUATION. SOMEHOW, THE PROGRAM  00517000
C------------------------------< HAS LESS THAN A MINUTE TO MAKE A       00518000
C------------------------------< MOVE.  THE LOOKAHEAD IS SET TO 3,      00519000
C------------------------------< THE WIDTHS ARE SET TO 8 AND A RAPID    00520000
C------------------------------< EXIT IS MADE.                          00521000
C                                                                       00522000
2000  DO 2001 I=1,10                                                    00523000
          WIDTH(I)=MIN(I)                                               00524000
2001  CONTINUE                                                          00525000
      DEPTH=3                                                           00526000
      TIMLIM=15                                                         00527000
      GO TO 50                                                          00528000
      END                                                               00529000
      BLOCK DATA                                                        00530000
      IMPLICIT INTEGER*4 (A-Z)                                          00531000
      COMMON /MOVES/ RK(4),BP(4),KT(8),KG(8)                            00532000
      COMMON /BOARD/ BOARD(120)                                         00533000
      COMMON /CAST SM/ CAST SC, UB CAST                                 00534000
      COMMON /GEN SM/ ATAK SC, BPAWN, BLKSC, TEMPO                      00535000
      COMMON /K SM/ EKMOVE, KSAFE                                       00536000
      COMMON /Q SM/ EQMOVE, Q EDGE                                      00537000
      COMMON /R SM/ ERMOVE, RANK78, ROPEN, RHALF, DROOKS, CROOKS,       00538000
     * RPASS, R EDGE                                                    00539000
      COMMON /B SM/ EBMOVE, LDIAG, BPAIR                                00540000
      COMMON /N SM/ ENMOVE, OUTPST, N EDGE                              00541000
      COMMON /P SM/ PADVNC, PPAWN, IPAWN, DPAWN, TPAWN, CPAWN,          00542000
     * ABREST, PPSHSC                                                   00543000
      COMMON /SAFE CM/ MPAWN, ANPAWN, ABPAWN                            00544000
      COMMON /CHRSET/ ALPHA(44)                                         00545000
      COMMON /HIST CM/ NMOVES, ANNOTE                                   00546000
      COMMON /STAT CM/ NODES(10), NGEN, MAXPLY, PRIGHT                  00547000
      COMMON /COLR CM/ CCOLOR, HCOLOR, COLOR                            00548000
      CHARACTER*5 CCOLOR, HCOLOR                                        00549000
      COMMON /TRACE/ TRACE(20,10), TFLAG                                00550000
      COMMON /CLOK CM/ CLOCK,CTYPE,CQUERY,GELAP,CELAP,HELAP,            00551000
     *ELAPC,ELAPH,MOVES,SMOVES,SELAP,CTOTAL,HTOTAL,OPTIME               00552000
      LOGICAL CLOCK, CQUERY                                             00553000
      COMMON /THAH CM/ THNK AH, LOOK AH, FOUND M, MTCHED, BRKFLG        00554000
      LOGICAL THNK AH, LOOK AH, PTHAHM, FOUND M, MTCHED, BRKFLG         00555000
      COMMON /TREE/ TREE(400),START(10),STOP(10),WHICH(10),BACKUP(10),  00556000
     *FROM(10),TO(10),VALUE(10),TYPE(10),PLY                            00557000
      COMMON /DATA/ CMOVE, SMOVE, HFROM8, HTO8, HTYPE8, MOVE            00558000
      COMMON /V CM/ VCMOVE                                              00559000
      COMMON /PRUNE/ WIDTH(10), MIN(10), MAX(10),                       00560000
     * DEPTH, ORDER1, ORDER2                                            00561000
      COMMON /TYPES/ NORMAL,CASTRT,CASTLF,ENPASS,PROMOTE                00562000
      COMMON /DUP/ PACK(8),POINT,BDSAVE(30,8)                           00563000
      COMMON /PIEC CM/ PVALUE(13), PINIT(13)                            00564000
      COMMON /BOOK CM/ KEY, IN BOOK                                     00565000
      LOGICAL IN BOOK                                                   00566000
      COMMON /PC CM/ COMMANDS(10,3), NCMNDS, PCMODE, EXMODE             00567000
      LOGICAL PCMODE, EXMODE                                            00568000
      COMMON /RATE CM/ CRATE, HRATE                                     00569000
      COMMON /MOV CNT/ NCMOVS, NHMOVS                                   00570000
      COMMON /DEBUG/ DEBUG                                              00571000
      INTEGER*4 GELAP                                                   00572000
      LOGICAL DEBUG                                                     00573000
      COMMON /MOV TIM/ MELAP, MSEC1, MSEC2                              00574000
      COMMON /TRCE CM/ STRACE(20), TSCORE                               00575000
      COMMON /OPEN CM/ MVNUMB                                           00576000
      DATA RK /+10J,-10J,+1J,-1J/                                       00577000
      DATA BP /+11J,-11J,+9J,-9J/                                       00578000
      DATA KT /+8J,+12J,+19J,+21J,-8J,-12J,-19J,-21J/                   00579000
      DATA KG /+1J,+9J,+10J,+11J,-1J,-9J,-10J,-11J/                     00580000
      DATA BOARD / 120*14J/                                             00581000
C                                                                       00582000
C------------------------------< TUNING PARAMETERS                      00583000
C                                                                       00584000
      DATA CAST SC, UB CAST / 180J,-50J/                                00585000
      DATA ATAK SC, BPAWN, BLKSC, TEMPO /30J,75J,50J,45J/               00586000
C                                                                       00587000
C--------------------< KING                                             00588000
C                                                                       00589000
      DATA EKMOVE, KSAFE / 62J,36J/                                     00590000
C                                                                       00591000
C--------------------< QUEEN                                            00592000
C                                                                       00593000
      DATA EQMOVE, Q EDGE / 108J,12J/                                   00594000
C                                                                       00595000
C--------------------< ROOK                                             00596000
C                                                                       00597000
      DATA ERMOVE, RANK78, ROPEN, RHALF, DROOKS, CROOKS, RPASS          00598000
     */       48J,   100J,   60J,   30J,    48J,    24J,   72J /        00599000
      DATA R EDGE / 12J/                                                00600000
C                                                                       00601000
C--------------------< BISHOP                                           00602000
C                                                                       00603000
      DATA EBMOVE, LDIAG, BPAIR / -24J,24J,75J /                        00604000
C                                                                       00605000
C--------------------< KNIGHT                                           00606000
C                                                                       00607000
      DATA ENMOVE, OUTPST, N EDGE  / -36J,40J,30J /                     00608000
C                                                                       00609000
C--------------------< PAWN                                             00610000
C                                                                       00611000
      DATA PADVNC, IPAWN, DPAWN, TPAWN / 12J,60J,30J,100J /             00612000
      DATA PPAWN, CPAWN, ABREST, PPSHSC / 20J,36J,16J,40J /             00613000
C                                                                       00614000
C--------------------< COMPROMISED KING-SIDE                            00615000
C                                                                       00616000
      DATA MPAWN, ANPAWN, ABPAWN / 60J,25J,40J /                        00617000
C                                                                       00618000
C                                                                       00619000
C------------------------------< END OF PARAMETERS                      00620000
C                                                                       00621000
      DATA ALPHA /%"A"J,%"B"J,%"C"J,%"D"J,%"E"J,%"F"J,%"G"J,%"H"J,      00622000
     *%"I"J,%"J"J,%"K"J,%"L"J,%"M"J,%"N"J,%"O"J,%"P"J,%"Q"J,            00623000
     *%"R"J,%"S"J,%"T"J,%"U"J,%"V"J,%"W"J,%"X"J,%"Y"J,%"Z"J,%"0"J,      00624000
     *%"1"J,%"2"J,%"3"J,%"4"J,%"5"J,%"6"J,%"7"J,%"8"J,%"9"J,%"+"J,      00625000
     *%"-"J,%"/"J,%"*"J,%"="J,%"."J,%"?"J,%" "J/                        00626000
      DATA NMOVES, ANNOTE / 0J,400J /                                   00627000
      DATA PRIGHT /0J/                                                  00628000
      DATA CCOLOR, HCOLOR, COLOR / 'BLACK', 'WHITE', 0J/                00629000
      DATA TFLAG /0J/                                                   00630000
      DATA CLOCK /.FALSE./, GELAP, CELAP, HELAP /99999999J,0J,0J/       00631000
      DATA CQUERY /.FALSE./, OPTIME / 0J/                               00632000
      DATA CTYPE, MOVES, SMOVES, SELAP /1J,200J,200J,200J/              00633000
      DATA CTOTAL, HTOTAL / 0J,0J/                                      00634000
      DATA THNK AH, LOOK AH, FOUNDM, MTCHED                             00635000
     * / .FALSE., .FALSE., .FALSE., .FALSE. /                           00636000
      DATA START(1)/1J/                                                 00637000
      DATA HFROM8,HTO8,HTYPE8,CMOVE,SMOVE,MOVE/1J,1J,1J,0J,0J,0J/       00638000
      DATA VCMOVE /0J/                                                  00639000
      DATA DEPTH, ORDER1, ORDER2 / 5J,4J,4J /                           00640000
      DATA WIDTH, MIN, MAX / 10*6J, 10*6J, 10*13J /                     00641000
      DATA NORMAL,CASTRT,CASTLF,ENPASS,PROMOTE                          00642000
     */         1J,    2J,    3J,    4J,     5J/                        00643000
      DATA POINT,BDSAVE/241*0J/                                         00644000
      DATA PINIT / 400J,1200J,1200J,2000J,3600J,8000J,0J,               00645000
     *             400J,1200J,1200J,2000J,3600J,8000J /                 00646000
      DATA KEY, IN BOOK / 1J,.FALSE. /                                  00647000
      DATA PCMODE, EXMODE / .FALSE., .FALSE. /                          00648000
      DATA CRATE, HRATE / 1400J,1400J /                                 00649000
      DATA NCMOVS, NHMOVS / 0J,0J /                                     00650000
      DATA DEBUG / .FALSE. /                                            00651000
      DATA MELAP / 0J /                                                 00652000
      DATA STRACE / 20*0J /                                             00653000
      DATA TRACE / 200*0J /                                             00654000
      DATA MVNUMB /1J/                                                  00655000
      END                                                               00656000
$CONTROL SEGMENT=PC                                                     00657000
      SUBROUTINE BISHOP                                                 00658000
C                                                                       00659000
C       ************************************************************    00660000
C       *                                                          *    00661000
C       *      BISHOP GENERATES ALL BISHOP MOVES AND DIAGONAL      *    00662000
C       *  MOVES FOR THE QUEEN.  SUBROUTINE SCORE IS CALLED TO     *    00663000
C       *  COMPUTE THE PLAUSIBILITY SCORE FOR THE MOVE, AFTER      *    00664000
C       *  WHICH THE MOVE IS ENTERED IN THE MOVE LIST.             *    00665000
C       *                                                          *    00666000
C       ************************************************************    00667000
C                                                                       00668000
      IMPLICIT INTEGER*4 (A-Z)                                          00669000
      COMMON /BOARD/ BOARD(120)                                         00670000
      COMMON /MOVES/ RK(4),BP(4),KT(8),KG(8)                            00671000
      COMMON /MOVE CM/ FROMSQ, TOSQ, SIDE                               00672000
      COMMON /INFO/ TYPE8, VALUE8, TO8, FROM8                           00673000
      COMMON /TYPES/ NORMAL,CASTRT,CASTLF,ENPASS,PROMOTE                00674000
      LOGICAL SIDE, CHECK                                               00675000
1000  DO 1030 I=1,4                                                     00676000
          TO8=FROM8                                                     00677000
          DIREC=BP(I)                                                   00678000
1010      TO8=TO8+DIREC                                                 00679000
          TYPE8=NORMAL                                                  00680000
          TOSQ=BOARD(TO8)                                               00681000
          IF(SIDE.AND.TOSQ.LT.7) GO TO 1030                             00682000
          IF(.NOT.SIDE.AND.TOSQ.GT.7) GO TO 1030                        00683000
          IF(TOSQ.EQ.14) GO TO 1030                                     00684000
          BOARD(TO8)=FROMSQ                                             00685000
          IF(CHECK(SIDE)) GO TO 1020                                    00686000
          CALL SCORE                                                    00687000
          CALL ENTER                                                    00688000
1020      BOARD(TO8)=TOSQ                                               00689000
          IF(TOSQ.EQ.7) GO TO 1010                                      00690000
1030  CONTINUE                                                          00691000
      RETURN                                                            00692000
      END                                                               00693000
      INTEGER FUNCTION BLOCK(SQUARE,SIDE)                               00694000
C                                                                       00695000
C       ************************************************************    00696000
C       *                                                          *    00697000
C       *      BLOCK IS USED TO DETERMINE IF A PIECE IS BLOCKADING *    00698000
C       *  A PASSED PAWN, AND IF SO HOW EFFECTIVE IT IS.  THE      *    00699000
C       *  SQUARE IN FRONT OF THE PIECE IS EXAMINED TO SEE IF IT   *    00700000
C       *  CONTAINS A PASSED PAWN.  IF SO, THE PIECE IS GIVEN      *    00701000
C       *  CREDIT FOR BLOCKING IT WHERE KNIGHTS, BISHOPS AND THE   *    00702000
C       *  KING ARE THE BEST BLOCKADERS, THE QUEEN IS NEXT, AND    *    00703000
C       *  ROOK IS LAST.  THE SCORE RETURNED IS A MEASURE OF HOW   *    00704000
C       *  EFFECTIVE THE BLOCKADER IS...THE BIGGER THE SCORE, THE  *   00705000
C       *  MORE EFFECTIVE.                                         *    00706000
C       *                                                          *    00707000
C       ************************************************************    00708000
C                                                                       00709000
      IMPLICIT INTEGER*4 (A-Z)                                          00710000
      COMMON /GEN SM/ ATAK SC, BPAWN, BLKSC, TEMPO                      00711000
      COMMON /BOARD/ BOARD(120)                                         00712000
      LOGICAL SIDE                                                      00713000
      INTEGER*4 DENOM(6)                                                00714000
      DATA DENOM/1J,2J,2J,4J,3J,2J/                                     00715000
      BLOCK=0                                                           00716000
      IF(SIDE) GO TO 200                                                00717000
C                                                                       00718000
C==============================< COMPUTER SCORING                       00719000
C                                                                       00720000
100   PAWN=1                                                            00721000
      DIR=1                                                             00722000
      GO TO 300                                                         00723000
C                                                                       00724000
C==============================< HUMAN SCORING                          00725000
C                                                                       00726000
200   PAWN=8                                                            00727000
      DIR=-1                                                            00728000
C                                                                       00729000
C------------------------------< IF THE SQUARE IN FRONT OF THE PIECE    00730000
C------------------------------< DOESN'T HAVE A PAWN ON IT, RETURN.     00731000
C                                                                       00732000
300   SQ=SQUARE+10*DIR                                                  00733000
      IF(BOARD(SQ).NE.PAWN) GO TO 999                                   00734000
C                                                                       00735000
C------------------------------< IF THE PAWN ISN'T PASSED, RETURN       00736000
C                                                                       00737000
      TEMP=PASSED(SQ,.NOT.SIDE)                                         00738000
      IF(TEMP.EQ.0) GO TO 999                                           00739000
C                                                                       00740000
C------------------------------< DETERMINE WHAT TYPE OF PIECE THE       00741000
C------------------------------< BLOCKADER IS TO ADJUST THE SCORE       00742000
C                                                                       00743000
      PIECE=MOD(BOARD(SQUARE),7)                                        00744000
      BLOCK=BLOCK+BLKSC+TEMP/DENOM(PIECE)                               00745000
999   RETURN                                                            00746000
      END                                                               00747000
$CONTROL SEGMENT=DSP                                                    00748000
      SUBROUTINE BOOK                                                   00749000
C                                                                       00750000
C       ************************************************************    00751000
C       *                                                          *    00752000
C       *      BOOK SEARCHES THE BOOK MOVE DATABASE FOR A RESPONSE *    00753000
C       *  TO THE HUMAN'S LAST MOVE.  IN MOST CASES THERE WILL BE  *    00754000
C       *  SEVERAL POSSIBLE REPLIES, THE COMPUTER ALWAYS TAKES THE *    00755000
C       *  FIRST ONE.  THIS COULD BE CHANGED TO A RANDOM NUMBER    *    00756000
C       *  CHOICE IF CARE IS TAKEN TO INSURE THAT ONLY 'GOOD'      *    00757000
C       *  LINES ARE PUT INTO THE DATABASE.  IF NO RESPONSE IS     *    00758000
C       *  FOUND, 'IN BOOK' IS SET TO FALSE SO THAT THE MOVE WILL  *    00759000
C       *  BE CALCULATED.  IF THE MOVE IS FOUND, OUR RESPONSE IS   *    00760000
C       *  CHOSEN AND THE POINTER TO THE HUMAN'S POSSIBLE REPLIES  *    00761000
C       *  IS SAVED FOR THE NEXT CALL.  NO MORE THAN TWO (2) I/O   *    00762000
C       *  OPERATIONS ARE REQUIRED FOR THIS (ONLY ONE IF THE       *    00763000
C       *  HUMAN'S RESPONSE IS NOT IN THE DATABASE), SO THE MORE   *    00764000
C       *  COMPREHENSIVE THE BOOK DATABASE IS, THE MORE TIME WILL  *    00765000
C       *  BE SAVED FOR LATER COMPUTED SEARCHING.                  *    00766000
C       *      A SEPARATE PROGRAM IS USED TO BUILD THE DATABASE    *    00767000
C       *  TO KEEP UNNEEDED CODE OUT OF THE MAIN CHESS PLAYING     *    00768000
C       *  PROGRAM.                                                *    00769000
C       *                                                          *    00770000
C       ************************************************************    00771000
C                                                                       00772000
      IMPLICIT INTEGER*4 (A-Z)                                          00773000
C     DEFINE FILE 3(1000,40,U,KEY)                                      00774000
      COMMON /DATA/ CMOVE, SMOVE, HFROM8, HTO8, HTYPE8, MOVE            00775000
      COMMON /COLR CM/ CCOLOR, HCOLOR, COLOR                            00776000
      CHARACTER*5 CCOLOR, HCOLOR                                        00777000
      COMMON /TYPES/ NORMAL,CASTRT,CASTLF,ENPASS,PROMOTE                00778000
      COMMON /TREE/ TREE(400),DMY(81)                                   00779000
      COMMON /INFO/ TYPE8, VALUE8, TO8, FROM8                           00780000
      COMMON /BOOK CM/ KEY, IN BOOK                                     00781000
      LOGICAL IN BOOK                                                   00782000
      COMMON /OPEN CM/ MVNUMB                                           00783000
      INTEGER*4 MAXW                                                    00784000
      DATA MAXW/20J/                                                    00785000
C                                                                       00786000
C------------------------------< IF IT IS THE FIRST MOVE AND THE        00787000
C------------------------------< COMPUTER IS WHITE, CHOOSE THE FIRST    00788000
C------------------------------< MOVE IN THE BOOK FILE.                 00789000
C                                                                       00790000
      IF(MOVE.EQ.0) GO TO 5                                             00791000
C                                                                       00792000
C------------------------------< READ IN THE RECORD WITH THE HUMAN'S    00793000
C------------------------------< POSSIBLE RESPONSES.  THEN MATCH THE    00794000
C------------------------------< HUMAN'S MOVE AGAINST THE LIST TO       00795000
C------------------------------< GET THE POINTER TO THE RECORD WITH     00796000
C------------------------------< THE COMPUTER'S POSSIBLE REPLIES.       00797000
C                                                                       00798000
      IF(KEY.EQ.0) GO TO 3                                              00799000
      LIM=MAXW*2                                                        00800000
      READ(3@KEY)(TREE(I),I=1,LIM)                                      00801000
C                                                                       00802000
C------------------------------< MATCH THE OPPONENT'S MOVE              00803000
C                                                                       00804000
      DO 2 I=1,MAXW                                                     00805000
          FROM8=TREE(I)                                                 00806000
          CALL EXTRCT                                                   00807000
          IF(COLOR.EQ.1) GO TO 1                                        00808000
          FROM8=121-FROM8                                               00809000
          TO8=121-TO8                                                   00810000
1         IF(TYPE8.NE.HTYPE8) GO TO 2                                   00811000
          IF(TYPE8.EQ.CASTRT.OR.TYPE8.EQ.CASTLF) GO TO 4                00812000
          IF(HTO8.EQ.TO8.AND.HFROM8.EQ.FROM8) GO TO 4                   00813000
2     CONTINUE                                                          00814000
3     IN BOOK = .FALSE.                                                 00815000
      RETURN                                                            00816000
4     KEY=TREE(I+MAXW)                                                  00817000
      IF(KEY.EQ.0) GO TO 3                                              00818000
C                                                                       00819000
C------------------------------< READ IN THE RECORD WITH THE COMPUTER'S 00820000
C------------------------------< POSSIBLE REPLIES TO THE LAST HUMAN     00821000
C------------------------------< MOVE AND CHOOSE ONE OF THEM (FIRST     00822000
C------------------------------< MOVE NOW, BUT COULD BE RANDOM).        00823000
C                                                                       00824000
5     LIM=MAXW*2                                                        00825000
      READ(3@KEY)(TREE(I),I=1,LIM)                                      00826000
C                                                                       00827000
C------------------------------< CHECK TO MAKE SURE REQUESTED MOVE      00828000
C------------------------------< ACTUALLY EXISTS                        00829000
C                                                                       00830000
      IF(MVNUMB.GT.MAXW) GO TO 300                                      00831000
      IF(TREE(MVNUMB).NE.0) GO TO 100                                   00832000
300   WRITE(6,200)MVNUMB                                                00833000
200   FORMAT(1X,'MOVE ',I2,' DOESN''T EXIST. I AM USING THE FIRST')     00834000
      MVNUMB=1                                                          00835000
100   CONTINUE                                                          00836000
      FROM8=TREE(MVNUMB)                                                00837000
      CALL EXTRCT                                                       00838000
      IF(COLOR.EQ.1) GO TO 6                                            00839000
      FROM8=121-FROM8                                                   00840000
      TO8=121-TO8                                                       00841000
6     CALL ENTERD(CMOVE)                                                00842000
      KEY=TREE(MAXW+MVNUMB)                                             00843000
      MVNUMB=1                                                          00844000
      RETURN                                                            00845000
      END                                                               00846000
      SUBROUTINE BREAK                                                  00847000
C                                                                       00848000
C       ************************************************************    00849000
C       *                                                          *    00850000
C       *      BREAK CONTROLS USE OF THE 'BREAK' BUTTON OR 'ATTN'  *    00851000
C       *  KEY ON TERMINALS.  THERE ARE TWO (2) ENTRY POINTS AND   *    00852000
C       *  TWO (2) ACTIONS TAKEN AS A RESULT OF A 'BREAK' OR 'ATTN'*    00853000
C       *  SIGNAL.  THE ENTRY POINTS  ARE 'BRK ON' TO SET BREAK    *    00854000
C       *  CONTROL AND 'BRK OFF' TO RESET BREAK CONTROL.  'BRK ON' *    00855000
C       *  REQUIRES 1 ARGUMENT IF THINK-AHEAD IS TO BE USED.  THIS *    00856000
C       *  IS THE STATEMENT NUMBER TO RETURN TO IF THE PROGRAM IS  *    00857000
C       *  THINKING ON THE OPPONENT'S TIME AND THE BREAK KEY IS    *    00858000
C       *  HIT INDICATING THAT IT IS TIME TO ACCEPT INPUT FROM THE *    00859000
C       *  PERSON PLAYING THE GAME.                                *    00860000
C       *      THE TWO ACTIONS TAKEN ARE (1) IF THE MACHINE IS     *    00861000
C       *  IN THE PROCESS OF CALCULATING A MOVE ON IT'S OWN TIME,  *    00862000
C       *  THE BEST MOVE FOUND SO FAR, THE CURRENT MOVE, AND THE   *    00863000
C       *  NUMBER OF MOVES REMAINING TO BE CHECKED ARE PRINTED.    *    00864000
C       *  (2)  IF THE PROGRAM IS IN THINK-AHEAD MODE, THAT IS, IT *    00865000
C       *  IS THINKING WHILE THE OPPONENT IS THINKING, THEN A      *    00866000
C       *  RETURN IS MADE TO THE INPUT ROUTINE TO ACCEPT THE MOVE  *    00867000
C       *  THE OPPONENT WISHES TO TYPE IN.                         *    00868000
C       *                                                          *    00869000
C       ************************************************************    00870000
C                                                                       00871000
      IMPLICIT INTEGER*4 (A-Z)                                          00872000
      SYSTEM INTRINSIC XCONTRAP                                         00873000
      COMMON /INFO/ TYPE8, VALUE8, TO8, FROM8                           00874000
      COMMON /TREE/  TREE(400),START(10),STOP(10),WHICH(10),BACKUP(10), 00875000
     *FROM(10),TO(10),VALUE(10),TYPE(10),PLY                            00876000
      COMMON /PRUNE/ WIDTH(10), MIN(10), MAX(10),                       00877000
     * DEPTH, ORDER1, ORDER2                                            00878000
      COMMON /COLR CM/ CCOLOR, HCOLOR, COLOR                            00879000
      COMMON /STAT CM/ NODES(10), NGEN, MAXPLY, PRIGHT                  00880000
      COMMON /THAH CM/ THNK AH, LOOK AH, FOUND M, MTCHED, BRKFLG        00881000
      LOGICAL THNK AH, LOOK AH, PTHAHM, FOUND M, MTCHED, BRKFLG         00882000
      COMMON /SAVE CM/ SBOARD(100)                                      00883000
      COMMON /DATA/ CMOVE, SMOVE, HFROM8, HTO8, HTYPE8, MOVE            00884000
      COMMON /BUFFER/ TEXT(30)                                          00885000
      COMMON /TRACE/ TRACE(20,10),TFLAG                                 00886000
      COMMON /HIST CM/ NMOVES, ANNOTE                                   00887000
      COMMON /BRK CM/ CSEC1, CSEC2, HSEC1, HSEC2                        00888000
      COMMON /PRED CM/ PTEXT(30)                                        00889000
      COMMON /TIME CM/ TIM LIM, MAX TIM                                 00890000
      COMMON /CHRSET/ ALPHA(44)                                         00891000
      EQUIVALENCE (BLANK,ALPHA(44))                                     00892000
      INTEGER*2 OFF, DMY                                                00893000
C------------------------------< GET BREAK CONTROL                      00894000
      DATA OFF / 0 /                                                    00895000
      ENTRY BRK ON                                                      00896000
C                                                                       00897000
C------------------------------< BREAK ROUTINE PRINTS CURRENT/BEST      00898000
C------------------------------< MOVES, VALUES, ETC.                    00899000
C                                                                       00900000
39    CONTINUE                                                          00901000
      IF(LOOKAH.AND..NOT.MTCHED) GO TO 442                              00902000
      CALL CTIME(CSEC2)                                                 00903000
      T1=TO8                                                            00904000
      F1=FROM8                                                          00905000
      T2=TYPE8                                                          00906000
      V1=VALUE8                                                         00907000
      E=CSEC2-CSEC1                                                     00908000
      TERM=0                                                            00909000
      LIM=DEPTH-1                                                       00910000
      DO 555 I=1,LIM                                                    00911000
          TERM=TERM+NODES(I)                                            00912000
555   CONTINUE                                                          00913000
      WRITE(6,40)E,TERM                                                 00914000
40    FORMAT(/1X,'TIME:',I4,1X,'SECS',2X,'POSITIONS:',I6)               00915000
      FROM8=TREE(WHICH(1))                                              00916000
      CALL EXTRCT                                                       00917000
      CALL OUTMOV(FROM8,TO8,TYPE8,ETYPE8,1,SBOARD)                      00918000
      WRITE(6,43)TEXT                                                   00919000
43    FORMAT(1X,'CURRENT MOVE: ',30R1)                                  00920000
      IF(BACKUP(1).EQ.-9999) GO TO 441                                  00921000
      FROM8=CMOVE                                                       00922000
      CALL EXTRCT                                                       00923000
      CALL OUTMOV(FROM8,TO8,TYPE8,ETYPE8,1,SBOARD)                      00924000
      WRITE(6,44)BACKUP(1),TEXT                                         00925000
44    FORMAT(1X,'BEST: ',I6,2X,30R1)                                    00926000
441   REMAIN=STOP(1)-WHICH(1)+1                                         00927000
      TOTAL=STOP(1)-START(1)+1                                          00928000
      WRITE(6,443)REMAIN,TOTAL                                          00929000
443   FORMAT(1X,I2,' OF ',I2,' MOVES REMAINING'/)                       00930000
      TO8=T1                                                            00931000
      FROM8=F1                                                          00932000
      TYPE8=T2                                                          00933000
      VALUE8=V1                                                         00934000
      TFLAG=0                                                           00935000
      RETURN                                                            00936000
C                                                                       00937000
C------------------------------< 'BREAK' HIT, ABORT LOOK-AHEAD          00938000
      ENTRY BRK ON2                                                     00939000
442   CONTINUE                                                          00940000
      READ(5,543)TEXT                                                   00941000
543   FORMAT(30R1)                                                      00942000
      IF(TEXT(1).EQ.BLANK) GO TO 446                                    00943000
      DO 444 I=1,30                                                     00944000
      IF(TEXT(I).EQ.BLANK.AND.PTEXT(I).EQ.BLANK) GO TO 445              00945000
      IF(TEXT(I).NE.PTEXT(I)) GO TO 450                                 00946000
444   CONTINUE                                                          00947000
445   MTCHED=.TRUE.                                                     00948000
      CALL XCONTRAP(OFF,DMY)                                            00949000
      ON CONTROLY CALL BRK ON                                           00950000
      CALL ETIME(HSEC2)                                                 00951000
      CALL CTIME(CSEC1)                                                 00952000
      MAX TIM = TIM LIM + CSEC1                                         00953000
446   CONTINUE                                                          00954000
      RETURN                                                            00955000
450   CONTINUE                                                          00956000
      BRKFLG=.TRUE.                                                     00957000
      CALL XCONTRAP(OFF,DMY)                                            00958000
      RETURN                                                            00959000
      END                                                               00960000
      INTEGER FUNCTION BSCORE(SQUARE,SIDE)                              00961000
C                                                                       00962000
C       ************************************************************    00963000
C       *                                                          *    00964000
C       *      BSCORE IS USED TO COMPUTE THE PLAUSIBILITY SCORE    *    00965000
C       *  FOR BISHOP MOVES.  THE SCORE IS OBTAINED DIRECTLY FROM  *    00966000
C       *  THE BISHOP CONTROL BOARD FOR THE SIDE TO MOVE. (CBSCOR, *    00967000
C       *  HBSCOR IN COMMON BLOCK 'B BD SM').                      *    00968000
C       *                                                          *    00969000
C       ************************************************************    00970000
C                                                                       00971000
      IMPLICIT INTEGER*4 (A-Z)                                          00972000
      COMMON /B BD SM/ CBSCOR(100), HBSCOR(100)                         00973000
      LOGICAL SIDE                                                      00974000
      IF(SIDE) GO TO 200                                                00975000
C                                                                       00976000
C==============================< COMPUTER SCORING                       00977000
C                                                                       00978000
100   BSCORE=CBSCOR(SQUARE)                                             00979000
      RETURN                                                            00980000
C                                                                       00981000
C==============================< HUMAN SCORING                          00982000
C                                                                       00983000
200   BSCORE=HBSCOR(SQUARE)                                             00984000
      RETURN                                                            00985000
      END                                                               00986000
$CONTROL SEGMENT=PC                                                     00987000
      SUBROUTINE CASTLE                                                 00988000
C                                                                       00989000
C       ************************************************************    00990000
C       *                                                          *    00991000
C       *      CASTLE GENERATES ALL CASTLING MOVES.  CASTLING TO   *    00992000
C       *  EITHER SIDE IS CONSIDERED EQUALLY PLAUSIBLE (BOTH GET   *    00993000
C       *  A FAIRLY HIGH SCORE TO ENSURE CHECKING THE MOVE).       *    00994000
C       *                                                          *    00995000
C       ************************************************************    00996000
C                                                                       00997000
      IMPLICIT INTEGER*4 (A-Z)                                          00998000
      COMMON /BOARD/ BOARD(120)                                         00999000
      LOGICAL CKINGM,CROOKR,CROOKL,HKINGM,HROOKR,HROOKL                 01000000
      COMMON /CAST CM/ CKINGM,CROOKR,CROOKL,HKINGM,HROOKR,HROOKL        01001000
      COMMON /MOVE CM/ INDEX, PIECE, SIDE                               01002000
      LOGICAL SIDE, CHECK                                               01003000
      COMMON /INFO/ TYPE8, VALUE8, TO8, FROM8                           01004000
      COMMON /TYPES/ NORMAL,CASTRT,CASTLF,ENPASS,PROMOTE                01005000
      COMMON /TREE/ TREE(400),START(10),STOP(10),WHICH(10),BACKUP(10),  01006000
     *FROM(10),TO(10),VALUE(10),TYPE(10),PLY                            01007000
      COMMON /K LOC CM/ CKINGL, HKINGL                                  01008000
      COMMON /COLR CM/ CCOLOR, HCOLOR, COLOR                            01009000
      CHARACTER*5 CCOLOR, HCOLOR                                        01010000
      COMMON /CAST SM/ CAST SC, UB CAST                                 01011000
      IF(PLY.GT.2) GO TO 9999                                           01012000
      TO8=0                                                             01013000
      FROM8=0                                                           01014000
      IF(SIDE) GO TO 2000                                               01015000
C                                                                       01016000
C------------------------------< COMPUTER CASTLING MOVES                01017000
C                                                                       01018000
1000  IF(CKINGM) GO TO 9999                                             01019000
      CKINGM=.TRUE.                                                     01020000
1010  IF(CHECK(.FALSE.)) GO TO 9997                                     01021000
      TEMP=CKINGL                                                       01022000
      IF(COLOR)1080,1020,1080                                           01023000
1020  IF(CROOKR) GO TO 1050                                             01024000
1030  IF(BOARD(23).NE.7.OR.BOARD(24).NE.7                               01025000
     *.OR.BOARD(25).NE.7) GO TO 1050                                    01026000
      CKINGL=24                                                         01027000
      IF(CHECK(.FALSE.)) GO TO 1040                                     01028000
      CKINGL=25                                                         01029000
      IF(CHECK(.FALSE.)) GO TO 1040                                     01030000
      TYPE8=CASTRT                                                      01031000
      VALUE8 = CAST SC + EXPOSE(SIDE)                                   01032000
      CALL ENTER                                                        01033000
1040  CKINGL=TEMP                                                       01034000
1050  IF(CROOKL) GO TO 9997                                             01035000
1060  IF(BOARD(27).NE.7.OR.BOARD(28).NE.7) GO TO 9997                   01036000
      CKINGL=27                                                         01037000
      IF(CHECK(.FALSE.)) GO TO 1070                                     01038000
      CKINGL=28                                                         01039000
      IF(CHECK(.FALSE.)) GO TO 1070                                     01040000
      TYPE8=CASTLF                                                      01041000
      VALUE8 = CAST SC + EXPOSE(SIDE)                                   01042000
      CALL ENTER                                                        01043000
1070  CKINGL=TEMP                                                       01044000
      GO TO 9997                                                        01045000
1080  IF(CROOKR) GO TO 1110                                             01046000
1090  IF(BOARD(23).NE.7.OR.BOARD(24).NE.7) GO TO 1110                   01047000
      CKINGL=23                                                         01048000
      IF(CHECK(.FALSE.)) GO TO 1100                                     01049000
      CKINGL=24                                                         01050000
      IF(CHECK(.FALSE.)) GO TO 1100                                     01051000
      TYPE8=CASTRT                                                      01052000
      VALUE8 = CAST SC + EXPOSE(SIDE)                                   01053000
      CALL ENTER                                                        01054000
1100  CKINGL=TEMP                                                       01055000
1110  IF(CROOKL) GO TO 9997                                             01056000
1120  IF(BOARD(26).NE.7.OR.BOARD(27).NE.7                               01057000
     *.OR.BOARD(28).NE.7) GO TO 9997                                    01058000
      CKINGL=26                                                         01059000
      IF(CHECK(.FALSE.)) GO TO 1130                                     01060000
      CKINGL=27                                                         01061000
      IF(CHECK(.FALSE.)) GO TO 1130                                     01062000
      TYPE8=CASTLF                                                      01063000
      VALUE8 = CAST SC + EXPOSE(SIDE)                                   01064000
      CALL ENTER                                                        01065000
1130  CKINGL=TEMP                                                       01066000
9997  CKINGM=.FALSE.                                                    01067000
      GO TO 9999                                                        01068000
C                                                                       01069000
C------------------------------< HUMAN CASTLING MOVES                   01070000
C                                                                       01071000
2000  IF(HKINGM) GO TO 9999                                             01072000
      HKINGM=.TRUE.                                                     01073000
2010  IF(CHECK(.TRUE.)) GO TO 9998                                      01074000
      TEMP=HKINGL                                                       01075000
      IF(COLOR)2080,2020,2080                                           01076000
2020  IF(HROOKL) GO TO 2050                                             01077000
2030  IF(BOARD(93).NE.7.OR.BOARD(94).NE.7                               01078000
     *.OR.BOARD(95).NE.7)  GO TO 2050                                   01079000
      HKINGL=94                                                         01080000
      IF(CHECK(.TRUE.)) GO TO 2040                                      01081000
      HKINGL=95                                                         01082000
      IF(CHECK(.TRUE.)) GO TO 2040                                      01083000
      TYPE8=CASTLF                                                      01084000
      VALUE8 = CAST SC + EXPOSE(SIDE)                                   01085000
      CALL ENTER                                                        01086000
2040  HKINGL=TEMP                                                       01087000
2050  IF(HROOKR) GO TO 9998                                             01088000
2060  IF(BOARD(97).NE.7.OR.BOARD(98).NE.7)   GO TO 9998                 01089000
      HKINGL=97                                                         01090000
      IF(CHECK(.TRUE.)) GO TO 2070                                      01091000
      HKINGL=98                                                         01092000
      IF(CHECK(.TRUE.)) GO TO 2070                                      01093000
      TYPE8=CASTRT                                                      01094000
      VALUE8 = CAST SC + EXPOSE(SIDE)                                   01095000
      CALL ENTER                                                        01096000
2070  HKINGL=TEMP                                                       01097000
      GO TO 9998                                                        01098000
2080  IF(HROOKL) GO TO 2110                                             01099000
2090  IF(BOARD(93).NE.7.OR.BOARD(94).NE.7)   GO TO 2110                 01100000
      HKINGL=93                                                         01101000
      IF(CHECK(.TRUE.)) GO TO 2100                                      01102000
      HKINGL=94                                                         01103000
      IF(CHECK(.TRUE.)) GO TO 2100                                      01104000
      TYPE8=CASTLF                                                      01105000
      VALUE8 = CAST SC + EXPOSE(SIDE)                                   01106000
      CALL ENTER                                                        01107000
2100  HKINGL=TEMP                                                       01108000
2110  IF(HROOKR) GO TO 9998                                             01109000
2120  IF(BOARD(96).NE.7.OR.BOARD(97).NE.7                               01110000
     *.OR.BOARD(98).NE.7)  GO TO 9998                                   01111000
      HKINGL=96                                                         01112000
      IF(CHECK(.TRUE.)) GO TO 2130                                      01113000
      HKINGL=97                                                         01114000
      IF(CHECK(.TRUE.)) GO TO 2130                                      01115000
      TYPE8=CASTRT                                                      01116000
      VALUE8 = CAST SC + EXPOSE(SIDE)                                   01117000
      CALL ENTER                                                        01118000
2130  HKINGL=TEMP                                                       01119000
9998  HKINGM=.FALSE.                                                    01120000
9999  RETURN                                                            01121000
      END                                                               01122000
$CONTROL SEGMENT=CMND                                                   01123000
      SUBROUTINE CCMND(DEVICE)                                          01124000
C                                                                       01125000
C       ************************************************************    01126000
C       *                                                          *    01127000
C       *      CCMND HANDLES ALL 'CHESS CLOCK' COMMANDS.  THERE    *    01128000
C       *  ARE FIVE BASIC OPERATIONS THAT CAN BE PERFORMED BY THIS *    01129000
C       *  ROUTINE:                                                *    01130000
C       *      1)  THE CHESS CLOCK CAN BE TURNED ON OR OFF.  IF IT *    01131000
C       *          IS ON, THE PROGRAM WILL PRINT OUT THE TIME BOTH *    01132000
C       *          IT AND THE HUMAN TAKES IN CHOOSING A MOVE AFTER *    01133000
C       *          EACH MAKES A MOVE.                              *    01134000
C       *      2)  THE CHESS CLOCK CAN BE SET TO SOME SPECIFIC     *    01135000
C       *          VALUE ALONG WITH A MOVE COUNTER TO FORCE THE    *    01136000
C       *          PROGRAM AND HUMAN TO MAKE A CERTAIN NUMBER OF   *    01137000
C       *          MOVES IN A SPECIFIED TIME PERIOD, FOR EXAMPLE   *    01138000
C       *          40 MOVES IN 10 MINUTES FOR HIGH-SPEED CHESS.    *    01139000
C       *      3)  THE CHESS CLOCK CAN BE DISPLAYED, TELLING HOW   *    01140000
C       *          MUCH TIME EACH SIDE HAS ON IT'S CLOCK TO SEE    *    01141000
C       *          HOW EACH SIDE IS DOING WITH RESPECT TO TIME.    *    01142000
C       *      4)  THE COMPUTER'S TIME PER MOVE IS USUALLY IN      *    01143000
C       *          COMPUTER TIME WHICH MAY BE MUCH SLOWER THAN     *    01144000
C       *          REAL OR WALL CLOCK TIME.  THE COMPUTER MAY BE   *    01145000
C       *          FORCED TO USE ELAPSED TIME JUST AS THE HUMAN    *    01146000
C       *          ALWAYS DOES IF DESIRED.  THIS MAY GET THE PROG- *    01147000
C       *          RAM INTO TIME TROUBLE, BUT MAY BE REQUIRED FOR  *    01148000
C       *          TOURNAMENT PLAY WHERE COMPUTER TIME IS NOT      *    01149000
C       *          UNDERSTOOD BY EVERYONE.                         *    01150000
C       *      5)  THE PROGRAM CAN BE INSTRUCTED TO PERIODICALLY  *     01151000
C       *          ASK THE TERMINAL OPERATOR WHO MUCH TIME IS     *     01152000
C       *          LEFT ON IT'S CLOCK SINCE COMPUTER TIMING MAY   *     01153000
C       *          NOT EXACTLY AGREE WITH THE CHESS CLOCK.  SEE   *     01154000
C       *          MODULE 'QUERY' FOR FURTHER DETAILS.            *     01155000
C       *                                                          *    01156000
C       ************************************************************    01157000
C                                                                       01158000
      IMPLICIT INTEGER*4 (A-Z)                                          01159000
      COMMON / BUFFER / TEXT(30)                                        01160000
      COMMON /PRUNE/ WIDTH(10), MIN(10), MAX(10),                       01161000
     * DEPTH, ORDER1, ORDER2                                            01162000
      COMMON /COLR CM/ CCOLOR, HCOLOR, COLOR                            01163000
      COMMON /CLOK CM/ CLOCK,CTYPE,CQUERY,GELAP,CELAP,HELAP,            01164000
     *ELAPC,ELAPH,MOVES,SMOVES,SELAP,CTOTAL,HTOTAL,OPTIME               01165000
      COMMON /BRK CM/ CSEC1, CSEC2, HSEC1, HSEC2                        01166000
      LOGICAL CLOCK, CQUERY                                             01167000
      COMMON /CHRSET/ ALPHA(44)                                         01168000
      EQUIVALENCE (D,ALPHA(4)),(L,ALPHA(12)),(T,ALPHA(20)),             01169000
     *(C,ALPHA(3)),(BLANK,ALPHA(44)),(QUEST,ALPHA(43)),                 01170000
     *(O,ALPHA(15)),(Q,ALPHA(17))                                       01171000
      IF(TEXT(2).EQ.C) GO TO 200                                        01172000
      IF(TEXT(2).EQ.D) GO TO 70                                         01173000
      IF(TEXT(2).EQ.QUEST) GO TO 90                                     01174000
      IF(TEXT(2).EQ.T) GO TO 110                                        01175000
      IF(TEXT(2).EQ.BLANK) GO TO 40                                     01176000
      IF(TEXT(2).EQ.O) GO TO 650                                        01177000
      IF(TEXT(2).EQ.Q) GO TO 400                                        01178000
      IF(TEXT(2).NE.L) RETURN                                           01179000
C                                                                       01180000
C------------------------------< CL : TOGGLE CHESS CLOCK ON/OFF         01181000
C                                                                       01182000
      CLOCK=.FALSE.                                                     01183000
      WRITE(6,10)                                                       01184000
      RETURN                                                            01185000
10    FORMAT(1X,'CLOCK TURNED OFF')                                     01186000
C                                                                       01187000
C------------------------------< C : SET CHESS CLOCK                    01188000
C                                                                       01189000
40    WRITE(6,41)                                                       01190000
41    FORMAT(1X,'HOW MANY MOVES?')                                      01191000
      CALL INPUT(TEMP)                                                  01192000
      IF(TEMP.EQ.0) RETURN                                              01193000
      MOVES=TEMP                                                        01194000
      WRITE(6,42)                                                       01195000
42    FORMAT(1X,'IN HOW MANY MINUTES?')                                 01196000
      CALL INPUT(GELAP)                                                 01197000
      GELAP=GELAP*60                                                    01198000
      WRITE(6,43)                                                       01199000
43    FORMAT(1X,'THEN HOW MANY MOVES?')                                 01200000
      CALL INPUT(SMOVES)                                                01201000
      WRITE(6,44)                                                       01202000
44    FORMAT(1X,'IN HOW MANY MINUTES?')                                 01203000
      CALL INPUT(SELAP)                                                 01204000
      SELAP=SELAP*60                                                    01205000
      CLOCK=.TRUE.                                                      01206000
      AVG=GELAP/MOVES                                                   01207000
      IF(AVG.LT.120) DEPTH=4                                            01208000
      IF(AVG.LT.30) DEPTH=3                                             01209000
      IF(AVG.LE.10) DEPTH=2                                             01210000
      IF(DEPTH.LT.5) OPTIME=0                                           01211000
      RETURN                                                            01212000
C                                                                       01213000
C------------------------------< CC : CORRECT CHESS CLOCK               01214000
C                                                                       01215000
200   IF(TEXT(3).NE.C.AND.TEXT(3).NE.BLANK) GO TO 220                   01216000
      WRITE(6,210)                                                      01217000
210   FORMAT(1X,'TIME LEFT ON MY CLOCK?')                               01218000
      CALL INPUT(TIME)                                                  01219000
      IF(TIME.EQ.0) GO TO 220                                           01220000
      CELAP=GELAP-TIME*60                                               01221000
220   IF(TEXT(3).NE.O.AND.TEXT(3).NE.BLANK) GO TO 240                   01222000
      WRITE(6,230)                                                      01223000
230   FORMAT(1X,'TIME LEFT ON OPPONENT''S CLOCK?')                      01224000
      CALL INPUT(TIME)                                                  01225000
      IF(TIME.EQ.0) GO TO 240                                           01226000
      CALL ETIME(HSEC2)                                                 01227000
      HELAP=GELAP-TIME*60-(HSEC1-HSEC2)                                 01228000
240   RETURN                                                            01229000
C                                                                       01230000
C------------------------------< CD : DISPLAY CHESS CLOCK               01231000
70    CALL ETIME(HSEC2)                                                 01232000
      D1=GELAP-CELAP                                                    01233000
      D2=GELAP-HELAP-(HSEC2-HSEC1)                                      01234000
      IF(D1.LT.0) D1=0                                                  01235000
      IF(D2.LT.0) D2=0                                                  01236000
      H1=D1/60                                                          01237000
      H2=D2/60                                                          01238000
      M1=MOD(D1,60)                                                     01239000
      M2=MOD(D2,60)                                                     01240000
      WRITE(DEVICE,80) H1,M1,H2,M2                                      01241000
80    FORMAT(7X,'BLITZ',12X,'OPPONENT'/                                 01242000
     *1X,I3,' MINS ',I2,' SECS',2X,I3,' MINS ',I2,' SECS')              01243000
      RETURN                                                            01244000
C                                                                       01245000
C------------------------------< CO : SET OPERATOR WASTE TIME           01246000
C                                                                       01247000
650   IF(TEXT(3).EQ.D) GO TO 652                                        01248000
      WRITE(6,651)                                                      01249000
651   FORMAT(1X,'ENTER TIME PER MOVE WASTED BY OPERATOR')               01250000
      CALL INPUT(OPTIME)                                                01251000
      IF(OPTIME.LT.0) GO TO 650                                         01252000
      RETURN                                                            01253000
652   WRITE(6,653)OPTIME                                                01254000
653   FORMAT(1X,'OPERATOR WASTES',I3,' SECONDS PER MOVE')               01255000
      RETURN                                                            01256000
C                                                                       01257000
C------------------------------< CQ : SET CLOCK QUERY FLAG              01258000
C                                                                       01259000
400   CQUERY=.NOT. CQUERY                                               01260000
      IF(CQUERY) WRITE(6,410)                                           01261000
      IF(.NOT. CQUERY) WRITE(6,420)                                     01262000
      RETURN                                                            01263000
410   FORMAT(1X,'I WILL ASK ABOUT THE CHESS CLOCK TIME')                01264000
420   FORMAT(1X,'I WILL NOT ASK ABOUT THE CHESS CLOCK TIME')            01265000
C                                                                       01266000
C------------------------------< CT : SET CLOCK TYPE (ELAPSED/CPU)      01267000
C                                                                       01268000
110   IF(CTYPE.EQ.1) WRITE(6,120)                                       01269000
      IF(CTYPE.EQ.2) WRITE(6,130)                                       01270000
      IF(TEXT(3).EQ.D) GO TO 170                                        01271000
160   WRITE(6,140)                                                      01272000
      CALL INPUT(TYPE)                                                  01273000
      IF(TYPE.EQ.0) GO TO 170                                           01274000
      IF(TYPE.NE.1.AND.TYPE.NE.2) GO TO 160                             01275000
      CTYPE=TYPE                                                        01276000
170   RETURN                                                            01277000
120   FORMAT(1X,'CLOCK IS USING CPU TIME')                              01278000
130   FORMAT(1X,'CLOCK IS USING ELAPSED TIME')                          01279000
140   FORMAT(1X,'ENTER CLOCK TYPE (1=CPU, 2=ELAPSED)')                  01280000
C                                                                       01281000
C------------------------------< C? : CHESS CLOCK HELP                  01282000
C                                                                       01283000
90    WRITE(6,100)                                                      01284000
100   FORMAT(                                                           01285000
     *1X,'C  : SET THE CHESS CLOCK'/                                    01286000
     *1X,'CC : CORRECT THE CHESS CLOCK'/                                01287000
     *1X,'CCC: CORRECT THE PROGRAM''S CLOCK'/                           01288000
     *1X,'CCO: CORRECT THE OPPONENT''S CLOCK'/                          01289000
     *1X,'CD : DISPLAY THE CHESS CLOCK'/                                01290000
     *1X,'CL : TURN THE CHESS CLOCK OFF'/                               01291000
     *1X,'CO : SET OPERATOR MOVE TIME'/                                 01292000
     *1X,'CQ : MAKE PROGRAM QUERY OPERATOR ABOUT CLOCK TIME'/           01293000
     *1X,'CT : RE-SPECIFY THE TYPE OF TIMING FOR COMPUTER MOVES'/       01294000
     *)                                                                 01295000
      RETURN                                                            01296000
      END                                                               01297000
      LOGICAL FUNCTION CHECK(SIDE)                                      01298000
C                                                                       01299000
C       ************************************************************    01300000
C       *                                                          *    01301000
C       *      CHECK DETERMINES IF THE SIDE TO MOVE IS IN CHECK    *    01302000
C       *  OR IF THE MOVE IS A CHECKING MOVE FOR THE OPPONENT.     *    01303000
C       *  THE ARGUMENT, 'SIDE' INDICATES WHICH SIDE TO CHECK FOR  *    01304000
C       *  AS FOLLOWS:                                             *    01305000
C       *    A)  IF SIDE IS TRUE, DETERMINE IF THE HUMAN IS IN     *    01306000
C       *        CHECK.                                            *    01307000
C       *    B)  IF SIDE IS FALSE, DETERMINE IF THE COMPUTER IS    *    01308000
C       *        IN CHECK.                                         *    01309000
C       *  CHECK IS A LOGICAL FUNCTION WHICH RETURNS TRUE IF       *    01310000
C       *  THE SIDE REQUESTED IS IN CHECK AND FALSE IF NOT.        *    01311000
C       *      CHECK PRETENDS IT IS VARIOUS PIECES SITTING ON      *    01312000
C       *  THE SAME SQUARE AS THE KING.  IT THEN GENERATES MOVES   *    01313000
C       *  FOR THESE FAKE PIECES AND FOLLOWS THE MOVES.  IF, FOR   *    01314000
C       *  EXAMPLE, IT GENERATES BISHOP MOVES AND LOOKS DOWN THE   *    01315000
C       *  DIAGONAL AND SEES AN OPPONENT BISHOP OR QUEEN WITH NO   *    01316000
C       *  INTERPOSING PIECES OR PAWNS, THEN CHECK IS SET TO TRUE  *    01317000
C       *  AND A RETURN IS TAKEN.  THIS IS DONE FOR ALL PIECES AND *    01318000
C       *  PAWNS BEFORE CHECK IS SET TO FALSE.                     *    01319000
C       *                                                          *    01320000
C       ************************************************************    01321000
C                                                                       01322000
      IMPLICIT INTEGER*4 (A-Z)                                          01323000
      LOGICAL SIDE                                                      01324000
      COMMON /K LOC CM/ CKINGL, HKINGL                                  01325000
      COMMON/MOVES/RK(4),BP(4),KT(8),KG(8)                              01326000
      COMMON/BOARD/BOARD(120)                                           01327000
      CHECK=.FALSE.                                                     01328000
      IF(SIDE) GO TO 9                                                  01329000
      TKINGL=CKINGL                                                     01330000
      BIAS=0                                                            01331000
      DIR=1                                                             01332000
      GO TO 10                                                          01333000
9     TKINGL=HKINGL                                                     01334000
      BIAS=7                                                            01335000
      DIR=-1                                                            01336000
10    PAWN=1+BIAS                                                       01337000
      KNIGHT=2+BIAS                                                     01338000
      BISHOP=3+BIAS                                                     01339000
      ROOK=4+BIAS                                                       01340000
      QUEEN=5+BIAS                                                      01341000
      KING=6+BIAS                                                       01342000
C                                                                       01343000
C------------------------------< KING IS A PAWN, SEE IF IT CAN          01344000
C------------------------------< CAPTURE AN OPPONENT'S PAWN.            01345000
C                                                                       01346000
      IF(BOARD(TKINGL+9*DIR).EQ.PAWN) GO TO 7                           01347000
      IF(BOARD(TKINGL+11*DIR).EQ.PAWN) GO TO 7                          01348000
C                                                                       01349000
C------------------------------< KING IS A KNIGHT/KING, SEE IF IT       01350000
C------------------------------< CAN CAPTURE A KNIGHT/KING.             01351000
C                                                                       01352000
8     DO 1 I=1,8                                                        01353000
          IF(BOARD(TKINGL+KT(I)).EQ.KNIGHT) GO TO 7                     01354000
          IF(BOARD(TKINGL+KG(I)).EQ.KING) GO TO 7                       01355000
1     CONTINUE                                                          01356000
C                                                                       01357000
C------------------------------< KING IS A BISHOP, SEE IF IT CAN        01358000
C------------------------------< CAPTURE A BISHOP OR QUEEN.             01359000
C                                                                       01360000
      DO 3 I=1,4                                                        01361000
          LOC=TKINGL                                                    01362000
          DIREC=BP(I)                                                   01363000
2         LOC=LOC+DIREC                                                 01364000
          TEMP=BOARD(LOC)                                               01365000
          IF(TEMP.EQ.7) GO TO 2                                         01366000
          IF(TEMP.EQ.BISHOP) GO TO 7                                    01367000
          IF(TEMP.EQ.QUEEN) GO TO 7                                     01368000
3     CONTINUE                                                          01369000
C                                                                       01370000
C------------------------------< KING IS A ROOK, SEE IF IT CAN          01371000
C------------------------------< CAPTURE A ROOK OR QUEEN.               01372000
C                                                                       01373000
      DO 5 I=1,4                                                        01374000
          LOC=TKINGL                                                    01375000
          DIREC=RK(I)                                                   01376000
4         LOC=LOC+DIREC                                                 01377000
          TEMP=BOARD(LOC)                                               01378000
          IF(TEMP.EQ.7) GO TO 4                                         01379000
          IF(TEMP.EQ.ROOK) GO TO 7                                      01380000
          IF(TEMP.EQ.QUEEN) GO TO 7                                     01381000
5     CONTINUE                                                          01382000
      RETURN                                                            01383000
C                                                                       01384000
C------------------------------< BY PRETENDING TO BE A PIECE, IT WAS    01385000
C------------------------------< THAT THE KING COULD CAPTURE THE        01386000
C------------------------------< PIECE IT WAS PRETENDING TO BE. BY      01387000
C------------------------------< THE SAME REASONING, THAT PIECE COULD   01388000
C------------------------------< CAPTURE THE KING -- IT IS IN CHECK.    01389000
C                                                                       01390000
7     CHECK=.TRUE.                                                      01391000
      RETURN                                                            01392000
      END                                                               01393000
      SUBROUTINE COMPRS                                                 01394000
C                                                                       01395000
C       ************************************************************    01396000
C       *                                                          *    01397000
C       *      COMPRS IS USED TO COMPRESS THE 64 SIGNIFICANT WORDS *    01398000
C       *  OF THE CHESS BOARD INTO 8 WORDS BY USING 4 BITS PER     *    01399000
C       *  SQUARE.  THIS COMPRESSED POSITION IS SAVED TO DETECT    *    01400000
C       *  DRAW BY REPITITION OF MOVES.                            *    01401000
C       *                                                          *    01402000
C       ************************************************************    01403000
C                                                                       01404000
      IMPLICIT INTEGER*4 (A-Z)                                          01405000
      COMMON /BOARD/ BOARD(120)                                         01406000
      COMMON /DUP/ PACK(8),POINT,BDSAVE(30,8)                           01407000
      ON INTEGER*4 OVERFLOW CALL OVTRAP                                 01408000
      SQ=21                                                             01409000
      DO 200 I=1,8                                                      01410000
          PACK(I)=0                                                     01411000
          DO 100 J=1,8                                                  01412000
              SQ=SQ+1                                                   01413000
              PACK(I)=PACK(I)*2**4+BOARD(SQ)                            01414000
100       CONTINUE                                                      01415000
          SQ=SQ+2                                                       01416000
200   CONTINUE                                                          01417000
      ON INTEGER*4 OVERFLOW ABORT                                       01418000
      RETURN                                                            01419000
      END                                                               01420000
      SUBROUTINE OVTRAP(ITG)                                            01421000
      IMPLICIT INTEGER*4 (A-Z)                                          01422000
      INTEGER*4 OVNM, ITG                                               01423000
      DATA OVNM / 0 /                                                   01424000
      OVNM=OVNM+1                                                       01425000
      RETURN                                                            01426000
      END                                                               01427000
$CONTROL SEGMENT=DSP                                                    01428000
      SUBROUTINE DISPLY(DEVICE)                                         01429000
C                                                                       01430000
C       ************************************************************    01431000
C       *                                                          *    01432000
C       *      DISPLAY IS USED TO DISPLAY THE GAME BOARD (CALLED   *    01433000
C       *  BY THE 'D' COMMAND). IN ADDITION TO THE BOARD, THE      *    01434000
C       *  PIECES CAPTURED BY BOTH SIDES ARE DISPLAYED TO THE      *    01435000
C       *  RIGHT FOR INFORMATION.  COLONS (: :) SURROUND THE HUMAN *    01436000
C       *  PIECES AND BRACKETS (   ) SURROUND THE COMPUTER PIECES. *    01437000
C       *  WHITE EMPTY SQUARES ARE INDICATED BY AN ASTERISK (*),   *    01438000
C       *  BLACK EMPTY SQUARES ARE INDICATED BY A DASH (-).        *    01439000
C       *                                                          *    01440000
C       ************************************************************    01441000
C                                                                       01442000
      IMPLICIT INTEGER*4 (A-Z)                                          01443000
      COMMON /BOARD/ BOARD(120)                                         01444000
      INTEGER*4 CHAR(13),BDCHAR(64),HPC(16),CPC(16),WSQ                 01445000
      COMMON /COLR CM/ CCOLOR, HCOLOR, COLOR                            01446000
      CHARACTER*5 CCOLOR,HCOLOR                                         01447000
      COMMON /BUFFER/ TEXT(30)                                          01448000
      COMMON /CLOK CM/ CLOCK,CTYPE,CQUERY,GELAP,CELAP,HELAP,            01449000
     *ELAPC,ELAPH,MOVES,SMOVES,SELAP,CTOTAL,HTOTAL,OPTIME               01450000
      LOGICAL CLOCK, CQUERY                                             01451000
      COMMON /CHRSET/ ALPHA(44)                                         01452000
      EQUIVALENCE (D,ALPHA(4))                                          01453000
      DATA CHAR/%":P:"J,%":N:"J,%":B:"J,%":R:"J,%":Q:"J,%":K:"J,        01454000
     *%" - "J,%"(P)"J,%"(N)"J,%"(B)"J,%"(R)"J,%"(Q)"J,                  01455000
     *%"(K)"J/,WSQ/%" * "J/                                             01456000
      DATA CPC/16*%"   "J/,HPC/16*%"   "J/                              01457000
      IF(TEXT(2).EQ.D) GO TO 1000                                       01458000
C                                                                       01459000
C------------------------------< SET UP THE DISPLAY BOARD               01460000
C                                                                       01461000
      SQ=21                                                             01462000
      DO 443 I=1,8                                                      01463000
          DO 442 J=1,8                                                  01464000
              SQ=SQ+1                                                   01465000
              BDCHAR((I-1)*8+J)=CHAR(BOARD(SQ))                         01466000
442       CONTINUE                                                      01467000
          SQ=SQ+2                                                       01468000
443   CONTINUE                                                          01469000
      FUDGE=0                                                           01470000
      DO 3 I=1,8                                                        01471000
          DO 2 J=1,7,2                                                  01472000
              IF(BDCHAR((I-1)*8+J+FUDGE).EQ.CHAR(7))                    01473000
     *               BDCHAR((I-1)*8+J+FUDGE)=WSQ                        01474000
2         CONTINUE                                                      01475000
          FUDGE=MOD(FUDGE+1,2)                                          01476000
3     CONTINUE                                                          01477000
C                                                                       01478000
C------------------------------< DETERMINE WHICH PIECES HAVE BEEN       01479000
C------------------------------< CAPTURED AND DISPLAY THEM ON THE SIDE. 01480000
C                                                                       01481000
      DO 386 I=1,7                                                      01482000
          CPC(I)=(25-I)/2                                               01483000
          HPC(I)=(11-I)/2                                               01484000
386   CONTINUE                                                          01485000
      DO 100 I=8,15                                                     01486000
      CPC(I)=8                                                          01487000
100   HPC(I)=1                                                          01488000
388   SQ=21                                                             01489000
      DO 223 I=1,8                                                      01490000
          DO 222 I1=1,8                                                 01491000
              SQ=SQ+1                                                   01492000
              DO 201 J=1,15                                             01493000
                  IF(CPC(J).EQ.BOARD(SQ)) GO TO 202                     01494000
201           CONTINUE                                                  01495000
              GO TO 203                                                 01496000
202           CPC(J)=7                                                  01497000
203           DO 250 J=1,15                                             01498000
                  IF(HPC(J).EQ.BOARD(SQ)) GO TO 251                     01499000
250           CONTINUE                                                  01500000
              GO TO 222                                                 01501000
251           HPC(J)=7                                                  01502000
222       CONTINUE                                                      01503000
          SQ=SQ+2                                                       01504000
223   CONTINUE                                                          01505000
      DO 302 I=1,15                                                     01506000
          DO 300 J=1,14                                                 01507000
              IF(CPC(J).NE.7) GO TO 301                                 01508000
              CPC(J)=CPC(J+1)                                           01509000
              CPC(J+1)=7                                                01510000
301           IF(HPC(J).NE.7) GO TO 300                                 01511000
              HPC(J)=HPC(J+1)                                           01512000
              HPC(J+1)=7                                                01513000
300       CONTINUE                                                      01514000
302   CONTINUE                                                          01515000
      DO 400 I=1,15                                                     01516000
          CPC(I)=CHAR(CPC(I))                                           01517000
          IF(CPC(I).EQ.CHAR(7)) CPC(I)=%' '                             01518000
          HPC(I)=CHAR(HPC(I))                                           01519000
          IF(HPC(I).EQ.CHAR(7)) HPC(I)=%' '                             01520000
400   CONTINUE                                                          01521000
C                                                                       01522000
C------------------------------< OUTPUT BOARD AND CAPTURED PIECES       01523000
C                                                                       01524000
      WRITE(DEVICE,4) CCOLOR                                            01525000
4     FORMAT(/16X,A5,T45,'CAPTURED PIECES'/)                            01526000
      DO 900 I=1,8                                                      01527000
          J=(I-1)*8+1                                                   01528000
          K=J+7                                                         01529000
          J1=(I-1)*2+1                                                  01530000
          K1=J1+1                                                       01531000
          WRITE(DEVICE,5)(BDCHAR(L),L=J,K),(CPC(L),HPC(L),L=J1,K1)      01532000
5         FORMAT(3X,8(R3,1X),12X,R3,4X,R3/47X,R3,4X,R3)                 01533000
900   CONTINUE                                                          01534000
      WRITE(DEVICE,6) HCOLOR                                            01535000
6     FORMAT(16X,A5/)                                                   01536000
C                                                                       01537000
C------------------------------< IF THE CHESS CLOCK IS BEING USED,      01538000
C------------------------------< DISPLAY IT UNDER THE BOARD.            01539000
C                                                                       01540000
      IF(.NOT. CLOCK) RETURN                                            01541000
      TEXT(2)=D                                                         01542000
      CALL CCMND(DEVICE)                                                01543000
7     RETURN                                                            01544000
1000  CALL OUTPUT(DEVICE,BOARD)                                         01545000
      GO TO 7                                                           01546000
      END                                                               01547000
      LOGICAL FUNCTION DRAW(SCORE)                                      01548000
C                                                                       01549000
C       ************************************************************    01550000
C       *                                                          *    01551000
C       *      DRAW IS USED TO DETERMINE IF THE COMPUTER SHOULD    *    01552000
C       *   ACCEPT A DRAW/STALEMATE IF ONE IS OFFERED/FOUND.  THE  *    01553000
C       *   MATERIAL BALANCE IS EXAMINED AS WELL AS THE VALUE      *    01554000
C       *   OF SQUARES PIECES/PAWNS ARE POSTED ON.  A VALUE OF     *    01555000
C       *   'TRUE' IS RETURNED IF THE PROGRAM IS BEHIND.           *    01556000
C       *                                                          *    01557000
C       ************************************************************    01558000
C                                                                       01559000
      IMPLICIT INTEGER*4 (A-Z)                                          01560000
      COMMON /BOARD/ BOARD(120)                                         01561000
      COMMON /RATE CM/ CRATE, HRATE                                     01562000
      COMMON /DRAW CM/ STAT BD(100)                                     01563000
      LOGICAL SIDE, ISOLAT                                              01564000
      DRAW=.FALSE.                                                      01565000
      CALL PREANL                                                       01566000
      SCORE=0                                                           01567000
C                                                                       01568000
C------------------------------< SCAN THE BOARD TO DETERMINE THE        01569000
C------------------------------< VALUE OF ALL PIECES/PAWNS.             01570000
C                                                                       01571000
      DO 200 SQUARE=22,99                                               01572000
          SC=0                                                          01573000
          TEMP=BOARD(SQUARE)                                            01574000
          IF(TEMP.EQ.7.OR.TEMP.EQ.14) GO TO 100                         01575000
          SIDE=TEMP.LT.7                                                01576000
          SIGN=1                                                        01577000
          IF(SIDE) SIGN=-1                                              01578000
          SC=WORTH(SQUARE,SIDE)                                         01579000
100       SCORE=SCORE+SIGN*SC                                           01580000
          STAT BD(SQUARE)=SC                                            01581000
200   CONTINUE                                                          01582000
C                                                                       01583000
C------------------------------< ANALYZE THE KING SAFETY                01584000
C                                                                       01585000
      SCORE=SCORE+EXPOSE(.FALSE.)-EXPOSE(.TRUE.)                        01586000
C                                                                       01587000
C------------------------------< IF THE OPPONENT IS A MUCH HIGHER       01588000
C------------------------------< RATED PLAYER THAN THE PROGRAM, ALWAYS  01589000
C------------------------------< ACCEPT A DRAW.  IF HE IS A CLASS       01590000
C------------------------------< BETTER, ACCEPT A DRAW IF NOT 1 1/2     01591000
C------------------------------< PAWNS OR MORE AHEAD. OTHERWISE, ACCEPT 01592000
C------------------------------< A DRAW WHEN BEHIND ONLY.               01593000
C                                                                       01594000
      RATE=HRATE-CRATE                                                  01595000
C                                                                       01596000
C------------------------------< IF THE OPPONENT IS 2 CLASSES BETTER,   01597000
C------------------------------< WE SHOULD COUNT OUR BLESSINGS AND      01598000
C------------------------------< ACCEPT THE DRAW UNLESS A ROOK AHEAD.   01599000
C                                                                       01600000
      IF(RATE.GT.400.AND.SCORE.LT.2000) GO TO 200                       01601000
C                                                                       01602000
C------------------------------< WE MUST BE AT LEAST 1 1/2 PAWNS        01603000
C------------------------------< AHEAD TO REFUSE A DRAW WITH A          01604000
C------------------------------< PLAYER 1 CLASS BETTER.                 01605000
C                                                                       01606000
      IF(RATE.GT.200.AND.SCORE.LT.600) GO TO 300                        01607000
C                                                                       01608000
C------------------------------< WE MUST ALWAYS BE AHEAD OR EVEN        01609000
C------------------------------< TO REFUSE A DRAW.                      01610000
C                                                                       01611000
      IF(SCORE.GE.0.AND.RATE.LT.200) GO TO 400                          01612000
300   DRAW=.TRUE.                                                       01613000
400   RETURN                                                            01614000
      END                                                               01615000
      INTEGER FUNCTION ENPRIS(SQUARE,SIDE)                              01616000
C                                                                       01617000
C       ************************************************************    01618000
C       *                                                          *    01619000
C       *      ENPRIS IS USED IN MOVE ORDERING TO DETERMINE THE    *    01620000
C       *  CONDITION OF PIECES ON THE BOARD.  IT RETURNS A VALUE   *    01621000
C       *  CORRESPONDING TO THE EXPECTED LOSS OF MATERIAL ON A     *    01622000
C       *  SQUARE.  IT MAKES THE FOLLOWING CHECKS:                 *    01623000
C       *                                                          *    01624000
C       *      1)  IF THE PIECE IS NOT UNDER ATTACK, LOSS=0        *    01625000
C       *                                                          *    01626000
C       *      2)  IF THE PIECE IS UNDER ATTACK AND NOT DEFENDED,  *    01627000
C       *          LOSS=VALUE OF PIECE                             *    01628000
C       *                                                          *    01629000
C       *      3)  IF THE PIECE IS ATTACKED BY A MORE VALUABLE     *    01630000
C       *          PIECE AND IS DEFENDED, LOSS=0                   *    01631000
C       *                                                          *    01632000
C       *      4)  IF THE PIECE IS ATTACKED BY A LESS VALUABLE     *    01633000
C       *          PIECE AND IS DEFENDED, LOSS=VALUE OF ATTACKED   *    01634000
C       *          PIECE LESS THE VALUE OF THE ATTACKING PIECE     *    01635000
C       *          (ASSUME THE PIECES WILL BE EXCHANGED)           *    01636000
C       *                                                          *    01637000
C       ************************************************************    01638000
C                                                                       01639000
      IMPLICIT INTEGER*4 (A-Z)                                          01640000
      LOGICAL SIDE                                                      01641000
      COMMON /BOARD/ BOARD(120)                                         01642000
      COMMON /PIEC CM/ PVALUE(13), PINIT(13)                            01643000
      ENPRIS=0                                                          01644000
      MVG PC=MOD(BOARD(SQUARE),7)                                       01645000
C                                                                       01646000
C------------------------------< GET LEAST VALUABLE PIECE ATTACKING     01647000
C------------------------------< THE INDICATED SQUARE                   01648000
C                                                                       01649000
1000  ATKG PC=MINATK(SQUARE,SIDE,NUMATK)                                01650000
C                                                                       01651000
C------------------------------< IF SQUARE IS NOT ATTACKED, RETURN      01652000
C                                                                       01653000
      IF(ATKG PC.EQ.0) GO TO 3000                                       01654000
C                                                                       01655000
C------------------------------< GET LEAST VALUABLE PIECE PROTECTING    01656000
C------------------------------< THE INDICATED SQUARE                   01657000
C                                                                       01658000
      PROT PC=MINATK(SQUARE,.NOT.SIDE,NUMPRT)                           01659000
C                                                                       01660000
C------------------------------< IF SQUARE IS PROTECTED, CHECK FURTHER  01661000
C                                                                       01662000
      IF(PROT PC.GT.0) GO TO 1100                                       01663000
C                                                                       01664000
C------------------------------< SQUARE IS ATTACKED, BUT NOT PROTECTED -01665000
C------------------------------< CONSIDER THE PIECE LOST                01666000
C                                                                       01667000
5000  ENPRIS=PINIT(MVG PC)                                              01668000
      GO TO 3000                                                        01669000
C                                                                       01670000
C------------------------------< IF THE DEFENDING PIECE IS A KING,      01671000
C------------------------------< FURTHER CHECKS ARE NECESSARY.          01672000
C                                                                       01673000
1100  IF(PROT PC.EQ.6) GO TO 4000                                       01674000
C                                                                       01675000
C------------------------------< IF THE ATTACKING PIECE IS MORE         01676000
C------------------------------< VALUABLE THAN THE PIECE ON 'SQUARE'    01677000
C------------------------------< WHICH IS PROTECTED - PIECE IS SAFE.    01678000
C                                                                       01679000
6000  IF(ATKG PC.GT.MVG PC) GO TO 3000                                  01680000
      IF(ATKG PC.LT.MVG PC) GO TO 2000                                  01681000
C                                                                       01682000
C------------------------------< THE ATTACKING PIECE IS WORTH THE       01683000
C------------------------------< SAME AS THE ATTACKED PIECE, SET        01684000
C------------------------------< THE SCORE TO 1 TO INDICATE EVENESS.    01685000
C                                                                       01686000
      ENPRIS=1                                                          01687000
      GO TO 3000                                                        01688000
C                                                                       01689000
C------------------------------< THE ATTACKING PIECE IS LESS            01690000
C------------------------------< VALUABLE THAN THE PIECE ON 'SQUARE' -  01691000
C------------------------------< ASSUME THE OTHER SIDE WOULD EXCHANGE.  01692000
C                                                                       01693000
2000  ENPRIS=PINIT(MVG PC)-PINIT(ATKG PC)                               01694000
3000  RETURN                                                            01695000
C                                                                       01696000
C------------------------------< THE ONLY PROTECTING PIECE IS THE       01697000
C------------------------------< KING, IF TWO PIECES ARE ATTACKING      01698000
C------------------------------< THE PIECE IN QUESTION, THEN IT IS      01699000
C------------------------------< SUBJECT TO CAPTURE SINCE THE KING      01700000
C------------------------------< CANNOT BE EXCHANGED.                   01701000
C                                                                       01702000
4000  IF(NUMATK.GT.1) GO TO 5000                                        01703000
      GO TO 6000                                                        01704000
      END                                                               01705000
      SUBROUTINE ENTER                                                  01706000
C                                                                       01707000
C       ************************************************************    01708000
C       *                                                          *    01709000
C       *      ENTER/ENTERD IS USED TO COMPRESS THE MOVE INFOR-    *    01710000
C       *  MATION INTO 1 WORD TO CONSERVE MEMORY.  ENTER ENTERS    *    01711000
C       *  THE MOVE INTO THE NEXT EMPTY SLOT IN THE MOVE LIST      *    01712000
C       *  WHILE ENTERD ENTERS THE MOVE INTO THE PARAMETER PASSED  *    01713000
C       *  IN THE ARGUMENT LIST.                                   *    01714000
C       *                                                          *    01715000
C       *      COMPRESSED DATA FORMAT :                            *    01716000
C       *                                                          *    01717000
C       *      SMMM VVVV VVVV VVVV VVTT TTTT TFFF FFFF             *    01718000
C       *                                                          *    01719000
C       *      M => MOVE TYPE (DESCRIBED IN MVMKER)                *    01720000
C       *      V => PLAUSIBILITY SCORE OF MOVE                     *    01721000
C       *      T => 'TO' OR DESTINATION SQUARE                     *    01722000
C       *      F => 'FROM' OR SOURCE SQUARE                        *    01723000
C       *                                                          *    01724000
C       ************************************************************    01725000
C                                                                       01726000
      IMPLICIT INTEGER*4 (A-Z)                                          01727000
      COMMON /INFO/ TYPE8, VALUE8, TO8, FROM8                           01728000
      COMMON /TREE/  TREE(400),START(10),STOP(10),WHICH(10),BACKUP(10), 01729000
     *FROM(10),TO(10),VALUE(10),TYPE(10),PLY                            01730000
      STOP(PLY)=STOP(PLY)+1                                             01731000
      TREE(STOP(PLY))=FROM8+TO8*2**7+(VALUE8+8000)*2**14+TYPE8*2**28    01732000
      RETURN                                                            01733000
      ENTRY ENTERD(WORD)                                                01734000
      WORD=FROM8+TO8*2**7+(VALUE8+8000)*2**14+TYPE8*2**28               01735000
      RETURN                                                            01736000
      END                                                               01737000
      INTEGER FUNCTION EXCHNG(SQUARE,SIDE)                              01738000
C                                                                       01739000
C       ************************************************************    01740000
C       *                                                          *    01741000
C       *      EXCHNG IS AN UNLIMITED LOOK-AHEAD ROUTINE TO CHECK  *    01742000
C       *  ALL CAPTURES ON A PARTICULAR SQUARE.  IT DETERMINES ALL *    01743000
C       *  PIECES BEARING ON THE SQUARE FOR BOTH SIDES AND THEN    *    01744000
C       *  PLAYS THE EXCHANGE SEQUENCES OUT.  THE SCORE IS AD-     *    01745000
C       *  JUSTED BASED ON THE LOSS OR GAIN OF MATERIAL FOUND.     *    01746000
C       *      THIS ROUTINE IS USED BY THE TERMINAL SCORING SUB-   *    01747000
C       *  ROUTINE TO EXAMINE THE LAST MOVE OF A SEQUENCE.         *    01748000
C       *  THIS IS DONE TO PREVENT A PIECE FROM BEING LEFT DANG-   *    01749000
C       *  LING BECAUSE THE SEARCH WAS CUT OFF AT SOME FIXED PLY.  *    01750000
C       *  IT IS ALSO USED BY THE PLAUSIBILITY RE-ORDERING SUB-    *    01751000
C       *  ROUTINE AT EARLY LEVELS IN THE TREE TO MAKE SURE THAT   *    01752000
C       *  AFTER EACH MOVE GENERATED, NO PIECES ARE LEFT DANGLING  *    01753000
C       *  SUBJECT TO CAPTURE.                                     *    01754000
C       *      IN CARRYING OUT EXCHANGE SEQUENCES, THIS ROUTINE    *    01755000
C       *  DOES NOT ALWAYS MAKE EVERY CAPTURE POSSIBLE BECAUSE     *    01756000
C       *  THIS COULD RESULT IN BLUNDERS ALSO.  FOR EXAMPLE, THE   *    01757000
C       *  SEQUENCE  NXB, BXN, RXB, QXN, RXQ WOULD BE EXAMINED,    *    01758000
C       *  BUT THE EXCHANGE SCORE WOULD BE BASED ON THE FIRST      *    01759000
C       *  THREE (3) MOVES ONLY AS NO ONE WOULD GIVE UP A QUEEN    *    01760000
C       *  FOR A KNIGHT UNLESS IN A CHECKMATE SEQUENCE.            *    01761000
C       *                                                          *    01762000
C       ************************************************************    01763000
C                                                                       01764000
      IMPLICIT INTEGER*4 (A-Z)                                          01765000
      COMMON /MOVES/ RK(4),BP(4),KT(8),KG(8)                            01766000
      COMMON /TREE/ TREE(400),START(10),STOP(10),WHICH(10),BACKUP(10),  01767000
     *FROM(10),TO(10),VALUE(10),TYPE(10),PLY                            01768000
      COMMON /BOARD/ BOARD(120)                                         01769000
      COMMON /PIEC CM/ PVALUE(13), PINIT(13)                            01770000
      COMMON /STAT CM/ NODES(10), NGEN, MAXPLY, PRIGHT                  01771000
      INTEGER*4 MOVESC(16),MOVESH(16),LIST(32)                          01772000
      LOGICAL SIDE, PLAYER                                              01773000
      EXCHNG=0                                                          01774000
      C=0                                                               01775000
      H=0                                                               01776000
C                                                                       01777000
C------------------------------< PAWN CAPTURES                          01778000
C                                                                       01779000
      IF(BOARD(SQUARE-9).NE.8) GO TO 1                                  01780000
      C=C+1                                                             01781000
      MOVESC(C)=PVALUE(8)+PSCORE(SQUARE,.FALSE.)                        01782000
1     IF(BOARD(SQUARE-11).NE.8) GO TO 2                                 01783000
      C=C+1                                                             01784000
      MOVESC(C)=PVALUE(8)+PSCORE(SQUARE,.FALSE.)                        01785000
2     IF(BOARD(SQUARE+9).NE.1) GO TO 3                                  01786000
      H=H+1                                                             01787000
      MOVESH(H)=PVALUE(1)+PSCORE(SQUARE,.TRUE.)                         01788000
3     IF(BOARD(SQUARE+11).NE.1) GO TO 4                                 01789000
      H=H+1                                                             01790000
      MOVESH(H)=PVALUE(1)+PSCORE(SQUARE,.TRUE.)                         01791000
C                                                                       01792000
C------------------------------< KNIGHT CAPTURES                        01793000
C                                                                       01794000
4     DO 7 I=1,8                                                        01795000
          LOC=SQUARE+KT(I)                                              01796000
          IF(BOARD(LOC).EQ.9) GO TO 5                                   01797000
          IF(BOARD(LOC).EQ.2) GO TO 6                                   01798000
          GO TO 7                                                       01799000
5         C=C+1                                                         01800000
          MOVESC(C)=PVALUE(9)+NSCORE(SQUARE,.FALSE.)                    01801000
          GO TO 7                                                       01802000
6         H=H+1                                                         01803000
          MOVESH(H)=PVALUE(2)+NSCORE(SQUARE,.TRUE.)                     01804000
7     CONTINUE                                                          01805000
C                                                                       01806000
C------------------------------< BISHOP/QUEEN CAPTURES                  01807000
C                                                                       01808000
      DO 12 I=1,4                                                       01809000
          DIREC=BP(I)                                                   01810000
          LOC=SQUARE                                                    01811000
9         LOC=LOC+DIREC                                                 01812000
          TEMP3=BOARD(LOC)                                              01813000
          GO TO(12,12,10,12,101,12,9,12,12,11,12,111,12,12),TEMP3       01814000
10        H=H+1                                                         01815000
          MOVESH(H)=PVALUE(TEMP3)+BSCORE(SQUARE,.TRUE.)                 01816000
          GO TO 9                                                       01817000
101       H=H+1                                                         01818000
          MOVESH(H)=PVALUE(TEMP3)+QSCORE(SQUARE,.TRUE.)                 01819000
          GO TO 9                                                       01820000
11        C=C+1                                                         01821000
          MOVESC(C)=PVALUE(TEMP3)+BSCORE(SQUARE,.FALSE.)                01822000
          GO TO 9                                                       01823000
111       C=C+1                                                         01824000
          MOVESC(C)=PVALUE(TEMP3)+QSCORE(SQUARE,.FALSE.)                01825000
          GO TO 9                                                       01826000
12    CONTINUE                                                          01827000
C                                                                       01828000
C------------------------------< ROOK/QUEEN CAPTURES                    01829000
C                                                                       01830000
      DO 16 I=1,4                                                       01831000
          DIREC=RK(I)                                                   01832000
          LOC=SQUARE                                                    01833000
13        LOC=LOC+DIREC                                                 01834000
          TEMP3=BOARD(LOC)                                              01835000
          GO TO(16,16,16,14,141,16,13,16,16,16,15,151,16,16),TEMP3      01836000
14        H=H+1                                                         01837000
          MOVESH(H)=PVALUE(TEMP3)+RSCORE(SQUARE,.TRUE.)                 01838000
          GO TO 13                                                      01839000
141       H=H+1                                                         01840000
          MOVESH(H)=PVALUE(TEMP3)+QSCORE(SQUARE,.TRUE.)                 01841000
          GO TO 13                                                      01842000
15        C=C+1                                                         01843000
          MOVESC(C)=PVALUE(TEMP3)+RSCORE(SQUARE,.FALSE.)                01844000
          GO TO 13                                                      01845000
151       C=C+1                                                         01846000
          MOVESC(C)=PVALUE(TEMP3)+QSCORE(SQUARE,.FALSE.)                01847000
          GO TO 13                                                      01848000
16    CONTINUE                                                          01849000
C                                                                       01850000
C------------------------------< KING CAPTURES                          01851000
C                                                                       01852000
      DO 44 I=1,8                                                       01853000
          LOC=SQUARE+KG(I)                                              01854000
          IF(BOARD(LOC).EQ.6) GO TO 42                                  01855000
          IF(BOARD(LOC).EQ.13) GO TO 43                                 01856000
          GO TO 44                                                      01857000
42        H=H+1                                                         01858000
          MOVESH(H)=PVALUE(6)                                           01859000
          GO TO 44                                                      01860000
43        C=C+1                                                         01861000
          MOVESC(C)=PVALUE(13)                                          01862000
44    CONTINUE                                                          01863000
C                                                                       01864000
C------------------------------< NOW THAT ALL CAPTURES ON THE IN-       01865000
C------------------------------< DICATED SQUARE ARE IN THE BUFFER,      01866000
C------------------------------< ANALYZE THE CAPTURING POSSIBILITIES    01867000
C------------------------------< FOR PLAUSIBILITY AND ADJUST THE        01868000
C------------------------------< SCORE ACCORDINGLY                      01869000
C                                                                       01870000
      CI=1                                                              01871000
      HI=1                                                              01872000
      LIST(1)=0                                                         01873000
      SIGN=1                                                            01874000
      DEPTH=1                                                           01875000
      PIECE=WORTH(SQUARE,SIDE)                                          01876000
      PLAYER=SIDE                                                       01877000
C                                                                       01878000
C------------------------------< CHANGE SIDES                           01879000
C                                                                       01880000
100   PLAYER=.NOT.PLAYER                                                01881000
      IF(PLAYER) GO TO 200                                              01882000
C                                                                       01883000
C------------------------------< IT IS THE MACHINES TURN TO CAPTURE,    01884000
C------------------------------< IF IT DOESN'T HAVE ANY MORE PIECES     01885000
C------------------------------< BEARING ON THE SQUARE, TIME TO QUIT.   01886000
C                                                                       01887000
      IF(CI.GT.C) GO TO 400                                             01888000
      TPIECE=MOVESC(CI)                                                 01889000
      CI=CI+1                                                           01890000
      GO TO 300                                                         01891000
C                                                                       01892000
C------------------------------< IT IS THE HUMANS TURN TO CAPTURE,      01893000
C------------------------------< IF HE DOESN'T HAVE ANY MORE PIECES     01894000
C------------------------------< BEARING ON THE SQUARE, TIME TO QUIT.   01895000
C                                                                       01896000
200   IF(HI.GT.H) GO TO 400                                             01897000
      TPIECE=MOVESH(HI)                                                 01898000
      HI=HI+1                                                           01899000
C                                                                       01900000
C------------------------------< PERFORM ALL INDICATED CAPTURES,BY      01901000
C------------------------------< MINIMAXING THE SCORES.                 01902000
C                                                                       01903000
300   DEPTH=DEPTH+1                                                     01904000
      LIST(DEPTH)=LIST(DEPTH-1)+SIGN*PIECE                              01905000
      PIECE=TPIECE                                                      01906000
      SIGN=-SIGN                                                        01907000
      GO TO 100                                                         01908000
C                                                                       01909000
C------------------------------< NOW THAT SCORING IS COMPLETE, SCAN     01910000
C------------------------------< THE EXCHANGE LIST TO DETERMINE WHEN    01911000
C------------------------------< THE SEQUENCE OF EXCHANGES WOULD        01912000
C------------------------------< STOP.                                  01913000
C                                                                       01914000
400   LIMIT=DEPTH                                                       01915000
      IF(DEPTH.EQ.1) GO TO 999                                          01916000
      T=MOD(DEPTH,2)                                                    01917000
      IF(T.EQ.0) GO TO 600                                              01918000
500   IF(LIST(LIMIT).LT.LIST(LIMIT-1)) LIST(LIMIT-1)=LIST(LIMIT)        01919000
      LIMIT=LIMIT-1                                                     01920000
      IF(LIMIT.LT.3) GO TO 700                                          01921000
600   IF(LIST(LIMIT).GT.LIST(LIMIT-1)) LIST(LIMIT-1)=LIST(LIMIT)        01922000
      LIMIT=LIMIT-1                                                     01923000
      IF(LIMIT.GE.3) GO TO 500                                          01924000
700   TEMP=PLY+DEPTH                                                    01925000
      IF(TEMP.GT.MAXPLY) MAXPLY=TEMP                                    01926000
      IF(LIST(2).LE.0) RETURN                                           01927000
      EXCHNG=LIST(2)                                                    01928000
999   RETURN                                                            01929000
      END                                                               01930000
      SUBROUTINE EXECPC                                                 01931000
C                                                                       01932000
C       ************************************************************    01933000
C       *                                                          *    01934000
C       *      EXECPC IS USED TO EXECUTE PROGRAMMED COMMANDS THAT  *    01935000
C       *  HAVE BEEN ENTERED PREVIOUSLY.  THIS ROUTINE IS CALLED   *    01936000
C       *  AFTER EVERY MOVE MADE BY THE COMPUTER.  FOR A DESCRIP-  *    01937000
C       *  TION OF PROGRAMMED COMMAND MODE, LOOK AT THE PCCMND     *    01938000
C       *  ROUTINE COMMENTS.  TO OPERATE, THIS ROUTINE MOVES THE   *    01939000
C       *  COMMANDS FROM THE PROGRAMMED COMMAND BUFFER INTO THE    *    01940000
C       *  REGULAR BUFFER (TEXT) AND CALLS OPTION JUST AS THOUGH   *    01941000
C       *  THE COMMANDS ARE BEING TYPED IN RATHER THAT GOTTEN      *    01942000
C       *  FROM AN ARRAY.                                          *    01943000
C       *                                                          *    01944000
C       ************************************************************    01945000
C                                                                       01946000
      IMPLICIT INTEGER*4 (A-Z)                                          01947000
      COMMON /BUFFER/ TEXT(30)                                          01948000
      COMMON /PC CM/ CMNDS(10,3), NCMNDS, PCMODE, EXMODE                01949000
      LOGICAL PCMODE, EXMODE                                            01950000
      COMMON /CHRSET/ ALPHA(44)                                         01951000
      EQUIVALENCE (P,ALPHA(16)),(BLANK,ALPHA(44))                       01952000
      EXMODE=.TRUE.                                                     01953000
      DO 20 I=1,NCMNDS                                                  01954000
      WRITE(6,30)(CMNDS(I,J),J=1,3)                                     01955000
      DO 5 J=1,3                                                        01956000
          IF(CMNDS(I,4-J).NE.BLANK) GO TO 8                             01957000
5     CONTINUE                                                          01958000
8     IF(CMNDS(I,4-J).EQ.P.AND.J.NE.3) WRITE(6,31) (CMNDS(I,J),J=1,3)   01959000
      TEXT(1)=CMNDS(I,1)                                                01960000
      TEXT(2)=CMNDS(I,2)                                                01961000
      TEXT(3)=CMNDS(I,3)                                                01962000
      DO 10 J=4,30                                                      01963000
          TEXT(J)=BLANK                                                 01964000
10    CONTINUE                                                          01965000
      CALL OPTION($20)                                                  01966000
20    CONTINUE                                                          01967000
      EXMODE=.FALSE.                                                    01968000
      RETURN                                                            01969000
30    FORMAT('?',3R1)                                                   01970000
31    FORMAT(1X,'?',3R1)                                                01971000
      END                                                               01972000
      INTEGER FUNCTION EXPOSE(SIDE)                                     01973000
C                                                                       01974000
C       ************************************************************    01975000
C       *                                                          *    01976000
C       *      THIS SUBROUTINE IS USED TO DETERMINE IF THE KING'S  *    01977000
C       *  SECTOR HAS BEEN COMPROMISED BY MOVING OR CAPTURING      *    01978000
C       *  PAWNS IN FRONT OF THE KING. THERE ARE THREE DEGREES OF  *    01979000
C       *  SAFETY DISCOVERED:                                      *    01980000
C       *      1)  A MISSING BISHOP, KNIGHT, OR ROOK PAWN IS THE   *    01981000
C       *          MOST IMPORTANT.                                 *    01982000
C       *      2)  AN ADVANCED BISHOP PAWN IS NEXT.                *    01983000
C       *      3)  FINALLY, AN ADVANCED KNIGHT PAWN IS LAST.       *    01984000
C       *  IF ANY OF THESE ARE FOUND, THE SCORE RETURNED IS PENA-  *    01985000
C       *  LIZED TO REFLECT THE LACK OF SAFETY.                    *    01986000
C       *                                                          *    01987000
C       ************************************************************    01988000
C                                                                       01989000
      IMPLICIT INTEGER*4 (A-Z)                                          01990000
      COMMON /BOARD/ BOARD(120)                                         01991000
      COMMON /K LOC CM/ CKINGL, HKINGL                                  01992000
      COMMON /Q LOC CM/ CQUEEN, HQUEEN                                  01993000
      COMMON /SAFE CM/ MPAWN, ANPAWN, ABPAWN                            01994000
      LOGICAL SIDE, CQUEEN, CKINGM, CROOKR, CROOKL,                     01995000
     * HQUEEN, HKINGM, HROOKR, HROOKL                                   01996000
      COMMON /CAST CM/ CKINGM,CROOKR,CROOKL,HKINGM,HROOKR,HROOKL        01997000
C                                                                       01998000
C------------------------------< INITIALIZE                             01999000
C                                                                       02000000
      EXPOSE=0                                                          02001000
      IF(SIDE) GO TO 200                                                02002000
100   IF(.NOT. CKINGM) GO TO 9999                                       02003000
      IF(CKINGL.GT.30.OR..NOT.HQUEEN) GO TO 9999                        02004000
      PAWN=8                                                            02005000
      DIR=1                                                             02006000
      CENTER=33                                                         02007000
      IF(CKINGL.GT.25) CENTER=38                                        02008000
      GO TO 300                                                         02009000
200   IF(.NOT. HKINGM) GO TO 9999                                       02010000
      IF(HKINGL.LT.90.OR..NOT.CQUEEN) GO TO 9999                        02011000
      PAWN=1                                                            02012000
      DIR=-1                                                            02013000
      CENTER=83                                                         02014000
      IF(HKINGL.GT.95) CENTER=88                                        02015000
C                                                                       02016000
C------------------------------< DETERMINE IF ANY PAWNS ARE MISSING     02017000
C------------------------------< IN FRONT OF THE CASTLED KING.          02018000
C                                                                       02019000
300   START=CENTER-1                                                    02020000
      END=CENTER+1                                                      02021000
      DO 400 SQ=START,END                                               02022000
          IF(BOARD(SQ).EQ.PAWN.OR.BOARD(SQ+DIR*10).EQ.PAWN              02023000
     *    .OR.BOARD(SQ+DIR*20).EQ.PAWN) GO TO 400                       02024000
          EXPOSE=EXPOSE-MPAWN                                           02025000
400   CONTINUE                                                          02026000
      CENT=CENTER-1                                                     02027000
C                                                                       02028000
C------------------------------< DETERMINE IF THE BISHOP'S OR KNIGHT'S  02029000
C------------------------------< PAWNS HAVE BEEN ADVANCED IN FRONT      02030000
C------------------------------< OF THE CASTLED KING.                   02031000
C                                                                       02032000
      IF(MOD(CENTER,10).LT.5) CENT=CENTER+1                             02033000
      IF(BOARD(CENTER).NE.PAWN) EXPOSE=EXPOSE-ANPAWN                    02034000
      IF(BOARD(CENT).NE.PAWN) EXPOSE=EXPOSE-ABPAWN                      02035000
9999  RETURN                                                            02036000
      END                                                               02037000
      SUBROUTINE EXTRCT                                                 02038000
C                                                                       02039000
C       ************************************************************    02040000
C       *                                                          *    02041000
C       *      EXTRCT TAKES THE COMPRESSED WORD (BUILT BY ENTER)   *    02042000
C       *  IN 'FROM8' AND BREAKS IT BACK DOWN INTO SEPARATE MOVE   *    02043000
C       *  PARAMETERS.                                             *    02044000
C       *                                                          *    02045000
C       *      COMPRESSED DATA FORMAT :                            *    02046000
C       *                                                          *    02047000
C       *      SMMM VVVV VVVV VVVV VVTT TTTT TFFF FFFF             *    02048000
C       *                                                          *    02049000
C       *      M => MOVE TYPE (DESCRIBED IN MVMKER)                *    02050000
C       *      V => PLAUSIBILITY SCORE OF MOVE                     *    02051000
C       *      T => 'TO' OR DESTINATION SQUARE                     *    02052000
C       *      F => 'FROM' OR SOURCE SQUARE                        *    02053000
C       *                                                          *    02054000
C       ************************************************************    02055000
C                                                                       02056000
      IMPLICIT INTEGER*4 (A-Z)                                          02057000
      COMMON /INFO/ TYPE8, VALUE8, TO8, FROM8                           02058000
      IF(FROM8.LT.0) FROM8=FROM8*(-1)                                   02059000
      TYPE8=FROM8                                                       02060000
      FROM8=MOD(TYPE8,2**7)                                             02061000
      TYPE8=TYPE8/2**7                                                  02062000
      TO8=MOD(TYPE8,2**7)                                               02063000
      TYPE8=TYPE8/2**7                                                  02064000
      VALUE8=MOD(TYPE8,2**14)-8000                                      02065000
      TYPE8=TYPE8/2**14                                                 02066000
      RETURN                                                            02067000
      END                                                               02068000
$CONTROL SEGMENT=CMND                                                   02069000
      SUBROUTINE FCMND                                                  02070000
C                                                                       02071000
C       ************************************************************    02072000
C       *                                                          *    02073000
C       *      FCMND PROCESSES THE 'F' COMMAND.  THIS IS USED TO   *    02074000
C       *  FORCE THE COMPUTER TO MAKE THE MOVE ENTERED ON THE NEXT *    02075000
C       *  LINE.  IF A MOVE HAS ALREADY BEEN MADE BY THE COMPUTER, *    02076000
C       *  THAT MOVE WILL BE UNMADE AND THE NEW ONE MADE.          *    02077000
C       *                                                          *    02078000
C       ************************************************************    02079000
C                                                                       02080000
      IMPLICIT INTEGER*4 (A-Z)                                          02081000
      COMMON /BUFFER/ TEXT(30)                                          02082000
      COMMON /DATA/ CMOVE, SMOVE, HFROM8, HTO8, HTYPE8, MOVE            02083000
      COMMON /V CM/ VCMOVE                                              02084000
      COMMON /INFO/ TYPE8, VALUE8, TO8, FROM8                           02085000
      COMMON /NAME CM/ NAME(5)                                          02086000
      COMMON /HIST CM/ NMOVES, ANNOTE                                   02087000
      COMMON /TREE/ DUMMY(480),PLY                                      02088000
      LOGICAL CHECK, SIDE                                               02089000
      COMMON /CHRSET/ ALPHA(44)                                         02090000
      EQUIVALENCE (BLANK,ALPHA(44))                                     02091000
      DATA ZERO /0J/                                                    02092000
C                                                                       02093000
C------------------------------< INPUT NEW MOVE TO MAKE                 02094000
C                                                                       02095000
10    DO 20   I=1,30                                                    02096000
          TEXT(1)=BLANK                                                 02097000
20    CONTINUE                                                          02098000
      WRITE(6,30)                                                       02099000
30    FORMAT(1X,'ENTER MY MOVE')                                        02100000
      READ(5,100)TEXT                                                   02101000
      IF(TEXT(1).EQ.BLANK) RETURN                                       02102000
C                                                                       02103000
C------------------------------< IF PROGRAM HAS ALREADY MADE A MOVE,    02104000
C------------------------------< IT MUST BE 'UNMADE'                    02105000
C                                                                       02106000
      PLY=1                                                             02107000
      FROM8=VCMOVE                                                      02108000
      IF(FROM8.EQ.0) GO TO 50                                           02109000
      CALL EXTRCT                                                       02110000
      CALL PUMVER                                                       02111000
      VCMOVE=0                                                          02112000
C                                                                       02113000
C------------------------------< CONVERT AND MAKE THE NEW MOVE          02114000
C                                                                       02115000
50    CALL INMOVE(1,$10)                                                02116000
      CALL ENTERD(VCMOVE)                                               02117000
      CALL PMOVER                                                       02118000
      IF( .NOT. CHECK(SIDE))GOTO 80                                     02119000
      WRITE(1@NMOVES) TEXT,ZERO,ZERO                                    02120000
      RETURN                                                            02121000
C                                                                       02122000
C------------------------------< CAN'T MAKE A MOVE THAT LEAVES          02123000
C------------------------------< THE KING IN CHECK                      02124000
C                                                                       02125000
80    WRITE(6,90)NAME                                                   02126000
90    FORMAT(1X,'MY KING IS IN CHECK, ',5A4)                            02127000
      GO TO 10                                                          02128000
100   FORMAT(30R1)                                                      02129000
      END                                                               02130000
$CONTROL SEGMENT=PC                                                     02131000
      INTEGER FUNCTION FORK(SQUARE,SIDE)                                02132000
C                                                                       02133000
C       ************************************************************    02134000
C       *                                                          *    02135000
C       *      FORK IS USED TO DETERMINE IF A MOVE IS A FORKING    *    02136000
C       *  TYPE OF MOVE (INCLUDES X-RAYS, PINS, ETC.).  THIS SUB-  *    02137000
C       *  ROUTINE LISTS ALL THE OPPONENT'S PIECES A PIECE ON      *    02138000
C       *  'SQUARE' ATTACKS.  THIS LIST IS SORTED AND THEN         *    02139000
C       *  SCANNED TO DETERMINE WHAT MIGHT BE LOST OR WON AS A     *    02140000
C       *  RESULT OF THIS FORKING?? MOVE.  THE LIST OF ATTACKED    *    02141000
C       *  PIECES IS EXAMINED FOR THE FIRST PIECE MORE VALUABLE    *    02142000
C       *  THAN THE ATTACKING PIECE OR THE FIRST PIECE THAT IS     *    02143000
C       *  UNDEFENDED IF IT IS LESS VALUABLE.  THIS PIECE WILL     *    02144000
C       *  BE ASSUMED TO BE SAVED.  THE REST OF THE LIST IS THEN   *    02145000
C       *  EXAMINED TO FIND THE NEXT PIECE MORE VALUABLE OR        *    02146000
C       *  UNDEFENDED.  THE SCORE RETURNED IS A) 0 IF NO PIECES    *    02147000
C       *  FIT THESE RULES; B) THE VALUE OF THE NEXT MOST VALUABLE *    02148000
C       *  ATTACKED PIECE IF IT UNDEFENDED; OR C) THE VALUE OF THE *    02149000
C       *  NEXT MOST VALUABLE PIECE LESS THE VALUE OF THE          *    02150000
C       *  ATTACKING PIECE IF IT IS DEFENDED.                      *    02151000
C       *                                                          *    02152000
C       ************************************************************    02153000
C                                                                       02154000
      IMPLICIT INTEGER*4 (A-Z)                                          02155000
      COMMON /PIEC CM/ PVALUE(13), PINIT(13)                            02156000
      COMMON /MOVES/ RK(4),BP(4),KT(8),KG(8)                            02157000
      COMMON /BOARD/ BOARD(120)                                         02158000
      INTEGER*4 FORKED(16), LOCS(16)                                    02159000
      LOGICAL SIDE, FIRST                                               02160000
      FORK=0                                                            02161000
      APIECE=BOARD(SQUARE)                                              02162000
      PIECE=MOD(APIECE,7)                                               02163000
      NUMBER=0                                                          02164000
      GO TO (100,200,300,400,300,500,999),PIECE                         02165000
C                                                                       02166000
C------------------------------< COUNT THE NUMBER OF PIECES THAT        02167000
C------------------------------< A PAWN ON 'SQUARE' ATTACKS             02168000
C                                                                       02169000
100   LOC=SQUARE+9                                                      02170000
      IF(SIDE) LOC=SQUARE-11                                            02171000
      DO 140 I=1,2                                                      02172000
          TEMP=BOARD(LOC)                                               02173000
          IF(SIDE) GO TO 110                                            02174000
          GO TO (120,120,120,120,120,120,130,                           02175000
     *           130,130,130,130,130,130,130),TEMP                      02176000
110       GO TO (130,130,130,130,130,130,130,                           02177000
     *           120,120,120,120,120,120,130),TEMP                      02178000
120       NUMBER=NUMBER+1                                               02179000
          FORKED(NUMBER)=TEMP                                           02180000
          LOCS(NUMBER)=LOC                                              02181000
130       LOC=LOC+2                                                     02182000
140   CONTINUE                                                          02183000
      GO TO 600                                                         02184000
C                                                                       02185000
C------------------------------< COUNT THE NUMBER OF PIECES THAT        02186000
C------------------------------< A KNIGHT ON 'SQUARE' ATTACKS           02187000
C                                                                       02188000
200   DO 230 I=1,8                                                      02189000
          LOC=SQUARE+KT(I)                                              02190000
          TEMP=BOARD(LOC)                                               02191000
          IF(SIDE) GO TO 210                                            02192000
          GO TO (220,220,220,220,220,220,230,                           02193000
     *           230,230,230,230,230,230,230),TEMP                      02194000
210       GO TO (230,230,230,230,230,230,230,                           02195000
     *           220,220,220,220,220,220,230),TEMP                      02196000
220       NUMBER=NUMBER+1                                               02197000
          FORKED(NUMBER)=TEMP                                           02198000
          LOCS(NUMBER)=LOC                                              02199000
230   CONTINUE                                                          02200000
      GO TO 600                                                         02201000
C                                                                       02202000
C------------------------------< COUNT THE NUMBER OF PIECES THAT        02203000
C------------------------------< A BISHOP ON 'SQUARE' ATTACKS           02204000
C                                                                       02205000
300   DO 340 I=1,4                                                      02206000
          LOC=SQUARE                                                    02207000
          DIREC=BP(I)                                                   02208000
310       LOC=LOC+DIREC                                                 02209000
          TEMP=BOARD(LOC)                                               02210000
          IF(SIDE) GO TO 320                                            02211000
          GO TO (330,330,330,330,330,330,310,                           02212000
     *           340,340,340,340,340,340,340),TEMP                      02213000
320       GO TO (340,340,340,340,340,340,310,                           02214000
     *           330,330,330,330,330,330,340),TEMP                      02215000
330       NUMBER=NUMBER+1                                               02216000
          FORKED(NUMBER)=TEMP                                           02217000
          LOCS(NUMBER)=LOC                                              02218000
          IF(MOD(TEMP,7).NE.1) GO TO 310                                02219000
340   CONTINUE                                                          02220000
      IF(PIECE.EQ.3) GO TO 600                                          02221000
C                                                                       02222000
C------------------------------< COUNT THE NUMBER OF PIECES THAT        02223000
C------------------------------< A ROOK ON 'SQUARE' ATTACKS             02224000
C                                                                       02225000
400   DO 440 I=1,4                                                      02226000
          LOC=SQUARE                                                    02227000
          DIREC=RK(I)                                                   02228000
410       LOC=LOC+DIREC                                                 02229000
          TEMP=BOARD(LOC)                                               02230000
          IF(SIDE) GO TO 420                                            02231000
          GO TO (430,430,430,430,430,430,410,                           02232000
     *           440,440,440,440,440,440,440),TEMP                      02233000
420       GO TO (440,440,440,440,440,440,410,                           02234000
     *           430,430,430,430,430,430,440),TEMP                      02235000
430       NUMBER=NUMBER+1                                               02236000
          FORKED(NUMBER)=TEMP                                           02237000
          LOCS(NUMBER)=LOC                                              02238000
          IF(MOD(TEMP,7).NE.1) GO TO 410                                02239000
440   CONTINUE                                                          02240000
      GO TO 600                                                         02241000
C                                                                       02242000
C------------------------------< COUNT THE NUMBER OF PIECES THAT        02243000
C------------------------------< A KING ON 'SQUARE' ATTACKS             02244000
C                                                                       02245000
500   DO 530 I=1,8                                                      02246000
          LOC=SQUARE+KG(I)                                              02247000
          TEMP=BOARD(LOC)                                               02248000
          IF(SIDE) GO TO 510                                            02249000
          GO TO (520,520,520,520,520,520,530,                           02250000
     *           530,530,530,530,530,530,530),TEMP                      02251000
510       GO TO (530,530,530,530,530,530,530,                           02252000
     *           520,520,520,520,520,520,530),TEMP                      02253000
520       NUMBER=NUMBER+1                                               02254000
          FORKED(NUMBER)=TEMP                                           02255000
          LOCS(NUMBER)=LOC                                              02256000
530   CONTINUE                                                          02257000
C                                                                       02258000
C------------------------------< NOW SORT THE LIST OF FORKED PIECES     02259000
C------------------------------< SO THAT THE SCORE WILL REFLECT THE     02260000
C------------------------------< LOSS OF THE SECOND BEST ONE.           02261000
C                                                                       02262000
600   IF(NUMBER.LE.1) GO TO 999                                         02263000
      I1=NUMBER-1                                                       02264000
      DO 750 I=1,I1                                                     02265000
          J1=I+1                                                        02266000
          DO 700 J=J1,NUMBER                                            02267000
              IF(FORKED(I).GE.FORKED(J)) GO TO 700                      02268000
              T=FORKED(I)                                               02269000
              FORKED(I)=FORKED(J)                                       02270000
              FORKED(J)=T                                               02271000
              T=LOCS(I)                                                 02272000
              LOCS(I)=LOCS(J)                                           02273000
              LOCS(J)=T                                                 02274000
700       CONTINUE                                                      02275000
750   CONTINUE                                                          02276000
C                                                                       02277000
C------------------------------< NOW SCAN THE LIST OF FORKED PIECES TO  02278000
C------------------------------< DETERMINE WHAT CAN BE CAPTURED AND     02279000
C------------------------------< WHAT THE GAIN WILL BE                  02280000
C                                                                       02281000
      FIRST=.TRUE.                                                      02282000
      DO 800 I=1,NUMBER                                                 02283000
          SCORE=0                                                       02284000
          IF(MOD(FORKED(I),7).EQ.6) GO TO 760                           02285000
          SCORE=MINATK(LOCS(I),SIDE,NUMATK)                             02286000
760       ATK SC=PVALUE(FORKED(I))-PVALUE(APIECE)                       02287000
          IF(SCORE.GT.0.AND.ATKSC.LE.0) GO TO 800                       02288000
C                                                                       02289000
C------------------------------< THIS PIECE IS ATTACKED AND NOT DEFENDED02290000
C------------------------------< OR IS ATTACKED, DEFENDED BUT IS WORTH  02291000
C------------------------------< MORE THAN THE ATTACKING PIECE. IF THIS 02292000
C------------------------------< IS THE FIRST SUCH PIECE FOUND, ASSUME I02293000
C------------------------------< WILL BE SAVED AND FIND THE NEXT ONE.   02294000
C                                                                       02295000
775       IF(.NOT. FIRST) GO TO 850                                     02296000
          FIRST=.FALSE.                                                 02297000
800   CONTINUE                                                          02298000
C                                                                       02299000
C------------------------------< NOTHING IS SUBJECT TO CAPTURE, RETURN  02300000
C                                                                       02301000
      GO TO 999                                                         02302000
C                                                                       02303000
C------------------------------< A PIECE IS SUBJECT TO CAPTURE, SCORE   02304000
C------------------------------< IS EITHER THE VALUE OF THE PIECE IF    02305000
C------------------------------< IT IS UNDEFENDED, OR THE VALUE OF THE  02306000
C------------------------------< PIECE LESS THE VALUE OF THE CAPTURING  02307000
C------------------------------< PIECE IF IT IS DEFENDED                02308000
C                                                                       02309000
850   FORK=PVALUE(FORKED(I))                                            02310000
      IF(SCORE.GT.0) FORK=FORK-PVALUE(BOARD(SQUARE))                    02311000
999   RETURN                                                            02312000
      END                                                               02313000
$CONTROL SEGMENT=CMND                                                   02314000
      SUBROUTINE HCMND(DEVICE)                                          02315000
C                                                                       02316000
C       ************************************************************    02317000
C       *                                                          *    02318000
C       *      HCMND PROCESSES THE 'H' COMMAND.  THIS LISTS THE    *    02319000
C       *  GAME HISTORY OF ALL MOVES MADE BY BOTH SIDES.  OUTPUT   *    02320000
C       *  MAY BE SENT TO THE LINE PRINTER OR USER TERMINAL.       *    02321000
C       *                                                          *    02322000
C       ************************************************************    02323000
C                                                                       02324000
      IMPLICIT INTEGER*4 (A-Z)                                          02325000
      COMMON /HIST CM/ NMOVES, ANNOTE                                   02326000
      COMMON /TREE/ TREE(400),DMY(81)                                   02327000
      COMMON /COLR CM/ CCOLOR, HCOLOR, COLOR                            02328000
      CHARACTER*5 CCOLOR, HCOLOR                                        02329000
      INTEGER*4 BUF1(30),BUF2(30)                                       02330000
      EQUIVALENCE (BUF1(1),TREE(100)),(BUF2(1),TREE(200))               02331000
      INTEGER*4 ATEXT(31),DORMAT(19),DIGITS(20),LIM(5)                  02332000
      EQUIVALENCE (ATEXT(1),TREE(300))                                  02333000
      COMMON /CHRSET/ ALPHA(44)                                         02334000
      EQUIVALENCE (PERIOD,ALPHA(42)),(BLANK,ALPHA(44))                  02335000
      DATA DORMAT/%"(1X,"J,%" I2,"J,%" 1X,"J,%""J,%"R1, "J,%" 1X,"J,    02336000
     *%"""(""I"J,%""J,%""")"","J,%"T25,"J,%""J,%"R1, "J,%" 1X,"J,       02337000
     *%"""(""I"J,%" "J,%""")"" "J,%"T40,"J,%"31R1"J,%")   "J/           02338000
      DATA DIGITS/%"   1"J,%"   2"J,%"   3"J,%"   4"J,%"   5"J,         02339000
     *%"   6"J,%"   7"J,%"   8"J,%"   9"J,%"  10"J,%"  11"J,            02340000
     *%"  12"J,%"  13"J,%"  14"J,%"  15"J,%"  16"J,%"  17"J,%"  18"J,   02341000
     *%"  19"J,%"  20"J/                                                02342000
      DATA LIM/-1J,9J,99J,999J,9999J/                                   02343000
      M=0                                                               02344000
      I=0                                                               02345000
C                                                                       02346000
C------------------------------< OUTPUT HEADING                         02347000
C                                                                       02348000
      IF(COLOR.EQ.0) WRITE(DEVICE,100)                                  02349000
      IF(COLOR.EQ.1) WRITE(DEVICE,200)                                  02350000
100   FORMAT(5X,'WHITE',15X,'BLACK+')                                   02351000
200   FORMAT(5X,'WHITE+',14X,'BLACK')                                   02352000
300   DO 400 J=1,8                                                      02353000
          BUF2(J)=PERIOD                                                02354000
400   CONTINUE                                                          02355000
      DO 500 J=9,30                                                     02356000
          BUF2(J)=BLANK                                                 02357000
500   CONTINUE                                                          02358000
      DO 550 J=1,32                                                     02359000
          ATEXT(J)=BLANK                                                02360000
550   CONTINUE                                                          02361000
C                                                                       02362000
C------------------------------< READ MOVES FROM HISTORY FILE           02363000
C                                                                       02364000
      ELAP2=0                                                           02365000
      I=I+1                                                             02366000
      IF(I.GT.NMOVES) GO TO 800                                         02367000
      READ(1@I)BUF1,ELAP1,NOTATE                                        02368000
      I=I+1                                                             02369000
      IF(I.GT.NMOVES) GO TO 600                                         02370000
      READ(1@I)BUF2,ELAP2,DUMMY                                         02371000
      IF(DUMMY.NE.0) NOTATE=DUMMY                                       02372000
600   M=M+1                                                             02373000
C                                                                       02374000
C------------------------------< SET UP VARIABLE FORMAT TO OUTPUT       02375000
C------------------------------< '(MOVETIME)'                           02376000
C                                                                       02377000
      DO 620 J=1,5                                                      02378000
          IF(ELAP1.GT.LIM(J)) W1=J                                      02379000
          IF(ELAP2.GT.LIM(J)) W2=J                                      02380000
620   CONTINUE                                                          02381000
      DO 650 J=1,19                                                     02382000
          IF(BUF1(20-J).NE.BLANK) GO TO 675                             02383000
650   CONTINUE                                                          02384000
675   END1=20-J                                                         02385000
      DORMAT(4)=DIGITS(END1)                                            02386000
      DORMAT(8)=DIGITS(W1)                                              02387000
      DO 680 J=1,19                                                     02388000
          IF(BUF2(20-J).NE.BLANK) GO TO 685                             02389000
680   CONTINUE                                                          02390000
685   END2=20-J                                                         02391000
      DORMAT(11)=DIGITS(END2)                                           02392000
      DORMAT(15)=DIGITS(W2)                                             02393000
      IF(NOTATE.NE.0) READ(1@NOTATE)ATEXT, NOTATE                       02394000
      WRITE(DEVICE,DORMAT)M,(BUF1(J),J=1,END1),ELAP1,                   02395000
     *                      (BUF2(J),J=1,END2),ELAP2,                   02396000
     *                      ATEXT                                       02397000
C                                                                       02398000
C------------------------------< READ AND OUTPUT ANNOTATION FOR MOVE    02399000
C                                                                       02400000
690   IF(NOTATE.EQ.0) GO TO 300                                         02401000
      READ(1@NOTATE) ATEXT,NOTATE                                       02402000
      WRITE(DEVICE,900) ATEXT                                           02403000
      GO TO 690                                                         02404000
900   FORMAT(T45,31R1)                                                  02405000
C     GO TO 300                                                         02406000
800   RETURN                                                            02407000
      END                                                               02408000
$CONTROL SEGMENT=IOMV                                                   02409000
      SUBROUTINE INMOVE(PLAY8,*)                                        02410000
C                                                                       02411000
C       ************************************************************    02412000
C       *                                                          *    02413000
C       *      INMOVE IS USED TO TRANSLATE ALL CHESS MOVES FROM    *    02414000
C       *  TEXT STRINGS TO THE INTERNAL FORM USED BY THE PROGRAM.  *    02415000
C       *  THIS IS DONE BY GENERATING ALL LEGAL MOVES FOR THE SIDE *    02416000
C       *  INPUTTING THE MOVE AND THEN USING THAT DATA INPUT TO    *    02417000
C       *  ELIMINATE ALL INCORRECT MOVES.  ENOUGH DATA MUST BE IN- *    02418000
C       *  PUT TO FULLY REMOVE ALL AMBIGUITIES.  USUALLY A SIMPLE  *    02419000
C       *  PXP WILL DO FOR 'PAWN TAKES PAWN', SOMETIMES P/KR5XP    *    02420000
C       *  WILL BE REQUIRED.  XB WILL BE ACCEPTED TO 'TAKE THE     *    02421000
C       *  BISHOP' IF ONLY ONE METHOD OF CAPTURE IS POSSIBLE. AM-  *    02422000
C       *  BIGUOUS, ILLEGAL, AND SYNTACTICAL MOVE ERRORS ARE DE-   *    02423000
C       *  TECTED AND IGNORED AFTER APPROPRIATE DIAGNOSTICS ARE    *    02424000
C       *  PRINTED.                                                *    02425000
C       *                                                          *    02426000
C       ************************************************************    02427000
C                                                                       02428000
      IMPLICIT INTEGER*4 (A-Z)                                          02429000
      COMMON /BOARD/ BOARD(120)                                         02430000
      COMMON /INFO/ TYPE8, VALUE8, TO8, FROM8                           02431000
      COMMON /COLR CM/ CCOLOR, HCOLOR, COLOR                            02432000
      CHARACTER*5 CCOLOR, HCOLOR                                        02433000
      COMMON /TREE/ TREE(400),START(10),STOP(10),DUM1(20),              02434000
     *FROMX(10),TOX(10),DUM2(20),PLY                                    02435000
      COMMON /PRUNE/ WIDTH(10), MIN(10), MAX(10),                       02436000
     * DEPTH, ORDER1, ORDER2                                            02437000
      INTEGER*4 PIECES(6),FILES(5)                                      02438000
      INTEGER*4 FROM(100),TO(100),FPIECE(100),TPIECE(100)               02439000
      EQUIVALENCE (FROM(1),TREE(60)),(TO(1),TREE(120)),                 02440000
     *(FPIECE(1),TREE(180)),(TPIECE(1),TREE(240))                       02441000
      COMMON /BUFFER/ TEXT(30)                                          02442000
      COMMON /TYPES/ NORMAL,CASTRT,CASTLF,ENPASS,PROMOTE                02443000
      COMMON /V CM/ VCMOVE                                              02444000
      INTEGER*4 DIGITS(10)                                              02445000
      LOGICAL EP,PNPROM                                                 02446000
      COMMON /CHRSET/ ALPHA(44)                                         02447000
      EQUIVALENCE (MINUS,ALPHA(38)),(EQUAL,ALPHA(41)),                  02448000
     *(SLASH,ALPHA(39)),(ZERO,ALPHA(27)),(NINE,ALPHA(36)),              02449000
     *(ALPHAO,ALPHA(15)),(ALPHAP,ALPHA(16)),(ALPHAX,ALPHA(24)),         02450000
     *(ALPHAE,ALPHA(5)),(BLANK,ALPHA(44)),(DIGITS(1),ALPHA(28))         02451000
      DATA FILES/%"R"J,%"N"J,%"B"J,%"Q"J,%"K"J/,PIECES/%"P"J,%"N"J,     02452000
     *%"B"J,%"R"J,%"Q"J,%"K"J/                                          02453000
      MTYPE=NORMAL                                                      02454000
      ICOL=1                                                            02455000
      IF(COLOR)2,3,2                                                    02456000
2     FILES(4)=PIECES(6)                                                02457000
      FILES(5)=PIECES(5)                                                02458000
3     ORANK=0                                                           02459000
      OFILE=0                                                           02460000
      OFILEQ=0                                                          02461000
      DRANK=0                                                           02462000
      DFILE=0                                                           02463000
      DFILEQ=0                                                          02464000
      PIECE=0                                                           02465000
      CPIECE=0                                                          02466000
      PPIECE=5                                                          02467000
      FROMSQ=0                                                          02468000
      TOSQ=0                                                            02469000
      EP=.FALSE.                                                        02470000
      PNPROM=.FALSE.                                                    02471000
C                                                                       02472000
C----------------------------------------< GENERATE ALL LEGAL MOVES     02473000
C----------------------------------------< AND LOAD FOR ELIMINATION     02474000
C                                                                       02475000
      PLAYER=MOD(PLAY8,2)                                               02476000
28    FROM8=VCMOVE                                                      02477000
      CALL EXTRCT                                                       02478000
      FROMX(1)=FROM8                                                    02479000
      TOX(1)=TO8                                                        02480000
      TEMP=PLY                                                          02481000
      PLY=2-PLAYER                                                      02482000
      TEMP1=WIDTH(2-PLAYER)                                             02483000
      WIDTH(2-PLAYER)=999                                               02484000
      START(2-PLAYER)=1                                                 02485000
      IF(2-PLAYER.GT.1)STOP(2-PLAYER-1)=0                               02486000
      CALL PREANL                                                       02487000
      CALL MOVGEN                                                       02488000
      PLY=TEMP                                                          02489000
      WIDTH(2-PLAYER)=TEMP1                                             02490000
      ISTOP=STOP(2-PLAYER)                                              02491000
      DO 155 I=1,ISTOP                                                  02492000
          FROM8=TREE(I)                                                 02493000
          CALL EXTRCT                                                   02494000
          FROM(I)=FROM8                                                 02495000
          TO(I)=TO8                                                     02496000
          FPIECE(I)=BOARD(FROM8)                                        02497000
          TPIECE(I)=BOARD(TO8)                                          02498000
155   CONTINUE                                                          02499000
      IF(TEXT(1).EQ.ALPHAO) GO TO30                                     02500000
C                                                                       02501000
C----------------------------------------< PROCESS 'FROM' SQUARE AND PIE02502000
C                                                                       02503000
      DO 351 I=1,4                                                      02504000
          IF(TEXT(I).EQ.SLASH) GO TO 361                                02505000
          IF(TEXT(I).EQ.MINUS) GO TO 361                                02506000
          IF(TEXT(I).EQ.ALPHAX) GO TO 361                               02507000
351   CONTINUE                                                          02508000
      GO TO 103                                                         02509000
361   IF(I.LT.4) GO TO 371                                              02510000
      OFILEQ=TEXT(1)                                                    02511000
      OFILE=TEXT(2)                                                     02512000
      ICOL=3                                                            02513000
      GO TO 38                                                          02514000
371   IF(I.LT.3) GO TO 38                                               02515000
      OFILEQ=TEXT(1)                                                    02516000
      IF(TEXT(2).NE.ALPHAP) GO TO 4463                                  02517000
      OFILE=OFILEQ                                                      02518000
      OFILEQ=0                                                          02519000
4463  ICOL=2                                                            02520000
38    IF(I.LT.2) GO TO 385                                              02521000
      PIECE=TEXT(ICOL)                                                  02522000
      ICOL=ICOL+1                                                       02523000
      IF(TEXT(ICOL).NE.SLASH) GO TO 385                                 02524000
      ICOL=ICOL+1                                                       02525000
      DO 381 I=1,4                                                      02526000
          IF(TEXT(ICOL-1+I).EQ.MINUS) GO TO 382                         02527000
          IF(TEXT(ICOL-1+I).EQ.ALPHAX) GO TO 382                        02528000
381   CONTINUE                                                          02529000
      GO TO 103                                                         02530000
382   IF(I.LT.4) GO TO 383                                              02531000
      OFILEQ=TEXT(ICOL)                                                 02532000
      OFILE=TEXT(ICOL+1)                                                02533000
      ORANK=TEXT(ICOL+2)                                                02534000
      ICOL=ICOL+3                                                       02535000
      GO TO 385                                                         02536000
383   IF(I.LT.3) GO TO 384                                              02537000
      OFILE=TEXT(ICOL)                                                  02538000
      ORANK=TEXT(ICOL+1)                                                02539000
      ICOL=ICOL+2                                                       02540000
      GO TO 385                                                         02541000
384   IF(I.LT.2) GO TO 103                                              02542000
      ORANK=TEXT(ICOL)                                                  02543000
      ICOL=ICOL+1                                                       02544000
      IF(ORANK.GE.ZERO.AND.ORANK.LE.NINE) GO TO 385                     02545000
      OFILE=ORANK                                                       02546000
      ORANK=0                                                           02547000
385   STYPE=TEXT(ICOL)                                                  02548000
      ICOL=ICOL+1                                                       02549000
      IF(STYPE.EQ.MINUS) GO TO 5                                        02550000
      IF(STYPE.NE.MINUS.AND.STYPE.NE.ALPHAX) GO TO 103                  02551000
C                                                                       02552000
C----------------------------------------< PROCESS 'TO' SQUARE AND PIECE02553000
C                                                                       02554000
      DO 45 I=1,4                                                       02555000
          IF(TEXT(ICOL-1+I).EQ.SLASH) GO TO 46                          02556000
          IF(TEXT(ICOL-1+I).EQ.BLANK) GO TO 46                          02557000
45    CONTINUE                                                          02558000
      GO TO 103                                                         02559000
46    IF(I.LT.4) GO TO 47                                               02560000
      DFILEQ=TEXT(ICOL)                                                 02561000
      DFILE=TEXT(ICOL+1)                                                02562000
      ICOL=ICOL+2                                                       02563000
      GO TO 50                                                          02564000
47    IF(I.LT.3) GO TO 50                                               02565000
      IF(TEXT(ICOL-1+I).EQ.EQUAL) GO TO 46                              02566000
      DFILEQ=TEXT(ICOL)                                                 02567000
      IF(TEXT(ICOL+1).NE.ALPHAP) GO TO 4464                             02568000
      DFILE=DFILEQ                                                      02569000
      DFILEQ=0                                                          02570000
4464  ICOL=ICOL+1                                                       02571000
50    IF(I.LT.2) GO TO 6                                                02572000
      CPIECE=TEXT(ICOL)                                                 02573000
      ICOL=ICOL+1                                                       02574000
      IF(TEXT(ICOL).NE.SLASH) GO TO 6                                   02575000
      ICOL=ICOL+1                                                       02576000
5     DO 581 I=1,4                                                      02577000
          IF(TEXT(ICOL-1+I).EQ.BLANK) GO TO 582                         02578000
          IF(TEXT(ICOL-1+I).EQ.EQUAL) GO TO 582                         02579000
581   CONTINUE                                                          02580000
      GO TO 103                                                         02581000
582   IF(I.LT.4) GO TO 583                                              02582000
      DFILEQ=TEXT(ICOL)                                                 02583000
      DFILE=TEXT(ICOL+1)                                                02584000
      DRANK=TEXT(ICOL+2)                                                02585000
      ICOL=ICOL+3                                                       02586000
      GO TO 585                                                         02587000
583   IF(I.LT.3) GO TO 584                                              02588000
      DFILE=TEXT(ICOL)                                                  02589000
      DRANK=TEXT(ICOL+1)                                                02590000
      ICOL=ICOL+2                                                       02591000
      GO TO 585                                                         02592000
584   IF(I.LT.2) GO TO 103                                              02593000
      DRANK=TEXT(ICOL)                                                  02594000
      ICOL=ICOL+1                                                       02595000
      IF(DRANK.GE.ZERO.AND.DRANK.LE.NINE) GO TO 585                     02596000
      DFILE=DRANK                                                       02597000
      DRANK=0                                                           02598000
585   IF(TEXT(ICOL).NE.EQUAL) GO TO 6                                   02599000
      PPIECE=TEXT(ICOL+1)                                               02600000
      PNPROM=.TRUE.                                                     02601000
      ICOL=ICOL+2                                                       02602000
6     IF(TEXT(ICOL).NE.BLANK) GO TO 103                                 02603000
      IF(TEXT(ICOL+1).EQ.ALPHAE) EP=.TRUE.                              02604000
6645  IF(OFILE.EQ.PIECES(6).OR.OFILE.EQ.PIECES(5)) OFILEQ=OFILE         02605000
      IF(DFILE.EQ.PIECES(6).OR.DFILE.EQ.PIECES(5)) DFILEQ=DFILE         02606000
C                                                                       02607000
C----------------------------------------< CONVERT CHARACTER STRINGS TO 02608000
C----------------------------------------< INTEGERS FOR PROCESSING      02609000
C                                                                       02610000
      DO 7   I=1,8                                                      02611000
          IF(ORANK.EQ.DIGITS(I)) ORANK=I+2                              02612000
          IF(DRANK.EQ.DIGITS(I)) DRANK=I+2                              02613000
7     CONTINUE                                                          02614000
      IF(DRANK.LT.0.OR.ORANK.LT.0) GO TO 103                            02615000
      IF(EP.AND.DRANK.NE.0) DRANK=DRANK+1                               02616000
      IF(PLAYER.EQ.0.AND.ORANK.NE.0) ORANK=13-ORANK                     02617000
      IF(PLAYER.EQ.0.AND.DRANK.NE.0) DRANK=13-DRANK                     02618000
      DO 8   I=1,5                                                      02619000
          IF(OFILEQ.EQ.FILES(I)) OFILEQ=I+1                             02620000
          IF(DFILEQ.EQ.FILES(I)) DFILEQ=I+1                             02621000
          IF(OFILE.EQ.FILES(I)) OFILE=I+1                               02622000
          IF(DFILE.EQ.FILES(I)) DFILE=I+1                               02623000
8     CONTINUE                                                          02624000
      IF(DFILE.LT.0.OR.OFILE.LT.0) GO TO 103                            02625000
      IF(DFILEQ.LT.0.OR.OFILEQ.LT.0) GO TO 103                          02626000
      DO 9   I=1,6                                                      02627000
          IF(PPIECE.EQ.PIECES(I)) PPIECE=I                              02628000
          IF(CPIECE.EQ.PIECES(I)) CPIECE=I                              02629000
          IF(PIECE.EQ.PIECES(I)) PIECE=I                                02630000
9     CONTINUE                                                          02631000
      IF(PIECE.LT.0.OR.PIECE.GT.6) GO TO 103                            02632000
      IF(CPIECE.LT.0.OR.CPIECE.GT.6) GO TO 103                          02633000
      IF(PPIECE.LT.0.OR.PPIECE.GT.6) GO TO 103                          02634000
      IF(PIECE.GT.0) PIECE=PIECE+7*PLAYER                               02635000
      IF(PPIECE.GT.0) PPIECE=PPIECE+7*PLAYER                            02636000
      IF(CPIECE.GT.0) CPIECE=CPIECE+7-7*PLAYER                          02637000
C                                                                       02638000
C----------------------------------------< ELIMINATE CASTLING MOVES,    02639000
C----------------------------------------< EN PASSANT, PROMOTION, ETC.  02640000
C                                                                       02641000
      DO 10 I=1,ISTOP                                                   02642000
          FROM8=TREE(I)                                                 02643000
          CALL EXTRCT                                                   02644000
          IF(TYPE8.EQ.CASTLF.OR.TYPE8.EQ.CASTRT) FROM(I)=0              02645000
          IF(EP.AND.TYPE8.NE.ENPASS) FROM(I)=0                          02646000
          IF(STYPE.EQ.ALPHAX.AND.TYPE8.EQ.ENPASS) TPIECE(I)=8-7*PLAYER  02647000
          IF(PNPROM.AND.TYPE8.NE.PROMOTE) FROM(I)=0                     02648000
10    CONTINUE                                                          02649000
C                                                                       02650000
C----------------------------------------< ELIMINATE ALL MOVES EXCEPT   02651000
C----------------------------------------< MOVES OF CORRECT PIECE       02652000
C                                                                       02653000
      DO 12 I=1,ISTOP                                                   02654000
          IF(PIECE.NE.FPIECE(I).AND.PIECE.GT.0) FROM(I)=0               02655000
          IF(STYPE.NE.ALPHAX) GO TO 11                                  02656000
          IF(TPIECE(I).EQ.7) FROM(I)=0                                  02657000
          IF(CPIECE.NE.TPIECE(I).AND.CPIECE.NE.0) FROM(I)=0             02658000
          GO TO 12                                                      02659000
11        IF(TPIECE(I).NE.7) FROM(I)=0                                  02660000
12    CONTINUE                                                          02661000
C                                                                       02662000
C----------------------------------------< ELIMINATE ALL MOVES EXCEPT   02663000
C----------------------------------------< MOVES ON CORRECT SIDE OF BOAR02664000
C                                                                       02665000
      DO 14 I=1,ISTOP                                                   02666000
          IF(OFILEQ.EQ.0) GO TO 13                                      02667000
          T=6-MOD((FROM(I)-1)/5+1,2)                                    02668000
          IF(T.NE.OFILEQ) FROM(I)=0                                     02669000
13        IF(DFILEQ.EQ.0) GO TO 14                                      02670000
          T=6-MOD((TO(I)-1)/5+1,2)                                      02671000
          IF(T.NE.DFILEQ) FROM(I)=0                                     02672000
14    CONTINUE                                                          02673000
C                                                                       02674000
C----------------------------------------< ELIMINATE ALL MOVES EXCEPT   02675000
C----------------------------------------< MOVES ON CORRECT FILES       02676000
C                                                                       02677000
      DO 16 I=1,ISTOP                                                   02678000
          IF(OFILE.EQ.0) GO TO 15                                       02679000
          T=MOD(FROM(I)-1,10)+1                                         02680000
          IF(T.NE.OFILE.AND.T.NE.11-OFILE) FROM(I)=0                    02681000
15        IF(DFILE.EQ.0) GO TO 16                                       02682000
          T=MOD(TO(I)-1,10)+1                                           02683000
          IF(T.NE.DFILE.AND.T.NE.11-DFILE) FROM(I)=0                    02684000
16    CONTINUE                                                          02685000
C                                                                       02686000
C----------------------------------------< ELIMINATE ALL MOVES EXCEPT   02687000
C----------------------------------------< MOVES ON CORRECT RANK        02688000
C                                                                       02689000
      DO 18 I=1,ISTOP                                                   02690000
          IF(ORANK.EQ.0) GO TO 17                                       02691000
          T=(FROM(I)-1)/10+1                                            02692000
          IF(T.NE.ORANK) FROM(I)=0                                      02693000
17        IF(DRANK.EQ.0) GO TO 18                                       02694000
          T=(TO(I)-1)/10+1                                              02695000
          IF(T.NE.DRANK) FROM(I)=0                                      02696000
18    CONTINUE                                                          02697000
C                                                                       02698000
C----------------------------------------< CHECK TO MAKE SURE ONLY      02699000
C----------------------------------------< ONE MOVE IS LEFT IN TREE     02700000
C                                                                       02701000
      IC=0                                                              02702000
      DO 19 I=1,ISTOP                                                   02703000
          IF(FROM(I).EQ.0) GO TO 19                                     02704000
          IC=IC+1                                                       02705000
          IMOVE=I                                                       02706000
19    CONTINUE                                                          02707000
      IF(IC.GT.1) GO TO 101                                             02708000
      IF(IC.EQ.0) GO TO 102                                             02709000
      FROM8=TREE(IMOVE)                                                 02710000
      CALL EXTRCT                                                       02711000
      VALUE8=PPIECE                                                     02712000
      RETURN                                                            02713000
C                                                                       02714000
C----------------------------------------< CHECK CASTLING MOVES         02715000
C                                                                       02716000
30    DO 301 I=1,30                                                     02717000
          IF(TEXT(2).NE.MINUS.OR.TEXT(3).NE.ALPHAO) GO TO 102           02718000
301   CONTINUE                                                          02719000
      IF(TEXT(4).NE.BLANK) GO TO 35                                     02720000
      IF(PLAYER) 31,34,31                                               02721000
31    IF(COLOR) 32,33,32                                                02722000
32    TYPEMV=CASTRT                                                     02723000
      GO TO 36                                                          02724000
33    TYPEMV=CASTLF                                                     02725000
      GO TO 36                                                          02726000
34    IF(COLOR) 33,32,33                                                02727000
35    IF(TEXT(4).NE.MINUS.OR.TEXT(5).NE.ALPHAO) GO TO 102               02728000
      IF(PLAYER) 34,31,34                                               02729000
36    DO 37 I=1,ISTOP                                                   02730000
          FROM8=TREE(I)                                                 02731000
          CALL EXTRCT                                                   02732000
          IF(TYPEMV.EQ.TYPE8) RETURN                                    02733000
37    CONTINUE                                                          02734000
      GO TO 102                                                         02735000
C                                                                       02736000
C----------------------------------------< ERROR MESSAGES               02737000
C                                                                       02738000
101   WRITE(6,201)                                                      02739000
201   FORMAT(1X,'AMBIGUOUS MOVE')                                       02740000
      RETURN 1                                                          02741000
102   WRITE(6,202)                                                      02742000
202   FORMAT(1X,'ILLEGAL MOVE')                                         02743000
      RETURN 1                                                          02744000
103   WRITE(6,203)                                                      02745000
203   FORMAT(1X,'UNRECOGNIZABLE MOVE')                                  02746000
      RETURN 1                                                          02747000
      END                                                               02748000
      SUBROUTINE INPUT(VALUE)                                           02749000
C                                                                       02750000
C       ************************************************************    02751000
C       *                                                          *    02752000
C       *      INPUT IS A FUNCTION USED TO INPUT INTEGER*4 VALUES    *  02753000
C       *  FROM THE USER TERMINAL.  THE DATA IS INPUT ON AN A FOR- *    02754000
C       *  MAT AND TRANSLATED SO THAT 'I2' AND 'I3' TYPE FORMATS   *    02755000
C       *  ARE NOT USED.  THIS ALLOWS THE NUMBERS TO BE INPUT ON A *    02756000
C       *  FREE FORMAT WITH LEADING BLANKS AND ZEROES IF DESIRED   *    02757000
C       *  WITHOUT HAVING TO REMEMBER HOW MANY DIGITS TO TYPE IN   *    02758000
C       *  FOR THIS PARTICULAR OPTION.                             *    02759000
C       *                                                          *    02760000
C       ************************************************************    02761000
C                                                                       02762000
      IMPLICIT INTEGER*4 (A-Z)                                          02763000
      COMMON /CHRSET/ ALPHA(44)                                         02764000
      INTEGER*4 DIGITS(10)                                              02765000
      EQUIVALENCE (DIGITS(1),ALPHA(27)),(MINUS,ALPHA(38)),              02766000
     *(PLUS,ALPHA(37)),(BLANK,ALPHA(44))                                02767000
      COMMON /TREE/ ARRAY(481)                                          02768000
      INTEGER*4 TEXT(72)                                                02769000
      EQUIVALENCE (TEXT(1),ARRAY(200))                                  02770000
100   VALUE=0                                                           02771000
      SIGN=1                                                            02772000
      READ(5,200,END=999)TEXT                                           02773000
200   FORMAT(72R1)                                                      02774000
      DO 600 I=1,72                                                     02775000
          IF(TEXT(I).EQ.BLANK) GO TO 600                                02776000
          DO 300 J=1,10                                                 02777000
              IF(TEXT(I).EQ.DIGITS(J)) GO TO 500                        02778000
300       CONTINUE                                                      02779000
          IF(TEXT(I).EQ.PLUS) SIGN=1                                    02780000
          IF(TEXT(I).EQ.MINUS) SIGN=-1                                  02781000
          IF(TEXT(I).EQ.PLUS.OR.TEXT(I).EQ.MINUS) GO TO 600             02782000
          WRITE(6,400)                                                  02783000
400       FORMAT(1X,'ILLEGAL NUMERIC INPUT - TRY AGAIN')                02784000
          GO TO 100                                                     02785000
500       VALUE=VALUE*10+J-1                                            02786000
600   CONTINUE                                                          02787000
      VALUE=VALUE*SIGN                                                  02788000
999   RETURN                                                            02789000
      END                                                               02790000
      LOGICAL FUNCTION ISOLAT(SQUARE,SIDE)                              02791000
C                                                                       02792000
C       ************************************************************    02793000
C       *                                                          *    02794000
C       *      ISOLAT IS USED TO DETERMINE IF A PAWN IS ISOLATED.  *    02795000
C       *  IT CHECKS TO SEE IF THERE ARE ANY FRIENDLY PAWNS ON     *    02796000
C       *  ADJACENT FILES TO SUPPORT THE ONE ON 'SQUARE'.  IF NOT, *    02797000
C       *  ISOLAT IS SET TO TRUE.                                  *    02798000
C       *                                                          *    02799000
C       ************************************************************    02800000
C                                                                       02801000
      IMPLICIT INTEGER*4 (A-Z)                                          02802000
      COMMON /BOARD/ BOARD(120)                                         02803000
      COMMON /P SM/ PADVNC, PPAWN, IPAWN, DPAWN, TPAWN, CPAWN,          02804000
     * ABREST, PPSHSC                                                   02805000
      LOGICAL SIDE                                                      02806000
      ISOLAT=.FALSE.                                                    02807000
C                                                                       02808000
C------------------------------< DETERMINE VALUE OF FRIENDLY PAWNS      02809000
C                                                                       02810000
      IF(SIDE) GO TO 200                                                02811000
100   FPAWN=8                                                           02812000
      GO TO 300                                                         02813000
200   FPAWN=1                                                           02814000
C                                                                       02815000
C------------------------------< CHECK TO SEE IF THE PAWN IS ISOLATED   02816000
C------------------------------< BY SCANNING ADJACENT FILES FOR THE     02817000
C------------------------------< PRESENCE OF FRIENDLY PAWNS.            02818000
C                                                                       02819000
300   SQ=MOD(SQUARE,10)+20                                              02820000
400   SQ=SQ+10                                                          02821000
      IF(BOARD(SQ-1).EQ.FPAWN) GO TO 500                                02822000
      IF(BOARD(SQ+1).EQ.FPAWN) GO TO 500                                02823000
        IF(SQ.LT.80) GO TO 400                                          02824000
C                                                                       02825000
C------------------------------< PAWN IS ISOLATED, RETURN 'TRUE'        02826000
C                                                                       02827000
      ISOLAT=.TRUE.                                                     02828000
500   RETURN                                                            02829000
      END                                                               02830000
$CONTROL SEGMENT=PC                                                     02831000
      SUBROUTINE KING                                                   02832000
C                                                                       02833000
C       ************************************************************    02834000
C       *                                                          *    02835000
C       *      KING GENERATES ALL KING MOVES.  SUBROUTINE SCORE IS *    02836000
C       *  CALLED TO COMPUTE THE PLAUSIBILITY SCORE FOR THE MOVE,  *    02837000
C       *  AFTER WHICH THE MOVE IS ENTERED IN THE MOVE LIST.       *    02838000
C       *                                                          *    02839000
C       ************************************************************    02840000
C                                                                       02841000
      IMPLICIT INTEGER*4 (A-Z)                                          02842000
      COMMON /BOARD/ BOARD(120)                                         02843000
      COMMON /MOVE CM/ FROMSQ, TOSQ, SIDE                               02844000
      COMMON /MOVES/ RK(4),BP(4),KT(8),KG(8)                            02845000
      COMMON /K LOC CM/ CKINGL, HKINGL                                  02846000
      COMMON /INFO/ TYPE8, VALUE8, TO8, FROM8                           02847000
      COMMON /TYPES/ NORMAL,CASTRT,CASTLF,ENPASS,PROMOTE                02848000
      LOGICAL SIDE, CHECK                                               02849000
1000  DO 1020 I=1,8                                                     02850000
          TO8=FROM8+KG(I)                                               02851000
          TOSQ=BOARD(TO8)                                               02852000
          TYPE8=NORMAL                                                  02853000
          IF(SIDE.AND.TOSQ.LT.7) GO TO 1020                             02854000
          IF(.NOT.SIDE.AND.TOSQ.GT.7) GO TO 1020                        02855000
          IF(TOSQ.EQ.14) GO TO 1020                                     02856000
          BOARD(TO8)=FROMSQ                                             02857000
          IF(SIDE) HKINGL=TO8                                           02858000
          IF(.NOT.SIDE) CKINGL=TO8                                      02859000
          IF(CHECK(SIDE)) GO TO 1010                                    02860000
          CALL SCORE                                                    02861000
          CALL ENTER                                                    02862000
1010      BOARD(TO8)=TOSQ                                               02863000
1020  CONTINUE                                                          02864000
          IF(SIDE) HKINGL=FROM8                                         02865000
          IF(.NOT.SIDE) CKINGL=FROM8                                    02866000
      RETURN                                                            02867000
      END                                                               02868000
$CONTROL SEGMENT=PC                                                     02869000
      SUBROUTINE KNIGHT                                                 02870000
C                                                                       02871000
C       ************************************************************    02872000
C       *                                                          *    02873000
C       *      KNIGHT GENERATES ALL KNIGHT MOVES.  SUBROUTINE      *    02874000
C       *  SCORE IS CALLED TO COMPUTE THE PLAUSIBILITY SCORE FOR   *    02875000
C       *  THE MOVE, AFTER WHICH THE MOVE IS ENTERED IN THE MOVE   *    02876000
C       *  LIST.                                                   *    02877000
C       *                                                          *    02878000
C       ************************************************************    02879000
C                                                                       02880000
      IMPLICIT INTEGER*4 (A-Z)                                          02881000
      COMMON /BOARD/ BOARD(120)                                         02882000
      COMMON /MOVES/ RK(4),BP(4),KT(8),KG(8)                            02883000
      COMMON /MOVE CM/ FROMSQ, TOSQ, SIDE                               02884000
      COMMON /INFO/ TYPE8, VALUE8, TO8, FROM8                           02885000
      COMMON /TYPES/ NORMAL,CASTRT,CASTLF,ENPASS,PROMOTE                02886000
      LOGICAL SIDE, CHECK                                               02887000
1000  BOARD(FROM8)=7                                                    02888000
      DO 1020 I=1,8                                                     02889000
          TO8=FROM8+KT(I)                                               02890000
          TOSQ=BOARD(TO8)                                               02891000
          TYPE8=NORMAL                                                  02892000
          IF(SIDE.AND.TOSQ.LT.7) GO TO 1020                             02893000
          IF(.NOT.SIDE.AND.TOSQ.GT.7) GO TO 1020                        02894000
          IF(TOSQ.EQ.14) GO TO 1020                                     02895000
          BOARD(TO8)=FROMSQ                                             02896000
          IF(CHECK(SIDE)) GO TO 1010                                    02897000
          CALL SCORE                                                    02898000
          CALL ENTER                                                    02899000
1010      BOARD(TO8)=TOSQ                                               02900000
1020  CONTINUE                                                          02901000
      RETURN                                                            02902000
      END                                                               02903000
      INTEGER FUNCTION KSCORE(SQUARE,SIDE)                              02904000
C                                                                       02905000
C       ************************************************************    02906000
C       *                                                          *    02907000
C       *      KSCORE IS USED TO COMPUTE THE PLAUSIBILITY SCORE    *    02908000
C       *  FOR KING MOVES. THE SCORE IS OBTAINED DIRECTLY FROM     *    02909000
C       *  THE KING CONTROL BOARD FOR THE SIDE TO MOVE.  (CKSCOR,  *    02910000
C       *  HKSCOR IN COMMON BLOCK 'K BD SM').                      *    02911000
C       *                                                          *    02912000
C       ************************************************************    02913000
C                                                                       02914000
      IMPLICIT INTEGER*4 (A-Z)                                          02915000
      COMMON /K BD SM/ CKSCOR(100), HKSCOR(100)                         02916000
      LOGICAL SIDE                                                      02917000
      IF(SIDE) GO TO 200                                                02918000
C                                                                       02919000
C==============================< COMPUTER SCORING                       02920000
C                                                                       02921000
100   KSCORE=CKSCOR(SQUARE)                                             02922000
      RETURN                                                            02923000
C                                                                       02924000
C==============================< HUMAN SCORING                          02925000
C                                                                       02926000
200   KSCORE=HKSCOR(SQUARE)                                             02927000
      RETURN                                                            02928000
      END                                                               02929000
$CONTROL SEGMENT=CMND                                                   02930000
      SUBROUTINE LMCMND(DEVICE)                                         02931000
C                                                                       02932000
C       ************************************************************    02933000
C       *                                                          *    02934000
C       *      LMCMND IS USED TO PROCESS THE 'LM' COMMAND WHICH    *    02935000
C       *  IS USED TO DUMP OUT ALL LEGAL MOVES FOR EITHER SIDE.    *    02936000
C       *  IF THE COMPUTER MOVES ARE DESIRED, THE LAST MOVE IS     *    02937000
C       *  TEMPORARILY 'UN-MADE' AND ALL LEGAL MOVES ARE THEN      *    02938000
C       *  LISTED.  IF THE OUTPUT IS DIRECTED TO THE LINE PRINTER, *    02939000
C       *  THE MOVES ARE ALWAYS FOR THE COMPUTER AND NO CHOICE IS  *    02940000
C       *  GIVEN.                                                  *    02941000
C       *                                                          *    02942000
C       ************************************************************    02943000
C                                                                       02944000
      IMPLICIT INTEGER*4 (A-Z)                                          02945000
      COMMON /BOARD/ BOARD(120)                                         02946000
      COMMON /BUFFER/ TEXT(30)                                          02947000
      COMMON /TREE/ TREE(400),START(10),STOP(10),WHICH(10),BACKUP(10),  02948000
     *FROM(10),TO(10),VALUE(10),TYPE(10),PLY                            02949000
      COMMON /INFO/ TYPE8, VALUE8, TO8, FROM8                           02950000
C     COMMON /DATA/ CMOVE, SMOVE, HFROM8, HTO8, HTYPE8, MOVE            02951000
      COMMON /ORDR CM/ VAL(100)                                         02952000
      COMMON /PRUNE/ WIDTH(10), MIN(10), MAX(10),                       02953000
     * DEPTH, ORDER1, ORDER2                                            02954000
      COMMON /V CM/ VCMOVE                                              02955000
      COMMON /P V MOVE/ PVMOVE, OVMOVE                                  02956000
      COMMON /PC CM/ CMNDS(10,3), NCMNDS, PCMODE, EXMODE                02957000
      LOGICAL PCMODE, EXMODE                                            02958000
C                                                                       02959000
C------------------------------< INITIALIZE                             02960000
C                                                                       02961000
      FROM8=VCMOVE                                                      02962000
      CALL EXTRCT                                                       02963000
      TO(1)=TO8                                                         02964000
      FROM(1)=FROM8                                                     02965000
      TYPE(1)=TYPE8                                                     02966000
      START(2)=1                                                        02967000
      PLY=1                                                             02968000
70    FORMAT(1X,'SIMPLE',2X,'COMPLEX',3X,'MOVE')                        02969000
      IF(EXMODE) GO TO 50                                               02970000
1     WRITE(DEVICE,30)                                                  02971000
      CALL INPUT(PLY)                                                   02972000
      IF(PLY.EQ.0) RETURN                                               02973000
      IF(PLY.EQ.1) GO TO 50                                             02974000
5     WRITE(DEVICE,70)                                                  02975000
C                                                                       02976000
C------------------------------< GENERATE ALL LEGAL MOVES               02977000
C                                                                       02978000
      CALL PREANL                                                       02979000
      TEMP=PVMOVE                                                       02980000
      PVMOVE=OVMOVE                                                     02981000
      CALL MOVGEN                                                       02982000
      PVMOVE=TEMP                                                       02983000
C                                                                       02984000
C------------------------------< OUTPUT THE MOVE LIST                   02985000
C                                                                       02986000
      N=START(PLY+1)-START(PLY)                                         02987000
      DO 10 I=1,N                                                       02988000
          FROM8=TREE(I)                                                 02989000
          CALL EXTRCT                                                   02990000
          CALL OUTMOV(FROM8,TO8,TYPE8,0,PLY,BOARD)                      02991000
          WRITE(DEVICE,20) VALUE8, VAL(I), TEXT                         02992000
20        FORMAT(1X,I6,2X,I6,2X,30R1)                                   02993000
          IF(I.EQ.STOP(PLY)) WRITE(DEVICE,15)                           02994000
10    CONTINUE                                                          02995000
15    FORMAT(1X,27('-'))                                                02996000
      IF(PLY.EQ.1) GO TO 60                                             02997000
      RETURN                                                            02998000
30    FORMAT(1X,'FOR WHICH SIDE? (ME=1, YOU=2)')                        02999000
C 40  FORMAT(I)                                                         03000000
C                                                                       03001000
C------------------------------< UNMAKE PROGRAM'S LAST MOVE TO          03002000
C------------------------------< LIST ALL OF THE PROGRAM'S LEGAL        03003000
C------------------------------< MOVES.                                 03004000
C                                                                       03005000
50    FROM8=VCMOVE                                                      03006000
      IF(FROM8.EQ.0) GO TO 5                                            03007000
      CALL EXTRCT                                                       03008000
      CALL PUMVER                                                       03009000
      GO TO 5                                                           03010000
60    FROM8=VCMOVE                                                      03011000
      IF(FROM8.EQ.0) RETURN                                             03012000
      CALL EXTRCT                                                       03013000
      CALL PMOVER                                                       03014000
      RETURN                                                            03015000
      END                                                               03016000
      SUBROUTINE LOCATE                                                 03017000
C                                                                       03018000
C       ************************************************************    03019000
C       *                                                          *    03020000
C       *      LOCATE IS USED TO LOCATE ANY PIECES NECESSARY BE-   *    03021000
C       *  FORE STARTING THE SEARCH.  THE KINGS ARE FOUND SO THAT  *    03022000
C       *  CHECK WILL NOT HAVE TO LOCATE THEM EACH TIME IT IS      *    03023000
C       *  CALLED; QUEENS, BISHOPS, ETC. ARE LOCATED AND ACCOUNTED *    03024000
C       *  FOR FOR LATER REFERENCE.  THIS IS DONE BECAUSE IT IS    *    03025000
C       *  CHEAPER IN TERMS OF TIME TO LOCATE EVERYTHING ONCE AND  *    03026000
C       *  KEEP UP WITH WHEN IT IS MOVED, THAN TO LOCATE SOMETHING *    03027000
C       *  WHEN IT'S PRESENCE OR ABSENCE IS IMPORTANT.             *    03028000
C       *                                                          *    03029000
C       ************************************************************    03030000
C                                                                       03031000
      IMPLICIT INTEGER*4 (A-Z)                                          03032000
      COMMON /BOARD/ BOARD(120)                                         03033000
      COMMON /K LOC CM/ CKINGL, HKINGL                                  03034000
      COMMON /Q LOC CM/ CQUEEN, HQUEEN                                  03035000
      COMMON /R LOC CM/ ONECRK, ONEHRK                                  03036000
      COMMON /B LOC CM/ ONECBP, ONEHBP                                  03037000
      LOGICAL CQUEEN, HQUEEN, ONECRK, ONEHRK, ONECBP, ONEHBP            03038000
      CQUEEN=.FALSE.                                                    03039000
      HQUEEN=.FALSE.                                                    03040000
      ONECRK=.FALSE.                                                    03041000
      ONEHRK=.FALSE.                                                    03042000
      ONECBP=.FALSE.                                                    03043000
      ONEHBP=.FALSE.                                                    03044000
      NCR=0                                                             03045000
      NHR=0                                                             03046000
      NCB=0                                                             03047000
      NHB=0                                                             03048000
C                                                                       03049000
C------------------------------< LOCATE ALL PIECES                      03050000
C                                                                       03051000
      DO 10 I=22,99                                                     03052000
          IF(BOARD(I).EQ.6) HKINGL=I                                    03053000
          IF(BOARD(I).EQ.13) CKINGL=I                                   03054000
          IF(BOARD(I).EQ.3) NHB=NHB+1                                   03055000
          IF(BOARD(I).EQ.4) NHR=NHR+1                                   03056000
          IF(BOARD(I).EQ.5) HQUEEN=.TRUE.                               03057000
          IF(BOARD(I).EQ.10) NCB=NCB+1                                  03058000
          IF(BOARD(I).EQ.11) NCR=NCR+1                                  03059000
          IF(BOARD(I).EQ.12) CQUEEN=.TRUE.                              03060000
10    CONTINUE                                                          03061000
      IF(NCB.NE.2) ONECBP=.TRUE.                                        03062000
      IF(NHB.NE.2) ONEHBP=.TRUE.                                        03063000
      IF(NCR.NE.2) ONECRK=.TRUE.                                        03064000
      IF(NHR.NE.2) ONEHRK=.TRUE.                                        03065000
      RETURN                                                            03066000
      END                                                               03067000
$CONTROL SEGMENT=LK                                                     03068000
      SUBROUTINE LOOK                                                   03069000
C                                                                       03070000
C       ************************************************************    03071000
C       *                                                          *    03072000
C       *      LOOK IS THE MAIN DRIVER FOR THE CHESS TREE SEARCH.  *    03073000
C       *  IT USES THE MINIMAX SEARCH WITH ALPHA/BETA PRUNING AS   *    03074000
C       *  DESCRIBED BY CLAUDE SHANNON'S TYPE A SEARCH STRATEGY.   *    03075000
C       *  BASICALLY, IN DOING A DEPTH FIRST SEARCH, LOOK GEN-     *    03076000
C       *  ERATES ALL LEGAL MOVES AND MAKES THEM ONE AT A TIME AS  *    03077000
C       *  IT ADVANCES TO THE NEXT DEEPER LEVEL.  IF A CHECK-      *    03078000
C       *  MATE IS FOUND, THAT MOVE IS IMMEDIATELY SELECTED FOR    *    03079000
C       *  THAT LEVEL AND BACKED UP.                               *    03080000
C       *      THE COMPUTER WILL AVOID DRAWS AT ANY LEVEL IN THE   *    03081000
C       *  TREE.  IT WILL REMEMBER AN IMMEDIATE DRAWING MOVE AND   *    03082000
C       *  AFTER COMPLETING THE SEARCH WILL DETERMINE IF IT'S      *    03083000
C       *  POSITION IS BAD ENOUGH TO WARRANT DRAWING THE GAME.     *    03084000
C       *                                                          *    03085000
C       ************************************************************    03086000
C                                                                       03087000
      IMPLICIT INTEGER*4 (A-Z)                                          03088000
      COMMON /BOARD/ BOARD(120)                                         03089000
      COMMON /DATA/ CMOVE, SMOVE, HFROM8, HTO8, HTYPE8, MOVE            03090000
      COMMON /TREE/ TREE(400),START(10),STOP(10),WHICH(10),BACKUP(10),  03091000
     *FROM(10),TO(10),VALUE(10),TYPE(10),PLY                            03092000
      COMMON /MSCORE/ SCORE                                             03093000
      COMMON /PRUNE/ WIDTH(10), MIN(10), MAX(10),                       03094000
     * DEPTH, ORDER1, ORDER2                                            03095000
      COMMON /INFO/ TYPE8, VALUE8, TO8, FROM8                           03096000
      LOGICAL CHECK, DRAW,SIDE                                          03097000
      COMMON /TRACE/ TRACE(20,10),TFLAG                                 03098000
      COMMON /DUP/ PACK(8),POINT,BDSAVE(30,8)                           03099000
      COMMON /BUFFER/ TEXT(30)                                          03100000
      COMMON /STAT CM/ NODES(10), NGEN, MAXPLY, PRIGHT                  03101000
      COMMON /TIME CM/ TIM LIM, MAX TIM                                 03102000
      COMMON /MOV TIM/ MELAP, MSEC1, MSEC2                              03103000
      COMMON /THAH CM/ THNK AH, LOOK AH, FOUND M, MTCHED, BRKFLG        03104000
      LOGICAL THNK AH, LOOK AH, FOUND M, MTCHED, BRKFLG                 03105000
      INTEGER*4 TAB(10),FMT(9)                                          03106000
      DATA TAB/%"  10"J,%"  20"J,%"  30"J,%"  40"J,%"  50"J,%"  60"J,   03107000
     1%"  70"J,%"  80"J,%"  90"J,%" 100"J/,                             03108000
     2FMT/%"  (T"J,%""J,%",15A"J,%"1,2X"J,%",I5,"J,                     03109000
     3%" 2X,"J,%"""*"","J,%" I6,"J,%"""*"")"J/                          03110000
      NTERM=0                                                           03111000
      NGEN=0                                                            03112000
      TERM=0                                                            03113000
      MAXPLY=0                                                          03114000
      CMOVE=0                                                           03115000
      SMOVE=0                                                           03116000
      PLY=0                                                             03117000
      SIDE=.TRUE.                                                       03118000
      DO 4444 I=1,20                                                    03119000
          DO 4445 J=1,10                                                03120000
              TRACE(I,J)=0                                              03121000
4445      CONTINUE                                                      03122000
4444  CONTINUE                                                          03123000
      DO 3002 I=1,10                                                    03124000
          NODES(I)=0                                                    03125000
3002  CONTINUE                                                          03126000
C                                                                       03127000
C------------------------------< ADJUST SEARCH PARAMETERS BASED ON      03128000
C------------------------------< THE AMOUNT OF TIME REMAINING ON        03129000
C------------------------------< THE CHESS CLOCK.                       03130000
C                                                                       03131000
      CALL ADJUST                                                       03132000
      MAX TIM=TIM LIM + MSEC1                                           03133000
      IF(LOOK AH) MAX TIM = 900 + MSEC1                                 03134000
C                                                                       03135000
C------------------------------< RECURSE TO MAXIMUM DEPTH               03136000
C                                                                       03137000
1     PLY=PLY+1                                                         03138000
      SIDE=.NOT. SIDE                                                   03139000
      SIGN=-1                                                           03140000
      IF(SIDE) SIGN=1                                                   03141000
      BACKUP(PLY)=SIGN*(10000-PLY)                                      03142000
      CALL MOVGEN                                                       03143000
      WHICH(PLY)=START(PLY)-1                                           03144000
      IF(STOP(PLY).LT.START(PLY)) GO TO 15                              03145000
2     IF(PLY.GT.1) GO TO 2000                                           03146000
      IF(STOP(1).GT.1) GO TO 2002                                       03147000
      CMOVE=TREE(1)                                                     03148000
      GO TO 18                                                          03149000
2002  IF(LOOK AH .AND. .NOT.MTCHED) GO TO 2000                          03150000
      CALL CTIME(TEST)                                                  03151000
      IF(TEST.LT.MAX TIM) GO TO 2000                                    03152000
      WRITE(6,2001)                                                     03153000
2001  FORMAT(1X,'MAXIMUM MOVE TIME REACHED')                            03154000
      GO TO 9                                                           03155000
2000  WHICH(PLY)=WHICH(PLY)+1                                           03156000
      IF(WHICH(PLY).GT.STOP(PLY)) GO TO 9                               03157000
      FROM8=TREE(WHICH(PLY))                                            03158000
      CALL EXTRCT                                                       03159000
      TO(PLY)=TO8                                                       03160000
      FROM(PLY)=FROM8                                                   03161000
      TYPE(PLY)=TYPE8                                                   03162000
      VALUE(PLY)=VALUE8                                                 03163000
      IF(PLY.GT.TFLAG) GO TO 203                                        03164000
      CALL OUTMOV(FROM8,TO8,TYPE8,0,PLY,BOARD)                          03165000
      FMT(2)=TAB(PLY)                                                   03166000
      IF(PLY.LT.DEPTH) WRITE(6,FMT)(TEXT(IX),IX=1,15),VALUE8,BACKUP(PLY)03167000
203   CONTINUE                                                          03168000
      CALL MOVER                                                        03169000
      NODES(PLY)=NODES(PLY)+1                                           03170000
      IF(PLY.NE.1) GO TO 3                                              03171000
C                                                                       03172000
C------------------------------< CHECK FOR REPITITION OF MOVES          03173000
C                                                                       03174000
      CALL COMPRS                                                       03175000
      D=0                                                               03176000
      DO 202 I=1,30                                                     03177000
          DO 201 J=1,8                                                  03178000
              IF(BDSAVE(I,J).NE.PACK(J)) GO TO 202                      03179000
201       CONTINUE                                                      03180000
          D=D+1                                                         03181000
202   CONTINUE                                                          03182000
      IF(D.NE.2) GO TO 3                                                03183000
      SMOVE=TREE(WHICH(1))*(-1)                                         03184000
      CALL UMOVER                                                       03185000
      GO TO 2                                                           03186000
3     IF(PLY.LT.DEPTH) GO TO 1                                          03187000
C                                                                       03188000
C------------------------------< TERMINAL NODE, SCORE VARIATION         03189000
C                                                                       03190000
      CALL TSCORE                                                       03191000
      IF(PLY.LE.TFLAG) WRITE(6,FMT)(TEXT(IX),IX=1,15),VALUE8,SCORE      03192000
      CALL UMOVER                                                       03193000
      IF(SIDE) GO TO 5                                                  03194000
4     IF(SCORE.LE.BACKUP(PLY))  GO TO 2                                 03195000
      IF(SCORE.GE.BACKUP(PLY-1))  GO TO 8                               03196000
      GO TO 6                                                           03197000
5     IF(SCORE.GE.BACKUP(PLY))  GO TO 2                                 03198000
      IF(SCORE.LE.BACKUP(PLY-1))  GO TO 8                               03199000
6     BACKUP(PLY)=SCORE                                                 03200000
      DO 7 M=1,DEPTH                                                    03201000
          TRACE(M+10,PLY)=WHICH(M)-START(M)                             03202000
          TRACE(M,PLY)=TREE(WHICH(M))                                   03203000
7     CONTINUE                                                          03204000
      GO TO 2                                                           03205000
C                                                                       03206000
C------------------------------< ALPHA/BETA CUTOFF FOUND                03207000
C                                                                       03208000
8     PLY=PLY-1                                                         03209000
      SIDE=.NOT. SIDE                                                   03210000
      TO8=TO(PLY)                                                       03211000
      FROM8=FROM(PLY)                                                   03212000
      TYPE8=TYPE(PLY)                                                   03213000
      CALL UMOVER                                                       03214000
      GO TO 2                                                           03215000
C                                                                       03216000
C------------------------------< PLY COMPLETED, BACK UP SCORE           03217000
C                                                                       03218000
9     PLY=PLY-1                                                         03219000
      SIDE=.NOT. SIDE                                                   03220000
      IF(PLY)18,18,10                                                   03221000
10    BACKUP(PLY)=BACKUP(PLY+1)                                         03222000
      DO 11 M=1,DEPTH                                                   03223000
          TRACE(M+10,PLY)=TRACE(M+10,PLY+1)                             03224000
          TRACE(M,PLY)=TRACE(M,PLY+1)                                   03225000
11    CONTINUE                                                          03226000
      TO8=TO(PLY)                                                       03227000
      FROM8=FROM(PLY)                                                   03228000
      TYPE8=TYPE(PLY)                                                   03229000
      CALL UMOVER                                                       03230000
      IF(PLY.NE.1) GO TO 12                                             03231000
      CMOVE=TREE(WHICH(1))                                              03232000
      GO TO 2                                                           03233000
12    IF(SIDE) GO TO 14                                                 03234000
13    IF(BACKUP(PLY).GE.BACKUP(PLY-1)) GO TO 8                          03235000
      GO TO 2                                                           03236000
14    IF(BACKUP(PLY).LE.BACKUP(PLY-1)) GO TO 8                          03237000
      GO TO 2                                                           03238000
C                                                                       03239000
C------------------------------< NO MOVES GENERATED, IT MUST BE         03240000
C------------------------------< CHECKMATE OR STALEMATE                 03241000
C                                                                       03242000
15    DO 16  M=1,PLY                                                    03243000
          TRACE(M,PLY)=TREE(WHICH(M))                                   03244000
          TRACE(M+10,PLY)=WHICH(M)-START(M)                             03245000
16    CONTINUE                                                          03246000
      IF(PLY.EQ.1) GO TO 9                                              03247000
      IF(PLY.NE.2) GO TO 171                                            03248000
      IF(CHECK(.TRUE.)) GO TO 17                                        03249000
      SMOVE=TREE(WHICH(1))                                              03250000
      GO TO 8                                                           03251000
17    CMOVE=TREE(WHICH(1))                                              03252000
      STOP(1)=WHICH(1)                                                  03253000
      GO TO 9                                                           03254000
C                                                                       03255000
C------------------------------< DETERMINE THE DESIRABILITY FOR THE     03256000
C------------------------------< SIDE WITH A DRAWING MOVE TO MAKE IT.   03257000
C                                                                       03258000
171   IF(.NOT. SIDE) GO TO 173                                          03259000
      IF(CHECK(.TRUE.)) GO TO 174                                       03260000
C                                                                       03261000
C------------------------------< CHECK TO SEE IF THE HUMAN WOULD        03262000
C------------------------------< ACCEPT A DRAW.                         03263000
C                                                                       03264000
      IF(.NOT. DRAW(TEMP)) GO TO 178                                    03265000
      GO TO 179                                                         03266000
173   IF(CHECK(.FALSE.)) GO TO 174                                      03267000
C                                                                       03268000
C------------------------------< CHECK TO SEE IF THE PROGRAM SHOULD     03269000
C------------------------------< ACCEPT A DRAW.                         03270000
C                                                                       03271000
172   IF(DRAW(TEMP)) GO TO 179                                          03272000
178   BACKUP(PLY)=-4000                                                 03273000
      GO TO 9                                                           03274000
179   BACKUP(PLY)=4000                                                  03275000
      GO TO 9                                                           03276000
C                                                                       03277000
C------------------------------< CHECKMATE FOUND, ADD 1 TO THE NUMBER   03278000
C------------------------------< OF MOVES TO BE EVALUATED (IF ANY       03279000
C------------------------------< MORE EXIST) SO THAT THE MACHINE        03280000
C------------------------------< WILL NOT STUMBLE INTO CHECKMATE        03281000
C------------------------------< DUE TO FORWARD PRUNING THE MOVES       03282000
C------------------------------< THAT WOULD ALLOW IT TO ESCAPE.         03283000
C                                                                       03284000
174   IF(STOP(PLY-2).LT.START(PLY-1)-1) STOP(PLY-2)=STOP(PLY-2)+1       03285000
      GO TO 9                                                           03286000
18    RETURN                                                            03287000
      END                                                               03288000
      SUBROUTINE MATCH(*)                                               03289000
C                                                                       03290000
C       ************************************************************    03291000
C       *                                                          *    03292000
C       *      MATCH IS USED TO DETERMINE IF THE HUMAN'S RESPONSE  *    03293000
C       *  MATCHED THE PREDICTED MOVE (IN THE PRINCIPLE VARIATION  *    03294000
C       *  CALCULATED FOR THE LAST MACHINE MOVE).  IF SO, THE      *    03295000
C       *  COUNT OF PREDICTED MOVES IS INCREMENTED.  IF IN         *    03296000
C       *  'THINK AHEAD' MODE, MATCH WILL RETURN CAUSING THE       *    03297000
C       *  RESPONSE CALCULATED ON THE OPPONENT'S TIME TO BE        *    03298000
C       *  USED RATHER THAN CALLING <LOOK>.                        *    03299000
C       *                                                          *    03300000
C       ************************************************************    03301000
C                                                                       03302000
      IMPLICIT INTEGER*4 (A-Z)                                          03303000
      COMMON /THNK CM/ PTYPE8, PTO8, PFROM8                             03304000
      COMMON /INFO/ TYPE8, VALUE8, TO8, FROM8                           03305000
      COMMON /STAT CM/ NODES(10), NGEN, MAXPLY, PRIGHT                  03306000
      COMMON /THAH CM/ THNK AH, LOOK AH, FOUND M, MTCHED, BRKFLG        03307000
      LOGICAL THNK AH, LOOK AH, FOUND M, MTCHED, BRKFLG                 03308000
      COMMON /P V MOVE/ PVMOVE, OVMOVE                                  03309000
      COMMON /TYPES/ NORMAL,CASTRT,CASTLF,ENPASS,PROMOTE                03310000
C                                                                       03311000
C------------------------------< DID THE HUMAN'S MOVE MATCH THE         03312000
C------------------------------< PREDICTED MOVE?                        03313000
C                                                                       03314000
      IF(MTCHED) GO TO 10                                               03315000
      IF(PTYPE8.NE.TYPE8) GO TO 20                                      03316000
      IF(TYPE8.EQ.CASTLF.OR.TYPE8.EQ.CASTRT) GO TO 10                   03317000
      IF(PTO8.NE.TO8.OR.PFROM8.NE.FROM8) GO TO 20                       03318000
C                                                                       03319000
C------------------------------< PREDICTED MOVE WAS MADE.  INCREMENT    03320000
C------------------------------< COUNT AND RETURN IF NOT IN THINK-      03321000
C------------------------------< AHEAD MODE OR IF MOVE CALCULATION      03322000
C------------------------------< WAS NOT COMPLETED.  RETURN 1 IF A      03323000
C------------------------------< RESPONSE IS READY.                     03324000
C                                                                       03325000
10    PRIGHT=PRIGHT+1                                                   03326000
      IF(.NOT. FOUNDM) RETURN                                           03327000
      FOUNDM=.FALSE.                                                    03328000
      RETURN 1                                                          03329000
C                                                                       03330000
C------------------------------< PREDICTED MOVE WAS NOT MADE. CLEAR     03331000
C------------------------------< THE THIRD PLY RESPONSE MOVE SO THAT    03332000
C------------------------------< IT WILL NOT BE FORCED TO THE TOP       03333000
C------------------------------< OF THE MOVES LIST SINCE IT IS          03334000
C------------------------------< IS BASED ON AN INVALID ASSUMPTION.     03335000
C                                                                       03336000
20    FOUNDM=.FALSE.                                                    03337000
      PVMOVE=0                                                          03338000
      RETURN                                                            03339000
      END                                                               03340000
      INTEGER FUNCTION MINATK(SQUARE,SIDE,NUMATK)                       03341000
C                                                                       03342000
C       ************************************************************    03343000
C       *                                                          *    03344000
C       *      MINATK IS USED TO DETERMINE THE VALUE OF THE LEAST  *    03345000
C       *  IMPORTANT PIECE ATTACKING A SQUARE.  THIS IS USED IN    *    03346000
C       *  SUBROUTINE 'ENPRIS' TO DETERMINE IF A PIECE IS SUBJECT  *    03347000
C       *  TO CAPTURE.  IT PERFORMS TWO (2) FUNCTIONS: A) IT       *    03348000
C       *  RETURNS THE VALUE OF THE LEAST PIECE ATTACKING THE      *    03349000
C       *  SQUARE IN QUESTION, AND B) IT RETURNS THE NUMBER OF     *   03350000
C       *  PIECES ATTACKING THE SQUARE.                            *    03351000
C       *                                                          *    03352000
C       ************************************************************    03353000
C                                                                       03354000
      IMPLICIT INTEGER*4 (A-Z)                                          03355000
      LOGICAL SIDE                                                      03356000
      COMMON/BOARD/BOARD(120)                                           03357000
      COMMON/MOVES/RK(4),BP(4),KT(8),KG(8)                              03358000
      MINATK=0                                                          03359000
      NUMATK=0                                                          03360000
      MAX=0                                                             03361000
      IF(SIDE) GO TO 1                                                  03362000
      BIAS=0                                                            03363000
      DIR=1                                                             03364000
      GO TO 2                                                           03365000
1     BIAS=7                                                            03366000
      DIR=-1                                                            03367000
2     PAWN=1+BIAS                                                       03368000
      KNIGHT=2+BIAS                                                     03369000
      BISHOP=3+BIAS                                                     03370000
      ROOK=4+BIAS                                                       03371000
      QUEEN=5+BIAS                                                      03372000
      KING=6+BIAS                                                       03373000
      TEMP=BOARD(SQUARE)                                                03374000
C                                                                       03375000
C------------------------------< KING ATTACKS                           03376000
C                                                                       03377000
      DO 100 I=1,8                                                      03378000
          IF(BOARD(SQUARE+KG(I)).NE.KING) GO TO 100                     03379000
          MAX=KING                                                      03380000
          NUMATK=NUMATK+1                                               03381000
100   CONTINUE                                                          03382000
C                                                                       03383000
C------------------------------< ROOK/QUEEN ATTACKS                     03384000
C                                                                       03385000
      DO 4 I=1,4                                                        03386000
          LOC=SQUARE                                                    03387000
          DIREC=RK(I)                                                   03388000
3         LOC=LOC+DIREC                                                 03389000
          TEMP=BOARD(LOC)                                               03390000
          IF(TEMP.EQ.7) GO TO 3                                         03391000
          IF(TEMP.NE.ROOK) GO TO 31                                     03392000
          MINATK=ROOK                                                   03393000
          NUMATK=NUMATK+1                                               03394000
          GO TO 4                                                       03395000
31        IF(TEMP.NE.QUEEN) GO TO 4                                     03396000
          MAX=QUEEN                                                     03397000
          NUMATK=NUMATK+1                                               03398000
4     CONTINUE                                                          03399000
C                                                                       03400000
C------------------------------< BISHOP/QUEEN ATTACKS                   03401000
C                                                                       03402000
      DO 6 I=1,4                                                        03403000
          LOC=SQUARE                                                    03404000
          DIREC=BP(I)                                                   03405000
5         LOC=LOC+DIREC                                                 03406000
          TEMP=BOARD(LOC)                                               03407000
          IF(TEMP.EQ.7) GO TO 5                                         03408000
          IF(TEMP.NE.BISHOP) GO TO 51                                   03409000
          MINATK=BISHOP                                                 03410000
          NUMATK=NUMATK+1                                               03411000
          GO TO 6                                                       03412000
51        IF(TEMP.NE.QUEEN) GO TO 6                                     03413000
          MAX=QUEEN                                                     03414000
          NUMATK=NUMATK+1                                               03415000
6     CONTINUE                                                          03416000
C                                                                       03417000
C------------------------------< KNIGHT ATTACKS                         03418000
C                                                                       03419000
      DO 7 I=1,8                                                        03420000
          IF(BOARD(SQUARE+KT(I)).NE.KNIGHT) GO TO 7                     03421000
          MINATK=KNIGHT                                                 03422000
          NUMATK=NUMATK+1                                               03423000
7     CONTINUE                                                          03424000
C                                                                       03425000
C------------------------------< PAWN ATTACKS                           03426000
C                                                                       03427000
      IF(BOARD(SQUARE+DIR*9).NE.PAWN) GO TO 8                           03428000
      MINATK=PAWN                                                       03429000
      NUMATK=NUMATK+1                                                   03430000
8     IF(BOARD(SQUARE+DIR*11).NE.PAWN) GO TO 9                          03431000
      MINATK=PAWN                                                       03432000
      NUMATK=NUMATK+1                                                   03433000
9     IF(MINATK.EQ.0) MINATK=MAX                                        03434000
      IF(MINATK.GT.6) MINATK=MINATK-7                                   03435000
      RETURN                                                            03436000
      END                                                               03437000
      SUBROUTINE MOVGEN                                                 03438000
C                                                                       03439000
C       ************************************************************    03440000
C       *                                                          *    03441000
C       *      MOVGEN IS THE DRIVER FOR ALL OF THE DIFFERENT MOVE  *    03442000
C       *  GENERATORS.  THE ENTIRE BOARD IS SCANNED AND AS A PIECE *    03443000
C       *  FOR THE SIDE TO MOVE IS DETECTED, THE APPROPRIATE MOVE  *    03444000
C       *  GENERATOR IS CALLED.  AFTER ALL LEGAL MOVES ARE IN THE  *    03445000
C       *  LIST, SUBROUTINE ORDER IS CALLED TO ORDER THE MOVES     *    03446000
C       *  FOR THE SEARCH.                                         *    03447000
C       *                                                          *    03448000
C       ************************************************************    03449000
C                                                                       03450000
      IMPLICIT INTEGER*4 (A-Z)                                          03451000
      COMMON /BOARD/ BOARD(120)                                         03452000
      COMMON /INFO/ TYPE8, VALUE8, TO8, FROM8                           03453000
      COMMON /ORDR CM/ VAL(100)                                         03454000
      COMMON /MOVE CM/ FROMSQ, TOSQ, SIDE                               03455000
      LOGICAL SIDE                                                      03456000
      COMMON /TREE/ TREE(400),START(10),STOP(10),WHICH(10),BACKUP(10),  03457000
     *FROM(10),TO(10),VALUE(10),TYPE(10),PLY                            03458000
      COMMON /PHASE/ OPEN, MIDDLE, END                                  03459000
      LOGICAL OPEN, MIDDLE, END,TF(2)                                   03460000
      DATA TF/.FALSE.,.TRUE./                                           03461000
      STOP(PLY)=START(PLY)-1                                            03462000
      SIDE=TF(2-MOD(PLY,2))                                             03463000
C                                                                       03464000
C------------------------------< SCAN THE ENTIRE BOARD TO FIND ALL      03465000
C------------------------------< PIECES OF THE SIDE TO MOVE.  GEN-      03466000
C------------------------------< ERATE AND SCORE ALL MOVES FOR THEM.    03467000
C                                                                       03468000
      DO 9999 FROM8=22,99                                               03469000
          FROMSQ=BOARD(FROM8)                                           03470000
          IF(.NOT.SIDE.AND.FROMSQ.LT.8) GO TO 9998                      03471000
          IF(SIDE.AND.FROMSQ.GT.6) GO TO 9998                           03472000
          BOARD(FROM8)=7                                                03473000
          GO TO (1000,2000,3000,4000,5000,6000,9998,                    03474000
     *           1000,2000,3000,4000,5000,6000,9998),FROMSQ             03475000
1000      CALL PAWN                                                     03476000
          GO TO 9998                                                    03477000
2000      CALL KNIGHT                                                   03478000
          GO TO 9998                                                    03479000
3000      CALL BISHOP                                                   03480000
          GO TO 9998                                                    03481000
4000      CALL ROOK                                                     03482000
          GO TO 9998                                                    03483000
5000      CALL BISHOP                                                   03484000
          CALL ROOK                                                     03485000
          GO TO 9998                                                    03486000
6000      CALL KING                                                     03487000
9998      BOARD(FROM8)=FROMSQ                                           03488000
9999  CONTINUE                                                          03489000
      IF(END) GO TO 9997                                                03490000
C                                                                       03491000
C------------------------------< IF NOT IN THE ENDGAME, GENERATE        03492000
C------------------------------< CASTLING MOVES.                        03493000
C                                                                       03494000
      CALL CASTLE                                                       03495000
C                                                                       03496000
C------------------------------< NOW ORDER THE MOVE LIST                03497000
C                                                                       03498000
9997  CALL ORDER                                                        03499000
      RETURN                                                            03500000
      END                                                               03501000
$CONTROL SEGMENT=LK                                                     03502000
      SUBROUTINE MVMKER                                                 03503000
C                                                                       03504000
C       ************************************************************    03505000
C       *                                                          *    03506000
C       *      MVMKER IS USED TO MAKE/UNMAKE ALL MOVES ON THE GAME *    03507000
C       *  BOARD.  IT SAVES THE VALUE OF THE 'TO' SQUARE BEFORE    *    03508000
C       *  MAKING A MOVE SO THAT THE MOVE CAN BE UNMADE LATER.     *    03509000
C       *  ENTRY 'MOVER' IS USED TO MAKE A MOVE AND ENTRY 'UMOVER' *    03510000
C       *  IS USED TO UNMAKE A MOVE.  BOTH ROUTINES USE DATA IN    *    03511000
C       *  COMMON BLOCK 'INFO' TO MAKE/UNMAKE MOVES.  NO VALIDITY  *    03512000
C       *  CHECK IS MADE SO THE PARAMETERS MUST BE CORRECT BEFORE  *    03513000
C       *  THE CALL IS MADE.                                       *    03514000
C       *                                                          *    03515000
C       ************************************************************    03516000
C                                                                       03517000
C                                                                       03518000
C    TYPE8:  1 => NORMAL MOVE                                           03519000
C            2 => CASTLE TO RIGHT SIDE OF BOARD                         03520000
C            3 => CASTLE TO LEFT SIDE OF BOARD                          03521000
C            4 => EN PASSANT PAWN CAPTURE                               03522000
C            5 => PAWN PROMOTION MOVES                                  03523000
C                                                                       03524000
      IMPLICIT INTEGER*4 (A-Z)                                          03525000
      COMMON /BOARD/ BOARD(120)                                         03526000
      COMMON /K LOC CM/ CKINGL, HKINGL                                  03527000
      COMMON /COLR CM/ CCOLOR, HCOLOR, COLOR                            03528000
      COMMON /TREE/ DUMMY(480),PLY                                      03529000
      COMMON /INFO/ TYPE8, VALUE8, TO8, FROM8                           03530000
      COMMON /CAPT CM/ SAVE(40)                                         03531000
      CHARACTER*5 CCOLOR, HCOLOR                                        03532000
C                                                                       03533000
C                                                                       03534000
C                                                                       03535000
      ENTRY MOVER                                                       03536000
      PLAYER=MOD(PLY,2)                                                 03537000
      GO TO(1,2,9,16,17),TYPE8                                          03538000
C                                                                       03539000
C------------------------------< NORMAL MOVES                           03540000
C                                                                       03541000
1     SAVE(PLY)=BOARD(TO8)                                              03542000
      BOARD(TO8)=BOARD(FROM8)                                           03543000
      BOARD(FROM8)=7                                                    03544000
      IF(BOARD(TO8).EQ.13) CKINGL=TO8                                   03545000
      IF(BOARD(TO8).EQ.6) HKINGL=TO8                                    03546000
      RETURN                                                            03547000
C                                                                       03548000
C------------------------------< CASTLE TO RIGHT                        03549000
C                                                                       03550000
2     SAVE(PLY)=7                                                       03551000
      IF(PLAYER)3,6,3                                                   03552000
3     IF(COLOR)4,5,4                                                    03553000
4     BOARD(22)=7                                                       03554000
      BOARD(23)=13                                                      03555000
      BOARD(24)=11                                                      03556000
      BOARD(25)=7                                                       03557000
      CKINGL=23                                                         03558000
      RETURN                                                            03559000
5     BOARD(22)=7                                                       03560000
      BOARD(24)=13                                                      03561000
      BOARD(25)=11                                                      03562000
      BOARD(26)=7                                                       03563000
      CKINGL=24                                                         03564000
      RETURN                                                            03565000
6     IF(COLOR)7,8,7                                                    03566000
7     BOARD(95)=7                                                       03567000
      BOARD(96)=4                                                       03568000
      BOARD(97)=6                                                       03569000
      BOARD(99)=7                                                       03570000
      HKINGL=97                                                         03571000
      RETURN                                                            03572000
8     BOARD(96)=7                                                       03573000
      BOARD(97)=4                                                       03574000
      BOARD(98)=6                                                       03575000
      BOARD(99)=7                                                       03576000
      HKINGL=98                                                         03577000
      RETURN                                                            03578000
C                                                                       03579000
C------------------------------< CASTLE TO LEFT                         03580000
C                                                                       03581000
9     SAVE(PLY)=7                                                       03582000
      IF(PLAYER)10,13,10                                                03583000
10    IF(COLOR)11,12,11                                                 03584000
11    BOARD(25)=7                                                       03585000
      BOARD(26)=11                                                      03586000
      BOARD(27)=13                                                      03587000
      BOARD(29)=7                                                       03588000
      CKINGL=27                                                         03589000
      RETURN                                                            03590000
12    BOARD(26)=7                                                       03591000
      BOARD(27)=11                                                      03592000
      BOARD(28)=13                                                      03593000
      BOARD(29)=7                                                       03594000
      CKINGL=28                                                         03595000
      RETURN                                                            03596000
13    IF(COLOR)14,15,14                                                 03597000
14    BOARD(92)=7                                                       03598000
      BOARD(93)=6                                                       03599000
      BOARD(94)=4                                                       03600000
      BOARD(95)=7                                                       03601000
      HKINGL=93                                                         03602000
      RETURN                                                            03603000
15    BOARD(92)=7                                                       03604000
      BOARD(94)=6                                                       03605000
      BOARD(95)=4                                                       03606000
      BOARD(96)=7                                                       03607000
      HKINGL=94                                                         03608000
      RETURN                                                            03609000
C                                                                       03610000
C------------------------------< EN PASSANT PAWN CAPTURE                03611000
C                                                                       03612000
16    BOARD(TO8)=BOARD(FROM8)                                           03613000
      BOARD(FROM8)=7                                                    03614000
      SAVE(PLY)=BOARD(TO8+10-20*PLAYER)                                 03615000
      BOARD(TO8+10-20*PLAYER)=7                                         03616000
      RETURN                                                            03617000
C                                                                       03618000
C------------------------------< PAWN PROMOTION                         03619000
C                                                                       03620000
17    BOARD(FROM8)=5+7*PLAYER                                           03621000
      GO TO 1                                                           03622000
C                                                                       03623000
C                                                                       03624000
C                                                                       03625000
      ENTRY UMOVER                                                      03626000
      PLAYER=PLY-PLY/2*2                                                03627000
      GO TO(18,19,26,33,34),TYPE8                                       03628000
C                                                                       03629000
C------------------------------< RETRACT NORMAL MOVE                    03630000
C                                                                       03631000
18    BOARD(FROM8)=BOARD(TO8)                                           03632000
      BOARD(TO8)=SAVE(PLY)                                              03633000
      IF(BOARD(FROM8).EQ.13) CKINGL=FROM8                               03634000
      IF(BOARD(FROM8).EQ.6) HKINGL=FROM8                                03635000
      RETURN                                                            03636000
C                                                                       03637000
C------------------------------< RETRACT CASTLE RIGHT                   03638000
C                                                                       03639000
19    IF(PLAYER)20,23,20                                                03640000
20    IF(COLOR)21,22,21                                                 03641000
21    BOARD(22)=11                                                      03642000
      BOARD(23)=7                                                       03643000
      BOARD(24)=7                                                       03644000
      BOARD(25)=13                                                      03645000
      CKINGL=25                                                         03646000
      RETURN                                                            03647000
22    BOARD(22)=11                                                      03648000
      BOARD(24)=7                                                       03649000
      BOARD(25)=7                                                       03650000
      BOARD(26)=13                                                      03651000
      CKINGL=26                                                         03652000
      RETURN                                                            03653000
23    IF(COLOR)24,25,24                                                 03654000
24    BOARD(95)=6                                                       03655000
      BOARD(96)=7                                                       03656000
      BOARD(97)=7                                                       03657000
      BOARD(99)=4                                                       03658000
      HKINGL=95                                                         03659000
      RETURN                                                            03660000
25    BOARD(96)=6                                                       03661000
      BOARD(97)=7                                                       03662000
      BOARD(98)=7                                                       03663000
      BOARD(99)=4                                                       03664000
      HKINGL=96                                                         03665000
      RETURN                                                            03666000
C                                                                       03667000
C------------------------------< RETRACT CASTLE LEFT                    03668000
C                                                                       03669000
26    IF(PLAYER)27,30,27                                                03670000
27    IF(COLOR)28,29,28                                                 03671000
28    BOARD(25)=13                                                      03672000
      BOARD(26)=7                                                       03673000
      BOARD(27)=7                                                       03674000
      BOARD(29)=11                                                      03675000
      CKINGL=25                                                         03676000
      RETURN                                                            03677000
29    BOARD(26)=13                                                      03678000
      BOARD(27)=7                                                       03679000
      BOARD(28)=7                                                       03680000
      BOARD(29)=11                                                      03681000
      CKINGL=26                                                         03682000
      RETURN                                                            03683000
30    IF(COLOR)31,32,31                                                 03684000
31    BOARD(92)=4                                                       03685000
      BOARD(93)=7                                                       03686000
      BOARD(94)=7                                                       03687000
      BOARD(95)=6                                                       03688000
      HKINGL=95                                                         03689000
      RETURN                                                            03690000
32    BOARD(92)=4                                                       03691000
      BOARD(94)=7                                                       03692000
      BOARD(95)=7                                                       03693000
      BOARD(96)=6                                                       03694000
      HKINGL=96                                                         03695000
      RETURN                                                            03696000
C                                                                       03697000
C------------------------------< RETRACT EN PASSANT PAWN CAPTURE        03698000
C                                                                       03699000
33    BOARD(FROM8)=BOARD(TO8)                                           03700000
      BOARD(TO8)=7                                                      03701000
      BOARD(TO8+10-20*PLAYER)=SAVE(PLY)                                 03702000
      RETURN                                                            03703000
C                                                                       03704000
C------------------------------< RETRACT PAWN PROMOTION                 03705000
C                                                                       03706000
34    BOARD(TO8)=1+7*PLAYER                                             03707000
      GO TO 18                                                          03708000
      END                                                               03709000
      INTEGER FUNCTION NSCORE(SQUARE,SIDE)                              03710000
C                                                                       03711000
C       ************************************************************    03712000
C       *                                                          *    03713000
C       *      NSCORE IS USED TO COMPUTE THE PLAUSIBILITY SCORE    *    03714000
C       *  FOR KNIGHT MOVES.  THE SCORE IS OBTAINED DIRECTLY FROM  *    03715000
C       *  THE KNIGHT CONTROL BOARD FOR THE SIDE TO MOVE. (CNSCOR, *    03716000
C       *  HNSCOR IN COMMON BLOCK 'N BD SM').                      *    03717000
C       *      THE SCORE IS ADJUSTED AS INDICATED FOR EACH OF THE  *    03718000
C       *  FOLLOWING FACTORS PRESENT:                              *    03719000
C       *      1)  BONUS FOR MOVING TO THE 5TH THRU 8TH RANK WHEN  *    03720000
C       *          OPPONENT'S KING IS STILL ON THE BACK RANK. THIS *    03721000
C       *          PUTS THE KNIGHT (OUTPOST KNIGHT) IN A POSITION  *    03722000
C       *          LEADING TO FORKS AND OTHER THREATS.  THIS DOES  *    03723000
C       *          NOT APPLY IF THE KNIGHT CAN BE DRIVEN AWAY BY   *    03724000
C       *          A SIMPLE PAWN PUSH.                             *    03725000
C       *                                                          *    03726000
C       ************************************************************    03727000
C                                                                       03728000
      IMPLICIT INTEGER*4 (A-Z)                                          03729000
      COMMON /BOARD/ BOARD(120)                                         03730000
      COMMON /K LOC CM/ CKINGL, HKINGL                                  03731000
      COMMON /N BD SM/ CNSCOR(100), HNSCOR(100)                         03732000
      COMMON /N SM/ ENMOVE, OUTPST, N EDGE                              03733000
      LOGICAL PPUSH,  SIDE                                              03734000
      COMMON /PHASE/ OPEN, MIDDLE, END                                  03735000
      LOGICAL OPEN, MIDDLE, END                                         03736000
      OUTPSC=OUTPST                                                     03737000
      IF(SIDE) GO TO 200                                                03738000
C                                                                       03739000
C==============================< COMPUTER SCORING                       03740000
C                                                                       03741000
100   NSCORE=CNSCOR(SQUARE)                                             03742000
      IF(END) GO TO 9999                                                03743000
      IF(SQUARE.LT.60) GO TO 9999                                       03744000
      IF(HKINGL.LT.70) GO TO 9999                                       03745000
C                                                                       03746000
C----------------------< AN OUTPOST KNIGHT SHOULD BE SUPPORTED          03747000
C----------------------< BY A FRIENDLY PAWN.  IF NOT, A LESSER          03748000
C----------------------< BONUS WILL BE GIVEN.                           03749000
C                                                                       03750000
      IF(BOARD(SQUARE-9).NE.8.AND.BOARD(SQUARE-11).NE.8) GO TO 400      03751000
      GO TO 300                                                         03752000
C                                                                       03753000
C==============================< HUMAN SCORING                          03754000
C                                                                       03755000
200   NSCORE=HNSCOR(SQUARE)                                             03756000
      IF(END) GO TO 9999                                                03757000
      IF(SQUARE.GT.60) GO TO 9999                                       03758000
      IF(CKINGL.GT.50) GO TO 9999                                       03759000
C                                                                       03760000
C----------------------< AN OUTPOST KNIGHT SHOULD BE SUPPORTED          03761000
C----------------------< BY A FRIENDLY PAWN.  IF NOT, A LESSER          03762000
C----------------------< BONUS WILL BE GIVEN.                           03763000
C                                                                       03764000
      IF(BOARD(SQUARE+9).NE.1.AND.BOARD(SQUARE+11).NE.1) GO TO 400      03765000
      GO TO 300                                                         03766000
C                                                                       03767000
C------------------------------< THE KNIGHT HAS BEEN POSTED ON          03768000
C------------------------------< AN AGGRESSIVE SQUARE THAT CAN LEAD     03769000
C------------------------------< TO FORKING MOVES (5TH THRU 8TH RANKS). 03770000
C------------------------------< IF THE KNIGHT CAN'T BE DRIVEN AWAY     03771000
C------------------------------< BY AN ENEMY PAWN, ADD A BONUS TO       03772000
C------------------------------< THE SCORE.                             03773000
C                                                                       03774000
400   OUTPSC=OUTPST/2                                                   03775000
300   IF(END) GO TO 9999                                                03776000
      IF(PPUSH(SQUARE,SIDE))  GO TO 9999                                03777000
      NSCORE=NSCORE+OUTPSC                                              03778000
9999  RETURN                                                            03779000
      END                                                               03780000
$CONTROL SEGMENT=CMND                                                   03781000
      SUBROUTINE OCMND(DEVICE,*)                                        03782000
C                                                                       03783000
C       ************************************************************    03784000
C       *                                                          *    03785000
C       *      OCMND PROCESSES THE 'O' COMMAND.  THIS DISPLAYS     *    03786000
C       *  VARIOUS PIECE CONTROL BOARDS WHEN CHANGING OR DEBUGGING *    03787000
C       *  THE PRE-ANALYSIS SUBROUTINE.                            *    03788000
C       *      THE COMMAND HAS THE FOLLOWING SYNTAX:               *    03789000
C       *               OSB                                        *    03790000
C       *  WHERE S IDENTIFIES THE SIDE ('C' FOR THE COMPUTER AND   *    03791000
C       *  'H' FOR THE HUMAN) AND B IDENTIFIES THE BOARD DESIRED   *    03792000
C       *  USING THE USUAL PIECE CODES (P FOR PAWN, N FOR KNIGHT,  *    03793000
C       *  ETC.  'OP' WILL DISPLAY THE PIECE VALUES.               *    03794000
C       *                                                          *    03795000
C       ************************************************************    03796000
C                                                                       03797000
      IMPLICIT INTEGER*4 (A-Z)                                          03798000
      COMMON /Q BD SM/ CQSCOR(100), HQSCOR(100)                         03799000
      COMMON /K BD SM/ CKSCOR(100), HKSCOR(100)                         03800000
      COMMON /R BD SM/ CRSCOR(100), HRSCOR(100)                         03801000
      COMMON /B BD SM/ CBSCOR(100), HBSCOR(100)                         03802000
      COMMON /N BD SM/ CNSCOR(100), HNSCOR(100)                         03803000
      COMMON /P BD SM/ CPSCOR(100), HPSCOR(100)                         03804000
      COMMON /PIEC CM/ PVALUE(13), PINIT(13)                            03805000
      COMMON /CHRSET/ ALPHA(44)                                         03806000
      EQUIVALENCE (B,ALPHA(2)),(C,ALPHA(3)),(H,ALPHA(8)),               03807000
     *(K,ALPHA(11)),(N,ALPHA(14)),(P,ALPHA(16)),(Q,ALPHA(17)),          03808000
     *(R,ALPHA(18)),(V,ALPHA(22))                                       03809000
      COMMON / BUFFER / TEXT(30)                                        03810000
      COMMON /DRAW CM/ STAT BD(100)                                     03811000
      LOGICAL DRAW,TEMP                                                 03812000
      CALL PREANL                                                       03813000
      IF(TEXT(3).EQ.P.AND.TEXT(4).NE.P) DEVICE=6                        03814000
      IF(TEXT(2).EQ.C) GO TO 200                                        03815000
      IF(TEXT(2).EQ.P) GO TO 300                                        03816000
      IF(TEXT(2).EQ.V) GO TO 400                                        03817000
      IF(TEXT(2).NE.H) RETURN 1                                         03818000
C                                                                       03819000
C------------------------------< 'OH?' COMMANDS                         03820000
C                                                                       03821000
      IF(TEXT(3).EQ.P) CALL OUTPUT(DEVICE,HPSCOR)                       03822000
      IF(TEXT(3).EQ.N) CALL OUTPUT(DEVICE,HNSCOR)                       03823000
      IF(TEXT(3).EQ.B) CALL OUTPUT(DEVICE,HBSCOR)                       03824000
      IF(TEXT(3).EQ.R) CALL OUTPUT(DEVICE,HRSCOR)                       03825000
      IF(TEXT(3).EQ.Q) CALL OUTPUT(DEVICE,HQSCOR)                       03826000
      IF(TEXT(3).EQ.K) CALL OUTPUT(DEVICE,HKSCOR)                       03827000
      RETURN                                                            03828000
C                                                                       03829000
C------------------------------< 'OC?' COMMANDS                         03830000
C                                                                       03831000
200   IF(TEXT(3).EQ.P) CALL OUTPUT(DEVICE,CPSCOR)                       03832000
      IF(TEXT(3).EQ.N) CALL OUTPUT(DEVICE,CNSCOR)                       03833000
      IF(TEXT(3).EQ.B) CALL OUTPUT(DEVICE,CBSCOR)                       03834000
      IF(TEXT(3).EQ.R) CALL OUTPUT(DEVICE,CRSCOR)                       03835000
      IF(TEXT(3).EQ.Q) CALL OUTPUT(DEVICE,CQSCOR)                       03836000
      IF(TEXT(3).EQ.K) CALL OUTPUT(DEVICE,CKSCOR)                       03837000
      RETURN                                                            03838000
C                                                                       03839000
C------------------------------< 'OP' COMMAND                           03840000
C                                                                       03841000
300   CALL SETPCV                                                       03842000
      WRITE(6,310)(PVALUE(I+7),PVALUE(I),I=1,5)                         03843000
310   FORMAT(10X,'BLITZ',2X,'OPPONENT'/                                 03844000
     *1X,'PAWN',T12,I4,4X,I4/                                           03845000
     *1X,'KNIGHT',T12,I4,4X,I4/                                         03846000
     *1X,'BISHOP',T12,I4,4X,I4/                                         03847000
     *1X,'ROOK',T12,I4,4X,I4/                                           03848000
     *1X,'QUEEN',T12,I4,4X,I4)                                          03849000
      RETURN                                                            03850000
C                                                                       03851000
C------------------------------< 'OV' COMMAND                           03852000
C                                                                       03853000
400   TEMP=DRAW(TEMP1)                                                  03854000
      CALL OUTPUT(DEVICE,STAT BD)                                       03855000
      RETURN                                                            03856000
      END                                                               03857000
$CONTROL SEGMENT=ADJ                                                    03858000
      SUBROUTINE OPTION(*)                                              03859000
C                                                                       03860000
C       ************************************************************    03861000
C       *                                                          *    03862000
C       *      OPTION IS THE DRIVER FOR ALL OF THE SEPARATE COM-   *    03863000
C       *  COMMAND MODULES.  IT DECODES THE FIRST CHARACTER OF THE *    03864000
C       *  INPUT AND CALLS THE CORRECT MODULE.  THE ONLY DIRECT    *    03865000
C       *  INPUT TO OPTION IS '?' WHICH REQUESTS A LISTING OF ALL  *    03866000
C       *  LEGAL COMMANDS.                                         *    03867000
C       *      SEVERAL COMMANDS CAN HAVE A 'P' APPENDED TO THEM    *    03868000
C       *  TO DIRECT THEIR OUTPUT TO THE LINE PRINTER RATHER THAN  *    03869000
C       *  THE USER TERMINAL.  THE FORTRAN UNIT NUMBER IS PASSED   *    03870000
C       *  AS AN ARGUMENT RATHER THAN BEING USED DIRECTLY.  UNIT   *    03871000
C       *  '6' GOES TO THE LINE PRINTER AND UNIT '108' GOES TO THE *    03872000
C       *  USER TERMINAL.                                          *    03873000
C       *                                                          *    03874000
C       ************************************************************    03875000
C                                                                       03876000
      IMPLICIT INTEGER*4 (A-Z)                                          03877000
      COMMON/BUFFER/TEXT(30)                                            03878000
      LOGICAL IN BOOK, DRAW                                             03879000
      COMMON /BOOK CM/ KEY, IN BOOK                                     03880000
      COMMON /DATA/ CMOVE, SMOVE, HFROM8, HTO8, HTYPE8, MOVE            03881000
      COMMON /TRACE/ TRACE(20,10), TFLAG                                03882000
      COMMON /MOV CNT/ NCMOVS, NHMOVS                                   03883000
      COMMON /COLR CM/ CCOLOR, HCOLOR, COLOR                            03884000
      CHARACTER*5 CCOLOR, HCOLOR                                        03885000
      COMMON /DEBUG/ DEBUG                                              03886000
      LOGICAL DEBUG                                                     03887000
      COMMON /HIST CM/ NMOVES, ANNOTE                                   03888000
      COMMON /THAH CM/ THNK AH, LOOK AH, FOUND M, MTCHED, BRKFLG        03889000
      LOGICAL THNK AH, LOOK AH, FOUND M, MTCHED, BRKFLG                 03890000
      COMMON /PC CM/ COMMANDS(10,3), NCMNDS, PCMODE, EXMODE             03891000
      LOGICAL PCMODE, EXMODE                                            03892000
      COMMON /CHRSET/ ALPHA(44)                                         03893000
      EQUIVALENCE (A,ALPHA(1)),(B,ALPHA(2)),(C,ALPHA(3)),               03894000
     *(D,ALPHA(4)),(E,ALPHA(5)),(F,ALPHA(6)),(G,ALPHA(7)),              03895000
     *(H,ALPHA(8)),(I,ALPHA(9)),(J,ALPHA(10)),(K,ALPHA(11)),            03896000
     *(L,ALPHA(12)),(M,ALPHA(13)),(N,ALPHA(14)),(O,ALPHA(15)),          03897000
     *(P,ALPHA(16)),(Q,ALPHA(17)),(R,ALPHA(18)),(S,ALPHA(19)),          03898000
     *(T,ALPHA(20)),(U,ALPHA(21)),(V,ALPHA(22)),(W,ALPHA(23)),          03899000
     *(X,ALPHA(24)),(Y,ALPHA(25)),(Z,ALPHA(26))                         03900000
      INTEGER*4 BLANK, QUEST                                            03901000
      LOGICAL HELP                                                      03902000
      DATA TLEVEL / 0J/,BLANK/%" "J/,QUEST/%"?"J/,HELP/.FALSE./         03903000
      DO 10 I=1,30                                                      03904000
      IF(TEXT(31-I).NE.BLANK) GO TO 20                                  03905000
10    CONTINUE                                                          03906000
      RETURN 1                                                          03907000
20    DEVICE=6                                                          03908000
      IF(TEXT(31-I).EQ.P) DEVICE=10                                     03909000
      IF(TEXT(1).EQ.A) GO TO 2400                                       03910000
      IF(TEXT(1).EQ.B.AND.TEXT(2).EQ.O) GO TO 1400                      03911000
      IF(TEXT(1).EQ.C) GO TO 900                                        03912000
      IF(TEXT(1).EQ.D.AND.TEXT(2).EQ.B) GO TO 3300                      03913000
      IF(TEXT(1).EQ.D.AND.TEXT(2).EQ.R.AND.                             03914000
     *   TEXT(3).EQ.A.AND.TEXT(4).EQ.W) GO TO 4300                      03915000
      IF(TEXT(1).EQ.D) GO TO 500                                        03916000
      IF(TEXT(1).EQ.E.AND.TEXT(2).EQ.N) GO TO 1000                      03917000
      IF(TEXT(1).EQ.F) GO TO 300                                        03918000
      IF(TEXT(1).EQ.H) GO TO 1200                                       03919000
      IF(TEXT(1).EQ.L.AND.TEXT(2).EQ.M)  GO TO 1700                     03920000
      IF(TEXT(1).EQ.O) GO TO 1300                                       03921000
      IF(TEXT(1).EQ.P.AND.TEXT(2).EQ.BLANK) GO TO 1500                  03922000
      IF(TEXT(1).EQ.P.AND.TEXT(2).EQ.C) GO TO 1600                      03923000
      IF(TEXT(1).EQ.R.AND.TEXT(2).EQ.E                                  03924000
     *.AND.TEXT(3).EQ.S)                    GO TO 4755                  03925000
      IF(TEXT(1).EQ.R.AND.(TEXT(2).EQ.BLANK                             03926000
     *               .OR.TEXT(2).EQ.K)) GO TO 1800                      03927000
      IF(TEXT(1).EQ.S.AND.TEXT(2).EQ.B) GO TO 400                       03928000
      IF(TEXT(1).EQ.S.AND.TEXT(2).EQ.O) GO TO 7800                      03929000
      IF(TEXT(1).EQ.S.AND.TEXT(2).EQ.R) GO TO 1900                      03930000
      IF(TEXT(1).EQ.S.AND.(TEXT(2).EQ.BLANK                             03931000
     *               .OR.TEXT(2).EQ.P)) GO TO 600                       03932000
      IF(TEXT(1).EQ.S) GO TO 100                                        03933000
      IF(TEXT(1).EQ.T.AND.TEXT(2).EQ.R) GO TO 1100                      03934000
      IF(TEXT(1).EQ.T.AND.TEXT(2).EQ.G) GO TO 5000                      03935000
      IF(TEXT(1).EQ.T) GO TO 800                                        03936000
      IF(TEXT(1).EQ.V) GO TO 200                                        03937000
      IF(TEXT(1).EQ.QUEST) GO TO 700                                    03938000
9999  RETURN                                                            03939000
C                                                                       03940000
C------------------------------< ? : DISPLAY COMMANDS AND EXPLANATION   03941000
C                                                                       03942000
700   WRITE(6,710)                                                      03943000
710   FORMAT(//                                                         03944000
     *1X,'A   : ANNOTE A MOVE IN THE GAME HISTORY'/                     03945000
     *1X,'BO  : TURN OPENING BOOK OFF'/                                 03946000
     *1X,'C?  : CONTROL CLOCK'/                                         03947000
     *1X,'D   : DISPLAY BOARD'/                                         03948000
     *1X,'DRAW: OFFER THE PROGRAM A DRAW'/                              03949000
     *1X,'END : TERMINATE EXECUTION'/                                   03950000
     *1X,'F   : FORCE COMPUTER TO MAKE A MOVE'/                         03951000
     *1X,'H   : LIST GAME HISTORY'/                                     03952000
     *1X,'LM  : LIST MOVES FOR EITHER SIDE'/                            03953000
     *1X,'O?  : OUTPUT CONTROL BOARDS'/                                 03954000
     *1X,'P   : OUTPUT PREDICTED MOVE'/                                 03955000
     *1X,'PC  : ENTER PROGRAMMED COMMANDS'/                             03956000
     *1X,'R   : RESET BOARD TO PRIOR MOVE'/                             03957000
     *1X,'S   : OUTPUT MOVE STATISTICS'/                                03958000
     *1X,'S?  : SET SEARCH LIMIT CONTROLS'/                             03959000
     *1X,'SB  : SET NEW BOARD POSITION'/)                               03960000
      WRITE(6,715)                                                      03961000
715   FORMAT(1X,'SO  : SET OPENING BLITZ SHOULD PLAY'/                  03962000
     *1X,'SR  : SET OPPONENT''S RATING'/                                03963000
     *1X,'T   : CONTROL THINK-AHEAD'/                                   03964000
     *1X,'TG  : SET PROGRAM TO TOURNAMENT PLAY LEVEL'/                  03965000
     *1X,'TR  : DUMP MOVE TREE DURING ANALYSIS'/                        03966000
     *1X,'V   : DISPLAY PRINCIPLE VARIATION OF COMPUTER''S MOVE'/       03967000
     *)                                                                 03968000
      IF(.NOT. HELP) WRITE(6,720)                                       03969000
720   FORMAT(                                                           03970000
     *1X,'P MAY BE APPENDED TO THE DISPLAY TYPE COMMANDS'/              03971000
     *1X,'TO DIRECT THE OUTPUT FROM THAT COMMAND TO THE'/               03972000
     *1X,'LINE PRINTER OR WHEREVER FORTRAN I/O UNIT 6'/                 03973000
     *1X,'IS CURRENTLY ASSIGNED'//                                      03974000
     *1X,'A ''?'' MAY BE APPENDED TO SOME SPECIFIC COMMANDS'/           03975000
     *1X,'TO GIVE A DETAILED DESCRIPTION OF THE SUB-'/                  03976000
     *1X,'COMMANDS (C? EXPLAINS CLOCK SUBCOMMANDS).'/)                  03977000
      HELP=.TRUE.                                                       03978000
      RETURN 1                                                          03979000
C                                                                       03980000
C------------------------------< A : ANNOTE GAME HISTORY                03981000
C                                                                       03982000
2400  CALL ACMND                                                        03983000
      RETURN 1                                                          03984000
C                                                                       03985000
C------------------------------< BO : TURN OPENING BOOK OFF             03986000
C                                                                       03987000
1400  IN BOOK = .FALSE.                                                 03988000
      RETURN 1                                                          03989000
C                                                                       03990000
C------------------------------< C : CONTROL CLOCK                      03991000
C                                                                       03992000
900   CALL CCMND(DEVICE)                                                03993000
      RETURN 1                                                          03994000
C                                                                       03995000
C------------------------------< D : DISPLAY GAME BOARD                 03996000
C                                                                       03997000
500   CALL DISPLY(DEVICE)                                               03998000
      RETURN 1                                                          03999000
C                                                                       04000000
C------------------------------< DB : TURN ON DEBUG TRACE MODE          04001000
C                                                                       04002000
3300  DEBUG=.NOT.DEBUG                                                  04003000
      IF(DEBUG) WRITE(6,3301)                                           04004000
      IF(.NOT. DEBUG) WRITE(6,3401)                                     04005000
      RETURN 1                                                          04006000
3301  FORMAT(1X,'DEBUG MODE ON')                                        04007000
3401  FORMAT(1X,'DEBUG MODE OFF')                                       04008000
C                                                                       04009000
C------------------------------< DRAW : OFFER THE PROGRAM A DRAW        04010000
C                                                                       04011000
4300  IF(.NOT. DRAW(SCORE)) GO TO 4302                                  04012000
      WRITE(6,4301)                                                     04013000
4301  FORMAT(1X,'DRAW ACCEPTED')                                        04014000
      WRITE(6,4304)SCORE                                                04015000
4304  FORMAT(1X,'BOARD EVALUATION =',I6)                                04016000
      NMOVES=NMOVES+1                                                   04017000
      WRITE(1@NMOVES)TEXT                                               04018000
      GO TO 1000                                                        04019000
4302  WRITE(6,4303)                                                     04020000
4303  FORMAT(1X,'DRAW REFUSED')                                         04021000
      WRITE(6,4304)SCORE                                                04022000
      RETURN 1                                                          04023000
C                                                                       04024000
C------------------------------< F : EVALUATE FORCED MOVE               04025000
C                                                                       04026000
300   CALL FCMND                                                        04027000
      RETURN 1                                                          04028000
C                                                                       04029000
C------------------------------< H : PRINT GAME HISTORY                 04030000
C                                                                       04031000
1200  CALL HCMND(DEVICE)                                                04032000
      RETURN 1                                                          04033000
C                                                                       04034000
C------------------------------< LM : LIST PLAUSIBLE MOVE TREE          04035000
C                                                                       04036000
1700  CALL LMCMND(DEVICE)                                               04037000
      RETURN 1                                                          04038000
C                                                                       04039000
C------------------------------< OX : OUTPUT CONTROL BOARDS             04040000
C------------------------------<      ( X = 'C' OR 'H' )                04041000
C                                                                       04042000
1300  CALL OCMND(DEVICE,$9999)                                          04043000
      RETURN 1                                                          04044000
C                                                                       04045000
C------------------------------< P : OUTPUT PREDICTED MOVE              04046000
C                                                                       04047000
1500  CALL PCMND                                                        04048000
      RETURN 1                                                          04049000
C                                                                       04050000
C------------------------------< PC : ENTER PROGRAMMED COMMANDS         04051000
C                                                                       04052000
1600  CALL PCCMND                                                       04053000
      RETURN 1                                                          04054000
C                                                                       04055000
C------------------------------< R : RESET BOARD TO PRIOR MOVE          04056000
C                                                                       04057000
1800  DMY=0                                                             04058000
      CALL RCMND(DMY)                                                   04059000
      RETURN 1                                                          04060000
C                                                                       04061000
C------------------------------< RESIGN : RESIGN GAME                   04062000
C                                                                       04063000
4755  WRITE(6,4756)HCOLOR                                               04064000
4756  FORMAT(1X,A5,' RESIGNS')                                          04065000
      NMOVES=NMOVES+1                                                   04066000
      WRITE(1@NMOVES)TEXT                                               04067000
      GO TO 1000                                                        04068000
C                                                                       04069000
C------------------------------< S : PRINT MOVE STATISTICS              04070000
C                                                                       04071000
600   CALL STATS(DEVICE)                                                04072000
      RETURN 1                                                          04073000
C                                                                       04074000
C------------------------------< S? : SET SEARCH LIMIT CONTROLS         04075000
C                                                                       04076000
100   CALL SCMND($9999)                                                 04077000
      RETURN 1                                                          04078000
C                                                                       04079000
C------------------------------< SB : SET THE BOARD TO SOME             04080000
C------------------------------< PRE-DETERMINED POSITION                04081000
C                                                                       04082000
400   CALL SETBRD                                                       04083000
410   WRITE(6,420)                                                      04084000
420   FORMAT(1X,'ENTER MOVE NUMBER')                                    04085000
      CALL INPUT(MOVE)                                                  04086000
      NCMOVS=MOVE                                                       04087000
      NHMOVS=MOVE                                                       04088000
      IF(COLOR.EQ.1) NHMOVS=NHMOVS-1                                    04089000
      IN BOOK = .FALSE.                                                 04090000
      RETURN 1                                                          04091000
C                                                                       04092000
C------------------------------< SO : SET OPENING TO USE                04093000
C                                                                       04094000
7800  CALL SETOPN                                                       04095000
      RETURN 1                                                          04096000
C                                                                       04097000
C------------------------------< SR : SET OPPONENT'S RATING             04098000
C                                                                       04099000
1900    CALL SRCMND                                                     04100000
        RETURN 1                                                        04101000
C                                                                       04102000
C------------------------------< T : CONTROL THINK-AHEAD                04103000
C                                                                       04104000
800   THNK AH=.NOT. THNK AH                                             04105000
      FOUND M=.FALSE.                                                   04106000
      LOOK AH=.FALSE.                                                   04107000
      MTCHED=.FALSE.                                                    04108000
      IF(THNK AH) WRITE(6,801)                                          04109000
      IF(.NOT. THNK AH) WRITE(6,802)                                    04110000
      RETURN 1                                                          04111000
801   FORMAT(1X,'I WILL THINK ALL OF THE TIME')                         04112000
802   FORMAT(1X,'I WILL NOT THINK ALL OF THE TIME')                     04113000
C     RETURN 1                                                          04114000
C                                                                       04115000
C------------------------------< TG : TOURNAMENT GAME SETTING           04116000
C                                                                       04117000
5000  CALL SETTG                                                        04118000
      RETURN 1                                                          04119000
C                                                                       04120000
C------------------------------< TR : TRACE MOVE LOOK AHEAD             04121000
C                                                                       04122000
1100  IF(EXMODE) GO TO 1110                                             04123000
1102  WRITE(6,1101)                                                     04124000
1101  FORMAT(1X,'TRACE SEARCH TO WHAT LEVEL?')                          04125000
      CALL INPUT(TFLAG)                                                 04126000
      TLEVEL=TFLAG                                                      04127000
      RETURN 1                                                          04128000
1110  IF(TLEVEL.NE.0) GO TO 1120                                        04129000
      WRITE(6,1101)                                                     04130000
      CALL INPUT(TLEVEL)                                                04131000
1120  TFLAG=TLEVEL                                                      04132000
      RETURN 1                                                          04133000
C                                                                       04134000
C------------------------------< V : OUTPUT PRINCIPLE VARIATION         04135000
C                                                                       04136000
200   CALL VCMND(DEVICE)                                                04137000
      RETURN 1                                                          04138000
C                                                                       04139000
C------------------------------< END : TERMINATE PLAY                   04140000
C                                                                       04141000
1000  STOP 'GOOD BYE'                                                   04142000
      END                                                               04143000
      SUBROUTINE ORDER                                                  04144000
C                                                                       04145000
C       ************************************************************    04146000
C       *                                                          *    04147000
C       *      THIS SUBROUTINE RE-ORDERS THE MOVE LIST GENERATED   *    04148000
C       *  BY THE MOVE GENERATORS.  THIS PLACES MOVES WITH HIGH    *    04149000
C       *  PLAUSIBILITY SCORES AT THE TOP OF THE LIST, HOPEFULLY   *    04150000
C       *  MAXIMIZING THE NUMBER OF ALPHA/BETA CUTOFFS THAT OCCUR  *    04151000
C       *  DURING THE COURSE OF THE SEARCH.  IF THE CURRENT PLY IS *    04152000
C       *  ONE, EXCHNG IS USED WITH EACH MOVE IN THE LIST TO       *    04153000
C       *  DETERMINE IF THE MOVE LEAVES ANY PIECES SUBJECT TO      *    04154000
C       *  CAPTURE.  IF SO, THE SCORE IS ADJUSTED TO REFLECT THE   *    04155000
C       *  LOSS OF THE PIECE.                                      *    04156000
C       *      FOR EACH MOVE GENERATED, 'EN PRIS' IS USED TO DE-   *    04157000
C       *  TERMINE IF ANY FRIENDLY PIECES ARE LEFT EXPOSED TO A    *    04158000
C       *  CAPTURE.  IF SO, THESE MOVES ARE MOVED DOWN IN THE LIST *    04159000
C       *  TO SAVE TIME.                                           *    04160000
C       *      IF THE PLY IS NOT GREATER THAN 'ORDER1', THEN ALL   *    04161000
C       *  MOVES FORWARD PRUNED ARE CHECKED TO SEE IF THE PUT THE  *    04162000
C       *  OPPONENT KING IN CHECK.  IF SO, THE MOVES ARE MOVED UP  *    04163000
C       *  BELOW THE LAST MOVE LEFT AFTER PRUNING AND THE WIDTH    *    04164000
C       *  IS INCREASED TO COVER THEM.                             *    04165000
C       *      IF THE PLY IS NOT GREATER THAN 'ORDER2', THEN ALL   *    04166000
C       *  CAPTURING MOVES ARE DONE AS THE CHECKING MOVES ABOVE    *    04167000
C       *  TO MAKE SURE THE PROGRAM WILL EXAMINE ALL EXCHANGES OPEN*    04168000
C       *  TO IT.                                                  *    04169000
C       *                                                          *    04170000
C       ************************************************************    04171000
C                                                                       04172000
      IMPLICIT INTEGER*4 (A-Z)                                          04173000
      COMMON /BOARD/ BOARD(120)                                         04174000
      COMMON /TREE/ TREE(400),START(10),STOP(10),WHICH(10),BACKUP(10),  04175000
     *FROM(10),TO(10),VALUE(10),TYPE(10),PLY                            04176000
      COMMON /PRUNE/ WIDTH(10), MIN(10), MAX(10),                       04177000
     * DEPTH, ORDER1, ORDER2                                            04178000
      COMMON /PIEC CM/ PVALUE(13), PINIT(13)                            04179000
      COMMON /INFO/ TYPE8, VALUE8, TO8, FROM8                           04180000
      COMMON /STAT CM/ NODES(10), NGEN, MAXPLY, PRIGHT                  04181000
      COMMON /TYPES/ NORMAL,CASTRT,CASTLF,ENPASS,PROMOTE                04182000
      COMMON /P SM/ PADVNC, PPAWN, IPAWN, DPAWN, TPAWN, CPAWN,          04183000
     * ABREST, PPSHSC                                                   04184000
      COMMON /MOVE CM/ FROMSQ, TOSQ, SIDE                               04185000
      LOGICAL SIDE, SAVES, CHECK, PPUSH                                 04186000
      COMMON /ORDR CM/ VAL(100)                                         04187000
      COMMON /CAPT CM/ SAVE(40)                                         04188000
      COMMON /PHASE/ OPEN, MIDDLE, END                                  04189000
      LOGICAL OPEN, MIDDLE, END                                         04190000
      COMMON /GEN SM/ ATAK SC, BPAWN, BLKSC, TEMPO                      04191000
      COMMON /P V MOVE/ PVMOVE, OVMOVE                                  04192000
      IF(WIDTH(PLY).GT.100) GO TO 9999                                  04193000
      START(PLY+1)=STOP(PLY)+1                                          04194000
      F=START(PLY)                                                      04195000
      L=STOP(PLY)                                                       04196000
      LGLMVS=L-F+1                                                      04197000
      NGEN=NGEN+LGLMVS                                                  04198000
      NTERM=NTERM+1                                                     04199000
      IF(F.GE.L) GO TO 9999                                             04200000
      IF(PLY.GT.1) GO TO 300                                            04201000
      FROM8=PVMOVE                                                      04202000
      CALL EXTRCT                                                       04203000
      PVTO=TO8                                                          04204000
      PVFROM=FROM8                                                      04205000
      PVTYPE=TYPE8                                                      04206000
300   CONTINUE                                                          04207000
C                                                                       04208000
C------------------------------< ADJUST EACH MOVE'S SCORE TO REFLECT    04209000
C------------------------------< THE CONDITION OF FRIENDLY PIECES.      04210000
C------------------------------< THIS GIVES MOVES WHICH LEAVE OTHER     04211000
C------------------------------< PIECES 'EN PRISE' A LOWER SCORE        04212000
C------------------------------< SO THAT THEY WILL BE FORWARD PRUNED    04213000
C------------------------------< OR EXAMINED LAST.                      04214000
C                                                                       04215000
      TEMP=0                                                            04216000
      DO 3000 I=F,L                                                     04217000
          TEMP=TEMP+1                                                   04218000
          FROM8=TREE(I)                                                 04219000
          CALL EXTRCT                                                   04220000
          SCORE=VALUE8                                                  04221000
          IF(PLY.EQ.DEPTH) GO TO 2500                                   04222000
C                                                                       04223000
C------------------------------< IF THE PREDICTED MOVE WAS MADE,        04224000
C------------------------------< MAKE THE PRINCIPLE VARIATION'S 3RD     04225000
C------------------------------< MOVE GO TO THE TOP OF THE LIST.        04226000
C                                                                       04227000
          IF(PVMOVE.EQ.0 .OR. PLY.GT.1) GO TO 400                       04228000
          IF(PVTYPE.NE.TYPE8) GO TO 400                                 04229000
          IF(TYPE8.EQ.CASTLF.OR.TYPE8.EQ.CASTRT) GO TO 450              04230000
          IF(PVTO.NE.TO8.OR.PVFROM.NE.FROM8) GO TO 400                  04231000
450       SCORE=SCORE+8000                                              04232000
          GO TO 2500                                                    04233000
400       CONTINUE                                                      04234000
          IF(LGLMVS.LE.WIDTH(PLY)) GO TO 2500                           04235000
          CALL MOVER                                                    04236000
C                                                                       04237000
C------------------------------< CHECK TO SEE IF THIS MOVE IS A         04238000
C------------------------------< FORKING TYPE MOVE.  IF SO, ADJUST      04239000
C------------------------------< THE SCORE TO MAKE SURE IT IS EX-       04240000
C------------------------------< AMINED BY THE SEARCH.                  04241000
C                                                                       04242000
          IF(TYPE8.EQ.CASTRT.OR.TYPE8.EQ.CASTLF) GO TO 500              04243000
          IF(PLY.EQ.1) TSCORE=EXCHNG(TO8,SIDE)                          04244000
          IF(PLY.GT.1) TSCORE=ENPRIS(TO8,SIDE)                          04245000
          SCORE=SCORE-TSCORE                                            04246000
C                                                                       04247000
C------------------------------< IF THE PIECE CAN BE CAPTURED, DO       04248000
C------------------------------< NOT CONSIDER THE MOVE A FORK. IF       04249000
C------------------------------< AT THE LAST 2 LEVELS IN THE TREE,      04250000
C------------------------------< DO NOT CONSIDER FORKS SINCE THE        04251000
C------------------------------< ULTIMATE GAIN IN MATERIAL WILL NOT     04252000
C------------------------------< BE DISCOVERED.                         04253000
C                                                                       04254000
          IF(TSCORE.GT.0 .OR. PLY.GT.DEPTH-2) GO TO 500                 04255000
          IF(PLY.GT.1) GO TO 475                                        04256000
          IF(ENPRIS(TO8,SIDE).EQ.1) GO TO 500                           04257000
475       SCORE=SCORE+FORK(TO8,SIDE)                                    04258000
500       DO 2000 SQUARE=22,99                                          04259000
              IF(SQUARE.EQ.TO8) GO TO 2000                              04260000
              SQVAL=BOARD(SQUARE)                                       04261000
              IF(SQVAL.EQ.14) GO TO 2000                                04262000
              IF(SQVAL.EQ.6.OR.SQVAL.EQ.13) GO TO 2000                  04263000
              IF(SIDE.AND.SQVAL.GT.6) GO TO 2000                        04264000
              IF(.NOT.SIDE.AND.SQVAL.LT.8) GO TO 2000                   04265000
              IF(PLY.EQ.1) TSCORE=EXCHNG(SQUARE,SIDE)                   04266000
              IF(PLY.GT.1) TSCORE=ENPRIS(SQUARE,SIDE)                   04267000
              SCORE=SCORE-TSCORE                                        04268000
2000      CONTINUE                                                      04269000
C                                                                       04270000
C------------------------------< IF THIS PIECE IS BEING MOVED TO        04271000
C------------------------------< A SQUARE WHERE IT CAN BE ATTACKED      04272000
C------------------------------< BY A PAWN, PENALIZE THE SCORE.         04273000
C                                                                       04274000
          IF(PPUSH(TO8,SIDE)) SCORE=SCORE-ATAK SC                       04275000
C                                                                       04276000
C------------------------------< CHECK TO SEE IF THIS MOVE IS A         04277000
C------------------------------< PAWN PUSH. IF SO, ADD A BONUS          04278000
C------------------------------< FOR ATTACKING A PIECE.                 04279000
C                                                                       04280000
          MVGPC=MOD(BOARD(TO8),7)                                       04281000
          IF(MVGPC.NE.1) GO TO 2300                                     04282000
          SCORE=SCORE+PATACK(TO8,SIDE)                                  04283000
2300      CALL UMOVER                                                   04284000
2500      VAL(TEMP)=SCORE                                               04285000
3000  CONTINUE                                                          04286000
C                                                                       04287000
C------------------------------< NOW ORDER THE MOVES BASED ON THE       04288000
C------------------------------< VALUES CALCULATED BY THE MOVE          04289000
C------------------------------< GENERATORS + THE ABOVE TRICKS          04290000
C                                                                       04291000
      F1=L-1                                                            04292000
      DO 901 I=F,F1                                                     04293000
          I1=I+1                                                        04294000
          DO 900 J=I1,L                                                 04295000
              T1=I-F+1                                                  04296000
              T2=J-F+1                                                  04297000
              IF(VAL(T1).GE.VAL(T2)) GO TO 900                          04298000
              TEMP=VAL(T1)                                              04299000
              VAL(T1)=VAL(T2)                                           04300000
              VAL(T2)=TEMP                                              04301000
              TEMP=TREE(I)                                              04302000
              TREE(I)=TREE(J)                                           04303000
              TREE(J)=TEMP                                              04304000
900       CONTINUE                                                      04305000
901   CONTINUE                                                          04306000
C                                                                       04307000
C------------------------------< FORWARD PRUNE TREE                     04308000
C                                                                       04309000
200   IF(PLY.EQ.DEPTH) GO TO 9999                                       04310000
      IF(LGLMVS.GT.WIDTH(PLY)) STOP(PLY)=START(PLY)+WIDTH(PLY)-1        04311000
C                                                                       04312000
C------------------------------< IF AT OR BELOW THE CHECK REORDERING    04313000
C------------------------------< LEVEL (ORDER1), MOVE CHECKS UP TO      04314000
C------------------------------< THE POINT IMMEDIATELY FOLLOWING THE    04315000
C------------------------------< THE LAST MOVE LEFT AFTER FORWARD       04316000
C------------------------------< PRUNING.                               04317000
C                                                                       04318000
C------------------------------< IF AT OR BELOW THE CAPTURE REORDERING  04319000
C------------------------------< LEVEL (ORDER2) DO THE SAME FOR ALL     04320000
C------------------------------< CAPTURING MOVES                        04321000
C                                                                       04322000
      IF(PLY.GT.ORDER1.AND.PLY.GT.ORDER2) GO TO 9999                    04323000
5000  JLAST=STOP(PLY)+1                                                 04324000
      JMOVE=JLAST                                                       04325000
      JTOP=JLAST-START(PLY)+1                                           04326000
      JBOT=JTOP                                                         04327000
1300  IF(JMOVE.GE.START(PLY+1)) GO TO 9999                              04328000
      FROM8=TREE(JMOVE)                                                 04329000
      CALL EXTRCT                                                       04330000
C                                                                       04331000
C------------------------------< TREAT CAPTURING MOVES                  04332000
C                                                                       04333000
      IF(PLY.GT.ORDER2) GO TO 1500                                      04334000
      IF(TYPE8.EQ.CASTLF.OR.TYPE8.EQ.CASTRT) GO TO 1500                 04335000
      IF(TYPE8.EQ.ENPASS) GO TO 1800                                    04336000
      IF(BOARD(TO8).NE.7) GO TO 1800                                    04337000
C                                                                       04338000
C------------------------------< TREAT CHECKING MOVES                   04339000
C                                                                       04340000
1500  IF(PLY.GT.ORDER1) GO TO 1900                                      04341000
      CALL MOVER                                                        04342000
      IF(CHECK(.NOT. SIDE)) GO TO 1400                                  04343000
      CALL UMOVER                                                       04344000
      GO TO 1900                                                        04345000
1400  CALL UMOVER                                                       04346000
1800  TEMP=TREE(JLAST)                                                  04347000
      TREE(JLAST)=TREE(JMOVE)                                           04348000
      TREE(JMOVE)=TEMP                                                  04349000
      TEMP=VAL(JTOP)                                                    04350000
      VAL(JTOP)=VAL(JBOT)                                               04351000
      VAL(JBOT)=TEMP                                                    04352000
      STOP(PLY)=STOP(PLY)+1                                             04353000
      JLAST=JLAST+1                                                     04354000
      JTOP=JTOP+1                                                       04355000
1900  JMOVE=JMOVE+1                                                     04356000
      JBOT=JBOT+1                                                       04357000
      GO TO 1300                                                        04358000
9999  RETURN                                                            04359000
      END                                                               04360000
$CONTROL SEGMENT=IOMV                                                   04361000
      SUBROUTINE OUTMOV(FROM8,TO8,TYPE8,MTYPE,PLAY8,BOARD)              04362000
C                                                                       04363000
C       ************************************************************    04364000
C       *                                                          *    04365000
C       *      OUTMOVE IS USED BY ANY ROUTINE WISHING TO OUTPUT A  *    04366000
C       *  MOVE IN STANDARD CHESS NOTATION.                             04367000
C       *  TO OUTPUT MACHINE MOVES AND EVEN TO OUTPUT HUMAN MOVES. *    04368000
C       *                                                          *    04369000
C       ************************************************************    04370000
C                                                                       04371000
      IMPLICIT INTEGER*4 (A-Z)                                          04372000
      INTEGER*4 BOARD(120),FILE(8),PIECES(6)                            04373000
      COMMON /COLR CM/ CCOLOR, HCOLOR, COLOR                            04374000
      CHARACTER*5 CCOLOR, HCOLOR                                        04375000
      COMMON /TYPES/ NORMAL,CASTRT,CASTLF,ENPASS,PROMOTE                04376000
      INTEGER*4 RANK(8)                                                 04377000
      COMMON /CHRSET/ ALPHA(44)                                         04378000
      EQUIVALENCE (RANK(1),ALPHA(28)),(ALPHAA,ALPHA(1)),                04379000
     *(ALPHAE,ALPHA(5)),(ALPHAM,ALPHA(13)),(ALPHAO,ALPHA(15)),          04380000
     *(ALPHAP,ALPHA(16)),(ALPHAT,ALPHA(20)),(ALPHAX,ALPHA(24)),         04381000
     *(PLUS,ALPHA(37)),(MINUS,ALPHA(38)),(SLASH,ALPHA(39)),             04382000
     *(EQUAL,ALPHA(41))                                                 04383000
      COMMON /BUFFER/ TEXT(30)                                          04384000
      DATA FILE/%"R"J,%"N"J,%"B"J,%" "J,%" "J,%"B"J,%"N"J,%"R"J/        04385000
      DATA PIECES/%"P"J,%"N"J,%"B"J,%"R"J,%"Q"J,%"K"J/                  04386000
C                                                                       04387000
C------------------------------< IF MOVE IS A CASTLING MOVE, GO TO      04388000
C------------------------------< A SPECIAL OUTPUT ROUTINE.              04389000
C                                                                       04390000
      IF(TYPE8.EQ.CASTLF.OR.TYPE8.EQ.CASTRT) GO TO 8888                 04391000
      IF(TO8.LT.22.OR.TO8.GT.99) RETURN                                 04392000
      IF(FROM8.LT.22.OR.FROM8.GT.99) RETURN                             04393000
C                                                                       04394000
C------------------------------< DETERMINE WHICH SIDE IS MOVING         04395000
C                                                                       04396000
8888  PLAYER=MOD(PLAY8,2)                                               04397000
C                                                                       04398000
C------------------------------< GET AND CONVERT PIECES BEING MOVED     04399000
C------------------------------< AND/OR CAPTURED.                       04400000
C                                                                       04401000
      PIECE=BOARD(FROM8)                                                04402000
      CPIECE=BOARD(TO8)                                                 04403000
      DO 1   I=1,30                                                     04404000
1     TEXT(I)=FILE(4)                                                   04405000
      IF(PIECE.GT.6) PIECE=PIECE-7                                      04406000
      IF(CPIECE.GT.7) CPIECE=CPIECE-7                                   04407000
      IF(TYPE8.EQ.ENPASS) CPIECE=1                                      04408000
C                                                                       04409000
C------------------------------< PROCESS ORIGIN FILE/SQUARE             04410000
C------------------------------< AND DESTINATION FILE/SQUARE            04411000
C                                                                       04412000
      GO TO (6,15,19,6,6),TYPE8                                         04413000
6     OFILEQ=PIECES(6)                                                  04414000
      DFILEQ=PIECES(6)                                                  04415000
      OFILE=MOD(FROM8-1,10)                                             04416000
      DFILE=MOD(TO8-1,10)                                               04417000
      IF(COLOR)7,8,7                                                    04418000
7     IF(OFILE.GT.4) OFILEQ=PIECES(5)                                   04419000
      IF(DFILE.GT.4) DFILEQ=PIECES(5)                                   04420000
      GO TO 9                                                           04421000
8     IF(OFILE.LT.5) OFILEQ=PIECES(5)                                   04422000
      IF(DFILE.LT.5) DFILEQ=PIECES(5)                                   04423000
9     ORANK=(FROM8-1)/10-1                                              04424000
      DRANK=(TO8-1)/10-1                                                04425000
      IF(TYPE8.EQ.ENPASS) DRANK=DRANK-1                                 04426000
      IF(PLAYER.NE.0) GO TO 775                                         04427000
      ORANK=9-ORANK                                                     04428000
      DRANK=9-DRANK                                                     04429000
      IF(TYPE8.EQ.ENPASS) DRANK=DRANK-2                                 04430000
C                                                                       04431000
C------------------------------< NOW BUILD TEXT STRING TO OUTPUT        04432000
C------------------------------< BASED ON INFORMATION FROM ABOVE.       04433000
C                                                                       04434000
775   TEXT(1)=PIECES(PIECE)                                             04435000
      TEXT(2)=SLASH                                                     04436000
      TEXT(3)=OFILEQ                                                    04437000
      PTR=4                                                             04438000
      TEXT(PTR)=FILE(OFILE)                                             04439000
      IF(TEXT(PTR).NE.FILE(4)) PTR=PTR+1                                04440000
      TEXT(PTR)=RANK(ORANK)                                             04441000
      PTR=PTR+1                                                         04442000
      TEXT(PTR)=MINUS                                                   04443000
      PTR=PTR+1                                                         04444000
      IF(CPIECE.EQ.7)  GO TO 10                                         04445000
      TEXT(PTR-1)=ALPHAX                                                04446000
      TEXT(PTR)=PIECES(CPIECE)                                          04447000
      TEXT(PTR+1)=SLASH                                                 04448000
      PTR=PTR+2                                                         04449000
10    TEXT(PTR)=DFILEQ                                                  04450000
      PTR=PTR+1                                                         04451000
      TEXT(PTR)=FILE(DFILE)                                             04452000
      IF(TEXT(PTR).NE.FILE(4)) PTR=PTR+1                                04453000
      TEXT(PTR)=RANK(DRANK)                                             04454000
      PTR=PTR+2                                                         04455000
      IF(PIECE.NE.1) GO TO 11                                           04456000
      IF(PLAYER.EQ.0.AND.TO8.GT.30) GO TO 11                            04457000
      IF(PLAYER.EQ.1.AND.TO8.LT.90)  GO TO 11                           04458000
      TEXT(PTR-1)=EQUAL                                                 04459000
      TEXT(PTR)=PIECES(5)                                               04460000
      PTR=PTR+2                                                         04461000
C                                                                       04462000
C------------------------------< ADD 'EP' FOR EN PASSANT CAPTURES       04463000
C                                                                       04464000
11    IF(TYPE8.NE.ENPASS) GO TO 12                                      04465000
      TEXT(PTR) = ALPHAE                                                04466000
      TEXT(PTR+1)=ALPHAP                                                04467000
      PTR=PTR+4                                                         04468000
C                                                                       04469000
C------------------------------< ADD ' +' IF THE MOVE IS A CHECK        04470000
C                                                                       04471000
12    IF(MTYPE.NE.1.AND.MTYPE.NE.3) GO TO 13                            04472000
      TEXT(PTR) = PLUS                                                  04473000
C                                                                       04474000
C------------------------------< ADD 'MATE' IF THE MOVE GIVES           04475000
C------------------------------< CHECKMATE.                             04476000
C                                                                       04477000
13    IF(MTYPE.NE.3) GO TO 14                                           04478000
      TEXT(PTR) = ALPHAM                                                04479000
      TEXT(PTR+1)=ALPHAA                                                04480000
      TEXT(PTR+2)=ALPHAT                                                04481000
      TEXT(PTR+3)=ALPHAE                                                04482000
14    RETURN                                                            04483000
C                                                                       04484000
C------------------------------< PROCESS CASTLING MOVES                 04485000
C                                                                       04486000
15    IF(PLAYER)16,17,16                                                04487000
16    IF(COLOR)22,18,22                                                 04488000
17    IF(COLOR)18,22,18                                                 04489000
18    TEXT(4)=MINUS                                                     04490000
      TEXT(5)=ALPHAO                                                    04491000
      GO TO 22                                                          04492000
19    IF(PLAYER)20,21,20                                                04493000
20    IF(COLOR)18,22,18                                                 04494000
21    IF(COLOR)22,18,22                                                 04495000
22    TEXT(1)=ALPHAO                                                    04496000
      TEXT(2)=MINUS                                                     04497000
      TEXT(3)=ALPHAO                                                    04498000
      GO TO 14                                                          04499000
      END                                                               04500000
$CONTROL SEGMENT=DSP                                                    04501000
      SUBROUTINE OUTPUT(DEVICE,BOARD)                                   04502000
C                                                                       04503000
C       ************************************************************    04504000
C       *                                                          *    04505000
C       *      THIS SUBROUTINE WILL OUTPUT THE SIGNIFICANT PART OF *    04506000
C       *  ANY BOARD TO THE TERMINAL OR LINE PRINTER.  NUMERICS    *    04507000
C       *  ONLY ARE USED, EVEN FOR THE GAME BOARD.                 *    04508000
C       *                                                          *    04509000
C       ************************************************************    04510000
C                                                                       04511000
      IMPLICIT INTEGER*4 (A-Z)                                          04512000
      INTEGER*4 BOARD(100)                                              04513000
      COMMON /BUFFER/ TEXT(30)                                          04514000
      WRITE(DEVICE,310)(TEXT(I),I=2,3)                                  04515000
      DO 110 I=22,92,10                                                 04516000
          J=I+7                                                         04517000
          WRITE(DEVICE,300)(BOARD(L),L=I,J)                             04518000
110   CONTINUE                                                          04519000
      RETURN                                                            04520000
300   FORMAT(1X,8I5)                                                    04521000
310   FORMAT(14X,'SCORING BOARD (',2R1,')')                             04522000
      END                                                               04523000
      INTEGER FUNCTION PASSED(SQUARE,SIDE)                              04524000
C                                                                       04525000
C       ************************************************************    04526000
C       *                                                          *    04527000
C       *     PASSED IS USED TO COMPUTE THE VALUE OF A PASSED PAWN *    04528000
C       *  ON 'SQUARE'.  IT CHECKS TO SEE IF A PAWN ON 'SQUARE' IS *    04529000
C       *  PASSED AND COMPUTES IT'S NET WORTH IF IT IS.  IF NOT,   *    04530000
C       *  A SCORE OF ZERO (0) IS RETURNED.                        *    04531000
C       *      IF A PAWN IS PASSED, IT IS NOT GIVEN CREDIT FOR     *   04532000
C       *  ADVANCING IF IT IS ISOLATED AND UNDEFENDED.  IF IT IS   *    04533000
C       *  NOT ISOLATED, PAWNS ARE KEPT CONNECTED BY ANOTHER       *    04534000
C       *  ROUTINE SO A FRIENDLY DEFENDER IS ALWAYS NEARBY.        *    04535000
C       *                                                          *    04536000
C       ************************************************************    04537000
C                                                                       04538000
      IMPLICIT INTEGER*4 (A-Z)                                          04539000
      COMMON /BOARD/ BOARD(120)                                         04540000
      COMMON /P SM/ PADVNC, PPAWN, IPAWN, DPAWN, TPAWN, CPAWN,          04541000
     * ABREST, PPSHSC                                                   04542000
      COMMON /P BD SM/ CPSCOR(100), HPSCOR(100)                         04543000
      LOGICAL SIDE, ISOLAT                                              04544000
      PASSED=0                                                          04545000
C                                                                       04546000
C------------------------------< DETERMINE DIRECTION OF MOVES, VALUE    04547000
C------------------------------< OF ENEMY PAWNS, AND RANK.              04548000
C                                                                       04549000
      IF(SIDE) GO TO 200                                                04550000
100   EPAWN=1                                                           04551000
      FPAWN=8                                                           04552000
      DIR=1                                                             04553000
      RANK=SQUARE/10-2                                                  04554000
      GO TO 300                                                         04555000
200   EPAWN=8                                                           04556000
      FPAWN=1                                                           04557000
      DIR=-1                                                            04558000
      RANK=9-SQUARE/10                                                  04559000
C                                                                       04560000
C------------------------------< CHECK TO SEE IF THE PAWN IS PASSED     04561000
C------------------------------< BY SCANNING THIS AND ADJACENT FILES    04562000
C------------------------------< IN FRONT OF THIS PAWN FOR THE          04563000
C------------------------------< PRESENCE OF ENEMY PAWNS.               04564000
C                                                                       04565000
300   IF(RANK.GT.5) GO TO 450                                           04566000
      SQ=SQUARE                                                         04567000
400   SQ=SQ+DIR*10                                                      04568000
      IF(BOARD(SQ-1).EQ.EPAWN) GO TO 500                                04569000
      IF(BOARD(SQ).EQ.EPAWN) GO TO 500                                  04570000
      IF(BOARD(SQ+1).EQ.EPAWN) GO TO 500                                04571000
      IF(BOARD(SQ).NE.14) GO TO 400                                     04572000
C                                                                       04573000
C------------------------------< THE PAWN SHOULD BE SUPPORTED TO        04574000
C------------------------------< GET THE FULL SCORE FOR ADVANCING       04575000
C                                                                       04576000
450   IF(.NOT.ISOLAT(SQUARE,SIDE)) GO TO 475                            04577000
      IF(MINATK(SQUARE,.NOT.SIDE,DUMMY).EQ.0) GO TO 480                 04578000
C                                                                       04579000
C------------------------------< PAWN IS PASSED, IT'S WORTH IS THE      04580000
C------------------------------< RANK TIMES THE PASSED PAWN SCORE       04581000
C------------------------------< IN AN EXPONENTIAL SORT OF WAY!         04582000
C                                                                       04583000
475   RANK=RANK*RANK                                                    04584000
480   PASSED=PPAWN*FLOAT(RANK)/3.0                                      04585000
500   RETURN                                                            04586000
      END                                                               04587000
      INTEGER FUNCTION PATACK(SQUARE,SIDE)                              04588000
C                                                                       04589000
C       ************************************************************    04590000
C       *                                                          *    04591000
C       *      PATACK IS USED TO DETERMINE IF A PAWN ON 'SQUARE'   *    04592000
C       *  IS ATTACKING A PIECE.  IF SO A BONUS IS RETURNED AS THE *    04593000
C       *  VALUE.  ADDITIONALLY, IF A PAWN IS ATTACKING A PIECE    *    04594000
C       *  WHICH MUST FLEE (KNIGHT OR ROOK), A FURTHER BONUS IS    *    04595000
C       *  ADDED.                                                  *    04596000
C       *                                                          *    04597000
C       ************************************************************    04598000
C                                                                       04599000
      IMPLICIT INTEGER*4 (A-Z)                                          04600000
      COMMON /BOARD/ BOARD(120)                                         04601000
      COMMON /GEN SM/ ATAK SC, BPAWN, BLKSC, TEMPO                      04602000
      LOGICAL SIDE                                                      04603000
      PATACK=0                                                          04604000
      IF(SIDE) GO TO 200                                                04605000
C                                                                       04606000
C------------------------------< DETERMINE WHAT THE PAWN BEING          04607000
C------------------------------< PUSHED ATTACKS.  IF IT ATTACKS         04608000
C------------------------------< NOTHING OR ANOTHER PAWN, RETURN.       04609000
C                                                                       04610000
100   IF(BOARD(SQUARE+9).EQ.1.OR.BOARD(SQUARE+11).EQ.1) GO TO 999       04611000
      DO 110 I=9,11,2                                                   04612000
          LOC=SQUARE+I                                                  04613000
          IF(BOARD(LOC).LT.7)  GO TO 300                                04614000
110   CONTINUE                                                          04615000
      GO TO 999                                                         04616000
200   IF(BOARD(SQUARE-9).EQ.8.OR.BOARD(SQUARE-11).EQ.8) GO TO 999       04617000
      DO 210 I=9,11,2                                                   04618000
          LOC=SQUARE-I                                                  04619000
          IF(BOARD(LOC).EQ.14) GO TO 999                                04620000
          IF(BOARD(LOC).GT.7)  GO TO 300                                04621000
210   CONTINUE                                                          04622000
      GO TO 999                                                         04623000
C                                                                       04624000
C------------------------------< PAWN IS ATTACKING A PIECE, ADD IN      04625000
C------------------------------< A BONUS.  IF IT IS ATTACKING A ROOK    04626000
C------------------------------< OR KNIGHT (WHICH MUST FLEE), ADD       04627000
C------------------------------< IN ANOTHER BONUS.                      04628000
C                                                                       04629000
300   PATACK=ATAK SC                                                    04630000
      PIECE=MOD(BOARD(LOC),7)                                           04631000
      IF(PIECE.NE.2.AND.PIECE.NE.4) GO TO 999                           04632000
      PATACK=PATACK+ATAK SC/2                                           04633000
999   RETURN                                                            04634000
      END                                                               04635000
$CONTROL SEGMENT=PC                                                     04636000
      SUBROUTINE PAWN                                                   04637000
C                                                                       04638000
C       ************************************************************    04639000
C       *                                                          *    04640000
C       *      PAWN GENERATES ALL PAWN MOVES.  SUBROUTINE SCORE IS *    04641000
C       *  CALLED TO COMPUTE THE PLAUSIBILITY SCORE FOR THE MOVE,  *    04642000
C       *  AFTER WHICH THE MOVE IS ENTERED IN THE MOVE LIST.  THE  *    04643000
C       *  'EN PASSANT' AS WELL AS PROMOTION MOVES ARE CONSIDERED  *    04644000
C       *  HERE, ALTHOUGH PROMOTION IS STRICTLY TO A QUEEN.        *    04645000
C       *                                                          *    04646000
C       ************************************************************    04647000
C                                                                       04648000
      IMPLICIT INTEGER*4 (A-Z)                                          04649000
      COMMON /BOARD/ BOARD(120)                                         04650000
      COMMON /MOVE CM/ FROMSQ, TOSQ, SIDE                               04651000
      LOGICAL SIDE, CHECK                                               04652000
      COMMON /DATA/ CMOVE, SMOVE, HFROM8, HTO8, HTYPE8, MOVE            04653000
      COMMON /INFO/ TYPE8, VALUE8, TO8, FROM8                           04654000
      COMMON /TYPES/ NORMAL,CASTRT,CASTLF,ENPASS,PROMOTE                04655000
      COMMON /TREE/ TREE(400),START(10),STOP(10),WHICH(10),BACKUP(10),  04656000
     *FROM(10),TO(10),VALUE(10),TYPE(10),PLY                            04657000
      IF(SIDE) GO TO 2000                                               04658000
C                                                                       04659000
C==============================< COMPUTER PAWN MOVES                    04660000
C                                                                       04661000
C                                                                       04662000
C----------------------< CAPTURES                                       04663000
C                                                                       04664000
1000  TO8=FROM8+9                                                       04665000
      DO 1040 I=1,2                                                     04666000
          TOSQ=BOARD(TO8)                                               04667000
          IF(TOSQ.GT.6) GO TO 1035                                      04668000
          BOARD(TO8)=8                                                  04669000
          IF(CHECK(.FALSE.)) GO TO 1030                                 04670000
          TYPE8=NORMAL                                                  04671000
          IF(TO8.LT.90) GO TO 1010                                      04672000
          TYPE8=PROMOTE                                                 04673000
          BOARD(TO8)=12                                                 04674000
1010      CALL SCORE                                                    04675000
          CALL ENTER                                                    04676000
1030      BOARD(TO8)=TOSQ                                               04677000
1035      TO8=TO8+2                                                     04678000
1040  CONTINUE                                                          04679000
C                                                                       04680000
C----------------------< EN PASSANT CAPTURES                            04681000
C                                                                       04682000
      TOSQ=1                                                            04683000
      IF(PLY.GT.1) GO TO 1050                                           04684000
      TLAST=HTO8                                                        04685000
      FLAST=HFROM8                                                      04686000
      GO TO 1060                                                        04687000
1050  TLAST=TO(PLY-1)                                                   04688000
      FLAST=FROM(PLY-1)                                                 04689000
1060  IF(FLAST.LT.80) GO TO 1090                                        04690000
      IF(BOARD(TLAST).NE.1) GO TO 1090                                  04691000
      TO8=FROM8+9                                                       04692000
      DO 1080 I=1,2                                                     04693000
          IF(BOARD(TO8).NE.7) GO TO 1075                                04694000
          IF(FLAST.NE.TO8+10) GO TO 1075                                04695000
          IF(TLAST.NE.TO8-10) GO TO 1075                                04696000
          BOARD(TLAST)=7                                                04697000
          BOARD(TO8)=8                                                  04698000
          IF(CHECK(.FALSE.)) GO TO 1070                                 04699000
          TYPE8=ENPASS                                                  04700000
          CALL SCORE                                                    04701000
          CALL ENTER                                                    04702000
1070      BOARD(TLAST)=1                                                04703000
          BOARD(TO8)=7                                                  04704000
1075      TO8=TO8+2                                                     04705000
1080  CONTINUE                                                          04706000
C                                                                       04707000
C----------------------< REGULAR MOVES                                  04708000
C                                                                       04709000
1090  TOSQ=7                                                            04710000
      TO8=FROM8+10                                                      04711000
      DO 1130 I=1,2                                                     04712000
          IF(BOARD(TO8).NE.7) GO TO 9999                                04713000
          BOARD(TO8)=8                                                  04714000
          IF(CHECK(.FALSE.)) GO TO 1120                                 04715000
          TYPE8=NORMAL                                                  04716000
          IF(TO8.LT.90) GO TO 1100                                      04717000
          TYPE8=PROMOTE                                                 04718000
          BOARD(TO8)=12                                                 04719000
1100      CALL SCORE                                                    04720000
          CALL ENTER                                                    04721000
1120      BOARD(TO8)=7                                                  04722000
          IF(FROM8.GT.40) GO TO 9999                                    04723000
          TO8=TO8+10                                                    04724000
1130  CONTINUE                                                          04725000
      GO TO 9999                                                        04726000
C                                                                       04727000
C==============================< HUMAN PAWN MOVES                       04728000
C                                                                       04729000
C                                                                       04730000
C----------------------< CAPTURES                                       04731000
C                                                                       04732000
2000  TO8=FROM8-9                                                       04733000
      DO 2040 I=1,2                                                     04734000
          TOSQ=BOARD(TO8)                                               04735000
          IF(TOSQ.LT.8.OR.TOSQ.GT.13) GO TO 2035                        04736000
          BOARD(TO8)=1                                                  04737000
          IF(CHECK(.TRUE.)) GO TO 2030                                  04738000
          TYPE8=NORMAL                                                  04739000
          IF(TO8.GT.30) GO TO 2010                                      04740000
          TYPE8=PROMOTE                                                 04741000
          BOARD(TO8)=5                                                  04742000
2010      CALL SCORE                                                    04743000
          CALL ENTER                                                    04744000
2030      BOARD(TO8)=TOSQ                                               04745000
2035      TO8=TO8-2                                                     04746000
2040  CONTINUE                                                          04747000
C                                                                       04748000
C----------------------< EN PASSANT CAPTURES                            04749000
C                                                                       04750000
      TOSQ=8                                                            04751000
      TLAST=TO(PLY-1)                                                   04752000
      FLAST=FROM(PLY-1)                                                 04753000
2060  IF(FLAST.GT.40) GO TO 2090                                        04754000
      IF(BOARD(TLAST).NE.8) GO TO 2090                                  04755000
      TO8=FROM8-9                                                       04756000
      DO 2080 I=1,2                                                     04757000
          IF(BOARD(TO8).NE.7) GO TO 2075                                04758000
          IF(FLAST.NE.TO8-10) GO TO 2075                                04759000
          IF(TLAST.NE.TO8+10) GO TO 2075                                04760000
          BOARD(TLAST)=7                                                04761000
          BOARD(TO8)=1                                                  04762000
          IF(CHECK(.TRUE.)) GO TO 2070                                  04763000
          TYPE8=ENPASS                                                  04764000
          CALL SCORE                                                    04765000
          CALL ENTER                                                    04766000
2070      BOARD(TLAST)=8                                                04767000
          BOARD(TO8)=7                                                  04768000
2075      TO8=TO8-2                                                     04769000
2080  CONTINUE                                                          04770000
C                                                                       04771000
C----------------------< REGULAR MOVES                                  04772000
C                                                                       04773000
2090  TOSQ=7                                                            04774000
      TO8=FROM8-10                                                      04775000
      DO 2130 I=1,2                                                     04776000
          IF(BOARD(TO8).NE.7) GO TO 9999                                04777000
          BOARD(TO8)=1                                                  04778000
          IF(CHECK(.TRUE.)) GO TO 2120                                  04779000
          TYPE8=NORMAL                                                  04780000
          IF(TO8.GE.30) GO TO 2100                                      04781000
          TYPE8=PROMOTE                                                 04782000
          BOARD(TO8)=5                                                  04783000
2100      CALL SCORE                                                    04784000
          CALL ENTER                                                    04785000
2120      BOARD(TO8)=7                                                  04786000
          IF(FROM8.LT.80) GO TO 9999                                    04787000
          TO8=TO8-10                                                    04788000
2130  CONTINUE                                                          04789000
9999  RETURN                                                            04790000
      END                                                               04791000
$CONTROL SEGMENT=CMND                                                   04792000
      SUBROUTINE PCMND                                                  04793000
C                                                                       04794000
C       ************************************************************    04795000
C       *                                                          *    04796000
C       *      PCMND IS USED TO PROCESS THE 'P' COMMAND.  IT       *    04797000
C       *  OUTPUTS THE PREDICTED HUMAN RESPONSE TO THE COMPUTER'S  *    04798000
C       *  LAST MOVE.                                              *    04799000
C       *                                                          *    04800000
C       ************************************************************    04801000
C                                                                       04802000
      IMPLICIT INTEGER*4 (A-Z)                                          04803000
      COMMON /TRCE CM/ STRACE(20), TSCORE                               04804000
      COMMON /BUFFER/ TEXT(30)                                          04805000
      COMMON /INFO/ TYPE8, VALUE8, TO8, FROM8                           04806000
      COMMON /BOARD/ BOARD(120)                                         04807000
      COMMON /BOOK CM/ KEY, IN BOOK                                     04808000
      LOGICAL IN BOOK                                                   04809000
      COMMON /COLR CM/ CCOLOR, HCOLOR, COLOR                            04810000
      CHARACTER*5 CCOLOR, HCOLOR                                        04811000
C                                                                       04812000
C------------------------------< IF NO PREDICTED MOVE, RETURN           04813000
C                                                                       04814000
      IF(IN BOOK) GO TO 40                                              04815000
      IF(STRACE(2).EQ.0) GO TO 20                                       04816000
C                                                                       04817000
C------------------------------< GET PREDICTED MOVE, CONVERT IT         04818000
C------------------------------< AND OUTPUT IT.                         04819000
C                                                                       04820000
      FROM8=STRACE(2)                                                   04821000
      CALL EXTRCT                                                       04822000
5     CALL OUTMOV(FROM8,TO8,TYPE8,0,0,BOARD)                            04823000
      WRITE(6,10)TEXT                                                   04824000
10    FORMAT(1X,'PREDICTED MOVE IS ',30R1)                              04825000
      RETURN                                                            04826000
20    WRITE(6,30)                                                       04827000
30    FORMAT(1X,'NO PREDICTED MOVE')                                    04828000
      RETURN                                                            04829000
C                                                                       04830000
C------------------------------< READ PREDICTED MOVE FROM BOOK          04831000
C------------------------------< MOVE DATABASE.                         04832000
C                                                                       04833000
40    TKEY=KEY                                                          04834000
      READ(3@KEY) FROM8                                                 04835000
      KEY=TKEY                                                          04836000
      CALL EXTRCT                                                       04837000
      IF(COLOR.EQ.1) GO TO 5                                            04838000
      TO8=121-TO8                                                       04839000
      FROM8=121-FROM8                                                   04840000
      GO TO 5                                                           04841000
      END                                                               04842000
$CONTROL SEGMENT=CMND                                                   04843000
      SUBROUTINE PCCMND                                                 04844000
C                                                                       04845000
C       ************************************************************    04846000
C       *                                                          *    04847000
C       *      PCCMND IS USED TO PROCESS THE 'PC' COMMAND WHICH    *    04848000
C       *  CONTROLS THE PROGRAMMED COMMAND MODE.  PROGRAMMED COM-  *    04849000
C       *  MANDS ARE SIMPLY COMMANDS THAT ARE TYPED IN ONCE AND    *    04850000
C       *  EXECUTED ONCE AFTER EACH MACHINE MOVE IS TYPED OUT.     *    04851000
C       *  PROGRAMMED COMMAND MODE IS TERMINATED BY TYPING THE     *    04852000
C       *  'PC' COMMAND AGAIN.  THE NEXT TIME 'PC' IS ENTERED, THE *    04853000
C       *  COMMAND BUFFER IS INITIALIZED AND NEW COMMANDS WILL BE  *    04854000
C       *  ACCEPTED.  THE MOST COMMON COMMAND TO USE IN THIS MODE  *    04855000
C       *  IS THE 'D' COMMAND TO DISPLAY THE BOARD AFTER EACH MA-  *    04856000
C       *  CHINE MOVE.  AS MANY COMMANDS AS DESIRED (UP TO 10) MAY *    04857000
C       *  BE USED, WHEN NO MORE COMMANDS ARE TO BE ENTERED, TYPE  *    04858000
C       *  A BLANK LINE (CARRIAGE RETURN WILL DO).                 *    04859000
C       *      THERE ARE NO RESTRICTIONS AS TO WHAT COMMANDS CAN   *    04860000
C       *  BE USED, BUT SOME CAUTION SHOULD BE USED.  IT WOULD NOT *    04861000
C       *  BE WISE TO USE THE 'F' COMMAND AS THE COMMAND PROCESSOR *    04862000
C       *  WILL EXPECT YOU TO TYPE IN A MOVE TO FORCE THE COMPUTER *    04863000
C       *  TO TAKE.  THIS AND OTHERS, WHILE NOT ILLEGAL, ARE IM-   *    04864000
C       *  PRACTICAL.                                              *    04865000
C       *      THE ONLY ABSOLUTE NO-NO IS TO ENTER THE 'PC' COM-   *    04866000
C       *  MAND AS A PROGRAMMED COMMAND.  THIS WILL CAUSE RE-      *    04867000
C       *  CURSION WITH ATTENDANT PROBLEMS IN FORTRAN.             *    04868000
C       *                                                          *    04869000
C       ************************************************************    04870000
C                                                                       04871000
      IMPLICIT INTEGER*4 (A-Z)                                          04872000
      COMMON /PC CM/ CMNDS(10,3), NCMNDS, PCMODE, EXMODE                04873000
      LOGICAL PCMODE, EXMODE                                            04874000
      COMMON /BUFFER/ TEXT(30)                                          04875000
      COMMON /CHRSET/ ALPHA(44)                                         04876000
      EQUIVALENCE (BLANK,ALPHA(44)),(D,ALPHA(4))                        04877000
      IF(TEXT(3).EQ.D) GO TO 100                                        04878000
      IF(PCMODE) GO TO 70                                               04879000
C                                                                       04880000
C------------------------------< READ THE COMMANDS IN AND PUT INTO      04881000
C------------------------------< THE COMMAND BUFFER.                    04882000
C                                                                       04883000
      WRITE(6,80)                                                       04884000
      PCMODE=.TRUE.                                                     04885000
      NCMNDS=0                                                          04886000
10    NCMNDS=NCMNDS+1                                                   04887000
      WRITE(6,20)                                                       04888000
20    FORMAT(1X,'ENTER COMMAND')                                        04889000
      READ(5,30)(CMNDS(NCMNDS,I),I=1,3)                                 04890000
30    FORMAT(3R1)                                                       04891000
      IF(CMNDS(NCMNDS,1).EQ.BLANK) GO TO 60                             04892000
      GO TO 10                                                          04893000
60    NCMNDS=NCMNDS-1                                                   04894000
      IF(NCMNDS.EQ.0) PCMODE=.FALSE.                                    04895000
      RETURN                                                            04896000
C                                                                       04897000
C------------------------------< TERMINATE PROGRAMMED COMMAND MODE      04898000
C                                                                       04899000
70    PCMODE=.FALSE.                                                    04900000
      WRITE(6,90)                                                       04901000
      RETURN                                                            04902000
80    FORMAT(1X,'PROGRAMMED COMMAND MODE')                              04903000
90    FORMAT(1X,'PROGRAMMED COMMAND MODE TERMINATED')                   04904000
C                                                                       04905000
C------------------------------< DISPLAY PROGRAMMED COMMANDS            04906000
C                                                                       04907000
100   IF(.NOT. PCMODE) GO TO 130                                        04908000
      DO 110 I=1,NCMNDS                                                 04909000
          WRITE(6,120)(CMNDS(I,J),J=1,3)                                04910000
110   CONTINUE                                                          04911000
120   FORMAT(1X,3R1)                                                    04912000
      RETURN                                                            04913000
130   WRITE(6,140)                                                      04914000
140   FORMAT(1X,'NONE')                                                 04915000
      RETURN                                                            04916000
      END                                                               04917000
      SUBROUTINE PMVMKR                                                 04918000
C                                                                       04919000
C       ************************************************************    04920000
C       *                                                          *    04921000
C       *      PMVMKR IS USED TO PERMANANTLY MAKE MOVES ON THE     *    04922000
C       *  GAME BOARD.  IT USES THE USUAL 'MOVER'/'UMOVER' ROU-    *    04923000
C       *  TINES TO MOVE PIECES AROUND AND THEN CHECKS ON THE STA- *    04924000
C       *  TUS OF MOVES AND SQUARES WHICH COULD AFFECT CASTLING    *    04925000
C       *  STATUS.  IT IS ONLY USED TO MAKE HUMAN MOVES AND COM-   *    04926000
C       *  PUTER MOVES WHEN THEY ARE TO BE MADE AFTER MOVE CAL-    *    04927000
C       *  CULATION.                                               *    04928000
C       *                                                          *    04929000
C       ************************************************************    04930000
C                                                                       04931000
      IMPLICIT INTEGER*4 (A-Z)                                          04932000
      LOGICAL SAVE1,SAVE2,SAVE3,SAVE4,SAVE5,SAVE6                       04933000
      COMMON /K LOC CM/ CKINGL, HKINGL                                  04934000
      COMMON /INFO/ TYPE8, VALUE8, TO8, FROM8                           04935000
      LOGICAL CKINGM,CROOKR,CROOKL,HKINGM,HROOKR,HROOKL                 04936000
      COMMON /CAST CM/  CKINGM,CROOKR,CROOKL,HKINGM,HROOKR,HROOKL       04937000
      COMMON /TYPES/ NORMAL,CASTRT,CASTLF,ENPASS,PROMOTE                04938000
      COMMON /TREE/ DUMMY(480),PLY                                      04939000
      COMMON /BOARD/ BOARD(120)                                         04940000
C                                                                       04941000
C                                                                       04942000
C                                                                       04943000
      ENTRY PUMVER                                                      04944000
      CKINGM=SAVE1                                                      04945000
      CROOKR=SAVE2                                                      04946000
      CROOKL=SAVE3                                                      04947000
      HKINGM=SAVE4                                                      04948000
      HROOKR=SAVE5                                                      04949000
      HROOKL=SAVE6                                                      04950000
      CALL UMOVER                                                       04951000
      RETURN                                                            04952000
C                                                                       04953000
C                                                                       04954000
C                                                                       04955000
      ENTRY PMOVER                                                      04956000
      SAVE1=CKINGM                                                      04957000
      SAVE2=CROOKR                                                      04958000
      SAVE3=CROOKL                                                      04959000
      SAVE4=HKINGM                                                      04960000
      SAVE5=HROOKR                                                      04961000
      SAVE6=HROOKL                                                      04962000
      CALL MOVER                                                        04963000
      IF(TYPE8.EQ.CASTLF.OR.TYPE8.EQ.CASTRT) GO TO 20                   04964000
      IF(TO8.EQ.22) CROOKR=.TRUE.                                       04965000
      IF(TO8.EQ.29) CROOKR=.TRUE.                                       04966000
      IF(TO8.EQ.92) HROOKL=.TRUE.                                       04967000
      IF(TO8.EQ.99) HROOKR=.TRUE.                                       04968000
      IF(FROM8.EQ.22) CROOKR=.TRUE.                                     04969000
      IF(FROM8.EQ.29) CROOKL=.TRUE.                                     04970000
      IF(FROM8.EQ.92) HROOKL=.TRUE.                                     04971000
      IF(FROM8.EQ.99) HROOKR=.TRUE.                                     04972000
      IF(BOARD(TO8).EQ.6) HKINGM=.TRUE.                                 04973000
      IF(BOARD(TO8).EQ.13) CKINGM=.TRUE.                                04974000
      RETURN                                                            04975000
20    IF(MOD(PLY,2).EQ.0) HKINGM=.TRUE.                                 04976000
      IF(MOD(PLY,2).EQ.1) CKINGM=.TRUE.                                 04977000
      RETURN                                                            04978000
      END                                                               04979000
      LOGICAL FUNCTION PPUSH(SQUARE,SIDE)                               04980000
C                                                                       04981000
C       ************************************************************    04982000
C       *                                                          *    04983000
C       *      PPUSH IS USED TO DETERMINE IF A PIECE ON 'SQUARE'   *    04984000
C       *  BE ATTACKED BY PUSHING A PAWN.  IF A PAWN CAN BE USED   *    04985000
C       *  TO ATTACK 'SQUARE' PPUSH IS SET TO TRUE UNLESS THE      *    04986000
C       *  PAWN CAN BE CAPTURED BY A PAWN ON THE SAME RANK AS      *    04987000
C       *  'SQUARE'.  DOUBLE RANK ADVANCES ARE ALSO CHECKED FOR    *    04988000
C       *  PAWNS STILL ON THEIR ORIGINAL SQUARE.                   *    04989000
C       *                                                          *    04990000
C       ************************************************************    04991000
C                                                                       04992000
      IMPLICIT INTEGER*4 (A-Z)                                          04993000
      LOGICAL SIDE, PUSH2                                               04994000
      COMMON /BOARD/ BOARD(120)                                         04995000
      PPUSH  = .FALSE.                                                  04996000
      PUSH2=.TRUE.                                                      04997000
      IF(SIDE) GO TO 200                                                04998000
100   EPAWN=1                                                           04999000
      FPAWN=8                                                           05000000
      DIR=1                                                             05001000
      IF(SQUARE.LT.51.OR.SQUARE.GT.60) PUSH2=.FALSE.                    05002000
      GO TO 300                                                         05003000
200   EPAWN=8                                                           05004000
      FPAWN=1                                                           05005000
      DIR=-1                                                            05006000
      IF(SQUARE.LT.61.OR.SQUARE.GT.70) PUSH2=.FALSE.                    05007000
C                                                                       05008000
C------------------------------< CAN A PAWN BE PUSHED ONE RANK TO       05009000
C------------------------------< ATTACK 'SQUARE'?                       05010000
C                                                                       05011000
300   IF(BOARD(SQUARE).EQ.FPAWN) RETURN                                 05012000
      IF(BOARD(SQUARE-2*DIR).EQ.FPAWN) GO TO 400                        05013000
      IF(BOARD(SQUARE+DIR*9).NE.7) GO TO 400                            05014000
      IF(BOARD(SQUARE+DIR*19).EQ.EPAWN) GO TO 9998                      05015000
C                                                                       05016000
C------------------------------< CAN A PAWN BE PUSHED TWO RANKS TO      05017000
C------------------------------< ATTACK 'SQUARE'?                       05018000
C                                                                       05019000
      IF(.NOT. PUSH2) GO TO 400                                         05020000
      IF(BOARD(SQUARE+DIR*19).NE.7) GO TO 400                           05021000
      IF(BOARD(SQUARE+DIR*29).EQ.EPAWN) GO TO 9998                      05022000
C                                                                       05023000
C------------------------------< CAN A PAWN BE PUSHED ONE RANK TO       05024000
C------------------------------< ATTACK 'SQUARE'?                       05025000
C                                                                       05026000
400   IF(BOARD(SQUARE+2*DIR).EQ.FPAWN) GO TO 9999                       05027000
      IF(BOARD(SQUARE+DIR*11).NE.7) GO TO 9999                          05028000
      IF(BOARD(SQUARE+DIR*21).EQ.EPAWN) GO TO 9998                      05029000
C                                                                       05030000
C------------------------------< CAN A PAWN BE PUSHED TWO RANKS TO      05031000
C------------------------------< ATTACK 'SQUARE'?                       05032000
C                                                                       05033000
      IF(.NOT. PUSH2) GO TO 9999                                        05034000
      IF(BOARD(SQUARE+DIR*21).NE.7) GO TO 9999                          05035000
      IF(BOARD(SQUARE+DIR*31).EQ.EPAWN) GO TO 9998                      05036000
      GO TO 9999                                                        05037000
C                                                                       05038000
C------------------------------< A PAWN CAN BE PUSHED TO ATTACK         05039000
C------------------------------< 'SQUARE' BECAUSE:                      05040000
C------------------------------<     A) THERE IS A PAWN ON AN ADJACENT  05041000
C------------------------------<        FILE.                           05042000
C------------------------------<     B) THE SQUARES IN FRONT OF IT      05043000
C------------------------------<        ARE CLEAR ALLOWING ADVANCE.     05044000
C------------------------------<     C) THE PAWN CANNOT BE CAPTURED     05045000
C------------------------------<        BY AN ENEMY PAWN.               05046000
C                                                                       05047000
9998  PPUSH  = .TRUE.                                                   05048000
9999  RETURN                                                            05049000
      END                                                               05050000
      SUBROUTINE PREANL                                                 05051000
C                                                                       05052000
C       ************************************************************    05053000
C       *                                                          *    05054000
C       *      PREANL IS USED TO SET THE PIECE CONTROL BOARDS TO   *    05055000
C       *  CONTROL PROGRAM STRATEGY.  THERE IS A CONTROL BOARD     *    05056000
C       *  FOR EACH TYPE OF PIECE TO CONTROL HOW TO BEST USE IT    *    05057000
C       *  IN FORMING STRATEGY.  INITIALLY, ALL BOARDS ARE SET TO  *    05058000
C       *  ATTRACT PIECES TOWARD THE CENTER OF THE BOARD, AND AF-  *    05059000
C       *  TER DEVELOPMENT IS COMPLETE, THE BOARDS ATTRACT PIECES  *    05060000
C       *  TOWARD THE VICINITY OF THE OPPONENT'S KING OR GOOD      *    05061000
C       *  SQUARES TO CONTROL.                                     *    05062000
C       *      THEN A SPECIFIC SUBROUTINE IS CALLED FOR EACH PIECE *    05063000
C       *  TYPE TO SET SPECIFIC TACTICAL VALUES BEFORE THE ACTUAL  *    05064000
C       *  SEARCH IS STARTED.  FOR EXAMPLE, KNIGHTS ARE DRIVEN     *    05065000
C       *  AWAY FROM THE EDGE OF THE BOARD, BISHOPS ARE ATTRACTED  *    05066000
C       *  TO STRONG DIAGONALS, ETC.                               *    05067000
C       *                                                          *    05068000
C       ************************************************************    05069000
C                                                                       05070000
      IMPLICIT INTEGER*4 (A-Z)                                          05071000
      COMMON /BOARD/ BOARD(120)                                         05072000
      COMMON /DATA/ CMOVE, SMOVE, HFROM8, HTO8, HTYPE8, MOVE            05073000
      COMMON /K LOC CM/ CKINGL, HKINGL                                  05074000
      COMMON /P LOC CM/ CPLOC(8), HPLOC(8), NCPNS, NHPNS                05075000
      COMMON /K BD SM/ CKSCOR(100), HKSCOR(100)                         05076000
      COMMON /Q BD SM/ CQSCOR(100), HQSCOR(100)                         05077000
      COMMON /R BD SM/ CRSCOR(100), HRSCOR(100)                         05078000
      COMMON /B BD SM/ CBSCOR(100), HBSCOR(100)                         05079000
      COMMON /N BD SM/ CNSCOR(100), HNSCOR(100)                         05080000
      COMMON /P BD SM/ CPSCOR(100), HPSCOR(100)                         05081000
      COMMON /P SM/ PADVNC, PPAWN, IPAWN, DPAWN, TPAWN, CPAWN,          05082000
     * ABREST, PPSHSC                                                   05083000
      COMMON /PHASE/ OPEN, MIDDLE, END                                  05084000
      LOGICAL OPEN, MIDDLE, END                                         05085000
      COMMON /DEV STS/ CDONE, HDONE                                     05086000
      LOGICAL CDONE, HDONE                                              05087000
      COMMON /MTRL SC/ CPCVAL, HPCVAL                                   05088000
      CALL SETPCV                                                       05089000
      OPEN=(HPCVAL+CPCVAL.GT.43200).AND.(MOVE.LE.15)                    05090000
      END=HPCVAL+CPCVAL.LT.26400                                        05091000
      MIDDLE=.NOT.OPEN .AND. .NOT.END                                   05092000
C                                                                       05093000
C------------------------------< DETERMINE IF EACH SIDE HAS COMPLETED   05094000
C------------------------------< MINOR PIECE DEVELOPMENT.               05095000
C                                                                       05096000
      HDONE=.TRUE.                                                      05097000
      CDONE=.TRUE.                                                      05098000
      IF(MOVE.GT.15) GO TO 550                                          05099000
      DO 500 SQ=22,29                                                   05100000
          IF(BOARD(SQ).EQ.9) CDONE=.FALSE.                              05101000
          IF(BOARD(SQ).EQ.10) CDONE=.FALSE.                             05102000
          IF(BOARD(SQ+70).EQ.2) HDONE=.FALSE.                           05103000
          IF(BOARD(SQ+70).EQ.3) HDONE=.FALSE.                           05104000
C                                                                       05105000
C------------------------------< EITHER SET THE CONTROL BOARDS TO       05106000
C------------------------------< ATTACK THE OPPONENT'S KING OR THE      05107000
C------------------------------< CENTER OF THE BOARD DEPENDING ON       05108000
C------------------------------< THE STAGE OF THE GAME.                 05109000
C                                                                       05110000
500   CONTINUE                                                          05111000
550   CONTINUE                                                          05112000
      CALL LOCATE                                                       05113000
      TEMP=CKINGL                                                       05114000
      IF(OPEN) TEMP=65                                                  05115000
      CALL SETSQ(HKSCOR,TEMP,PADVNC)                                    05116000
      TEMP=HKINGL                                                       05117000
      IF(OPEN) TEMP=55                                                  05118000
      CALL SETSQ(CKSCOR,TEMP,PADVNC)                                    05119000
      DO 100 I=1,100                                                    05120000
          CQSCOR(I)=CKSCOR(I)                                           05121000
          CRSCOR(I)=CKSCOR(I)                                           05122000
          CBSCOR(I)=CKSCOR(I)                                           05123000
          CNSCOR(I)=CKSCOR(I)                                           05124000
          HQSCOR(I)=HKSCOR(I)                                           05125000
          HRSCOR(I)=HKSCOR(I)                                           05126000
          HBSCOR(I)=HKSCOR(I)                                           05127000
          HNSCOR(I)=HKSCOR(I)                                           05128000
100   CONTINUE                                                          05129000
C                                                                       05130000
C------------------------------< LOCATE THE PAWNS ON THE BOARD TO       05131000
C------------------------------< DETERMINE WHICH DIRECTION THE PIECES   05132000
C------------------------------< SHOULD HEAD.                           05133000
C                                                                       05134000
200   NHPNS=0                                                           05135000
      NCPNS=0                                                           05136000
      DO 400 ST=22,29                                                   05137000
          DO 350 SQ=ST,99,10                                            05138000
              IF(BOARD(SQ).NE.1) GO TO 300                              05139000
              NHPNS=NHPNS+1                                             05140000
              HPLOC(NHPNS)=SQ                                           05141000
              GO TO 400                                                 05142000
300           IF(BOARD(SQ).NE.8) GO TO 350                              05143000
              NCPNS=NCPNS+1                                             05144000
              CPLOC(NCPNS)=SQ                                           05145000
350       CONTINUE                                                      05146000
400   CONTINUE                                                          05147000
      CALL SETPBD                                                       05148000
      CALL SETNBD                                                       05149000
      CALL SETBBD                                                       05150000
      CALL SETRBD                                                       05151000
      CALL SETQBD                                                       05152000
      CALL SETKBD                                                       05153000
      RETURN                                                            05154000
      END                                                               05155000
      INTEGER FUNCTION PSCORE(SQUARE,SIDE)                              05156000
C                                                                       05157000
C       ************************************************************    05158000
C       *                                                          *    05159000
C       *      PSCORE IS USED TO COMPUTE THE PLAUSIBILITY SCORE    *    05160000
C       *  FOR PAWN MOVES.  THE SCORE IS OBTAINED DIRECTLY FROM    *    05161000
C       *  THE PAWN CONTROL BOARD FOR THE SIDE TO MOVE. (CPSCOR,   *    05162000
C       *  HPSCOR IN COMMON BLOCK 'P BD SM').                      *    05163000
C       *      THE SCORE IS ADJUSTED AS INDICATED FOR EACH OF THE  *    05164000
C       *  FOLLOWING FACTORS PRESENT:                                   05165000
C       *      1)  BONUS FOR ADVANCING A PASSED PAWN               *    05166000
C       *      2)  BONUS FOR PUSHING A PAWN TO A SQUARE WHERE IT   *    05167000
C       *          BECOMES PASSED, IE. PUSHING IT PAST A PAWN      *    05168000
C       *          WHICH COULD CAPTURE IT (EXCHANGING, POSSIBLY).  *    05169000
C       *      3)  PENALTY FOR DOUBLING/TRIPLING PAWNS.            *    05170000
C       *      4)  BONUS FOR KEEPING PAWNS CONNECTED.              *    05171000
C       *      5)  BONUS FOR KEEPING PAWNS ABREAST (FLUID).        *    05172000
C       *      6)  PENALTY FOR MOVING A PAWN TO A SQUARE WHERE IT  *    05173000
C       *          IS ISOLATED.                                    *    05174000
C       *                                                          *    05175000
C       ************************************************************    05176000
C                                                                       05177000
      IMPLICIT INTEGER*4 (A-Z)                                          05178000
      COMMON /BOARD/ BOARD(120)                                         05179000
      COMMON /P SM/ PADVNC, PPAWN, IPAWN, DPAWN, TPAWN, CPAWN,          05180000
     * ABREST, PPSHSC                                                   05181000
      COMMON /P BD SM/ CPSCOR(100), HPSCOR(100)                         05182000
      LOGICAL SIDE, ISOLAT                                              05183000
      IF(SIDE) GO TO 200                                                05184000
C                                                                       05185000
C==============================< COMPUTER SCORING                       05186000
C                                                                       05187000
100   PSCORE=CPSCOR(SQUARE)                                             05188000
      FPAWN=8                                                           05189000
      GO TO 300                                                         05190000
C                                                                       05191000
C==============================< HUMAN SCORING                          05192000
C                                                                       05193000
200   PSCORE=HPSCOR(SQUARE)                                             05194000
      FPAWN=1                                                           05195000
C                                                                       05196000
C------------------------------< ADD IN THE SCORE FOR ADVANCING/        05197000
C------------------------------< CREATING A PASSED PAWN BY CALLING      05198000
C------------------------------< 'PASSED' TO DETERMINE IF A PAWN        05199000
C------------------------------< ON 'SQUARE' IS PASSED AND IF SO,       05200000
C------------------------------< IT'S VALUE.                            05201000
C                                                                       05202000
300   PSCORE=PSCORE+PASSED(SQUARE,SIDE)                                 05203000
C                                                                       05204000
C------------------------------< DETERMINE IF THE PAWN IS BEING MOVED   05205000
C------------------------------< TO A FILE WITH AT LEAST ONE FRIENDLY   05206000
C------------------------------< PAWN ON IT. IF SO, PENALIZE THE SCORE  05207000
C------------------------------< FOR DOUBLING/TRIPLING PAWNS.           05208000
C                                                                       05209000
      RANK=MOD(SQUARE,10)+30                                            05210000
      RANKE=RANK+50                                                     05211000
      PCOUNT=1                                                          05212000
      DO 400 SQ=RANK,RANKE,10                                           05213000
          IF(SQ.EQ.SQUARE) GO TO 400                                    05214000
          IF(BOARD(SQ).EQ.FPAWN) PCOUNT=PCOUNT+1                        05215000
400   CONTINUE                                                          05216000
      IF(PCOUNT.LE.1) GO TO 500                                         05217000
      PSCORE=PSCORE-DPAWN                                               05218000
      IF(PCOUNT.EQ.2) GO TO 500                                         05219000
      PSCORE=PSCORE-TPAWN                                               05220000
C                                                                       05221000
C------------------------------< IF THE PAWN IS ISOLATED, PENALIZE      05222000
C------------------------------< THE SCORE (THIS CAPTURING MOVE         05223000
C------------------------------< MAKES THIS PAWN ISOLATED)-             05224000
C                                                                       05225000
500   IF(ISOLAT(SQUARE,SIDE)) PSCORE=PSCORE-IPAWN*PCOUNT                05226000
C                                                                       05227000
C------------------------------< DETERMINE IF THE PAWN IS CONNECTED     05228000
C------------------------------< WITH FREINDLY PAWNS.  IF SO, ADD A     05229000
C------------------------------< BONUS TO THE MOVE'S SCORE.             05230000
C                                                                       05231000
      L1=SQUARE-10                                                      05232000
      L2=SQUARE+10                                                      05233000
      IF(.NOT.SIDE.AND.(SQUARE-1)/10.EQ.5) L1=L1-10                     05234000
      IF(SIDE.AND.(SQUARE-1)/10.EQ.6) L2=L2+10                          05235000
      DO 600 SQ=L1,L2,10                                                05236000
          IF(BOARD(SQ-1).EQ.FPAWN) GO TO 700                            05237000
          IF(BOARD(SQ+1).EQ.FPAWN) GO TO 700                            05238000
600   CONTINUE                                                          05239000
      GO TO 800                                                         05240000
700   PSCORE=PSCORE+CPAWN                                               05241000
C                                                                       05242000
C------------------------------< DETERMINE IF THE PAWN IS ABREAST OF    05243000
C------------------------------< WITH A FREINDLY PAWN (FLUID PAWN       05244000
C------------------------------< STRUCTURE).  IF SO, ADD A BONUS TO     05245000
C------------------------------< THE MOVE'S SCORE.                      05246000
C                                                                       05247000
      IF(BOARD(SQUARE-1).EQ.FPAWN.OR.BOARD(SQUARE+1).EQ.FPAWN)          05248000
     *                            PSCORE=PSCORE+ABREST                  05249000
800   RETURN                                                            05250000
      END                                                               05251000
      INTEGER FUNCTION QSCORE(SQUARE,SIDE)                              05252000
C                                                                       05253000
C       ************************************************************    05254000
C       *                                                          *    05255000
C       *      QSCORE IS USED TO COMPUTE THE PLAUSIBILITY SCORE    *    05256000
C       *  FOR QUEEN MOVES. THE SCORE IS OBTAINED DIRECTLY FROM    *    05257000
C       *  THE QUEEN CONTROL BOARD FOR THE SIDE TO MOVE. (CQSCOR,  *    05258000
C       *  HQSCOR IN COMMON BLOCK 'Q BD SM').                      *    05259000
C       *                                                          *    05260000
C       ************************************************************    05261000
C                                                                       05262000
      IMPLICIT INTEGER*4 (A-Z)                                          05263000
      COMMON /Q BD SM/ CQSCOR(100), HQSCOR(100)                         05264000
      LOGICAL SIDE                                                      05265000
      IF(SIDE) GO TO 200                                                05266000
C                                                                       05267000
C==============================< COMPUTER SCORING                       05268000
C                                                                       05269000
100   QSCORE=CQSCOR(SQUARE)                                             05270000
      RETURN                                                            05271000
C                                                                       05272000
C==============================< HUMAN SCORING                          05273000
C                                                                       05274000
200   QSCORE=HQSCOR(SQUARE)                                             05275000
      RETURN                                                            05276000
      END                                                               05277000
      SUBROUTINE QUERY                                                  05278000
C                                                                       05279000
C       ************************************************************    05280000
C       *                                                          *    05281000
C       *      QUERY IS USED TO QUERY THE OPERATOR ABOUT THE       *    05282000
C       *  AMOUNT OF TIME REMAINING ON THE PROGRAM'S CHESS CLOCK.  *    05283000
C       *  FOR THE FIRST THIRTY MOVES, THE QUERY IS MADE EACH 10   *    05284000
C       *  MOVES; AFTER THAT THE QUERY IS MADE EACH 3 MOVES.  FOR  *    05285000
C       *  EXAMPLE, THE OPERATOR WOULD BE ASKED ON MOVE 10,20,30,  *    05286000
C       *  33,36,39,43,46,49,53,56,59.  NOTICE THAT AFTER 30 MOVES,*    05287000
C       *  EVERY 3RD IS USED, SKIPPING THE 10TH SINCE THE CLOCK    *    05288000
C       *  IS RESET EACH 10TH MOVE IN TOURNAMENT PLAY.             *    05289000
C       *                                                          *    05290000
C       ************************************************************    05291000
C                                                                       05292000
      IMPLICIT INTEGER*4 (A-Z)                                          05293000
      COMMON /MOV CNT/ NCMOVS, NHMOVS                                   05294000
      COMMON /CHRSET/ ALPHA(44)                                         05295000
      EQUIVALENCE (C,ALPHA(3)),(D,ALPHA(4))                             05296000
      COMMON /CLOK CM/ CLOCK,CTYPE,CQUERY,GELAP,CELAP,HELAP,            05297000
     *ELAPC,ELAPH,MOVES,SMOVES,SELAP,CTOTAL,HTOTAL,OPTIME               05298000
      COMMON /BUFFER/ TEXT(30)                                          05299000
      LOGICAL CLOCK, CQUERY                                             05300000
C------------------------------< IF MORE THAT 10 MOVES REMAIN IN THE    05301000
C------------------------------< TIMING INTERVAL, ONLY ASK EVERY        05302000
C------------------------------< 10 MOVES.                              05303000
C                                                                       05304000
      IF(MOVES-NCMOVS.LE.10) GO TO 100                                  05305000
      IF(MOD(NCMOVS,10).EQ.0) GO TO 200                                 05306000
      GO TO 999                                                         05307000
C                                                                       05308000
C------------------------------< IF FEWER THAN 10 MOVES REMAIN, ASK ON  05309000
C------------------------------< EACH 3RD MOVE, NOT COUNTING EACH       05310000
C------------------------------< 10TH MOVE (33,36,39,43,46,49,ETC)      05311000
C                                                                       05312000
100   MOVE=MOVES-NCMOVS                                                 05313000
      IF(MOVE.EQ.10) GO TO 999                                          05314000
      IF(MOD(MOVE,3).NE.0) GO TO 999                                    05315000
200   TEXT(2)=D                                                         05316000
      CALL CCMND(6)                                                     05317000
      TEXT(2)=C                                                         05318000
      TEXT(3)=C                                                         05319000
      CALL CCMND(6)                                                     05320000
999   RETURN                                                            05321000
      END                                                               05322000
$CONTROL SEGMENT=CMND                                                   05323000
      SUBROUTINE RCMND(RESTRT)                                          05324000
C                                                                       05325000
C       ************************************************************    05326000
C       *                                                          *    05327000
C       *      RCMND IS USED TO PROCESS THE 'R' COMMAND WHICH CAN  *    05328000
C       *  RESET THE BOARD TO THE POSITION AFTER ANY PRIOR MOVE.   *    05329000
C       *  THE BOARD IS ALWAYS RESET TO THE POSITION FOR THE MOVE  *    05330000
C       *  INDICATED, SO THAT IT IS THE HUMAN'S TURN TO MOVE.  FOR *    05331000
C       *  EXAMPLE, IF THE COMPUTER IS WHITE, AND YOU WISH TO BACK *    05332000
C       *  UP TO MOVE 15, THE MOVE FOR BLACK LISTED UNDER MOVE 15  *    05333000
C       *  WOULD NOT BE MADE.                                      *    05334000
C       *      'RK' IS AN ALTERNATIVE WAY TO SET THE BOARD TO      *   05335000
C       *  SET UP A BOARD POSITION.  IN THIS MODE, YOU CAN KEY     *    05336000
C       *  MOVES IN FOR BOTH SIDES, STARTING WITH WHITE.  THE      *    05337000
C       *  MOVES WILLBE MADE AS YOU ENTER THEM, TERMINATING        *    05338000
C       *  WHEN THE CORRECT NUMBER HAVE BEEN TYPED IN OR BY        *    05339000
C       *  END-OF-FILE.                                            *    05340000
C       *                                                          *    05341000
C       ************************************************************    05342000
C                                                                       05343000
      IMPLICIT INTEGER*4 (A-Z)                                          05344000
      COMMON /BUFFER/ TEXT(30)                                          05345000
      COMMON /HIST CM/ NMOVES, ANNOTE                                   05346000
      COMMON /COLR CM/ CCOLOR, HCOLOR, COLOR                            05347000
      COMMON /TREE/ TREE(480), PLY                                      05348000
      COMMON /PRUNE/ WIDTH(10), MIN(10), MAX(10),                       05349000
     * DEPTH, ORDER1, ORDER2                                            05350000
      COMMON /MOV CNT/ NCMOVS, NHMOVS                                   05351000
      COMMON /V CM/ VCMOVE                                              05352000
      COMMON /CHR SET/ ALPHA(44)                                        05353000
      EQUIVALENCE (K,ALPHA(11))                                         05354000
      CHARACTER*5 CCOLOR, HCOLOR                                        05355000
      DATA ZERO / 0J /                                                  05356000
      KEYIN=0                                                           05357000
      IF (RESTRT.EQ.1)GOTO 99                                           05358000
      IF(TEXT(2).EQ.K) KEYIN=1                                          05359000
5     IF(KEYIN.EQ.0) WRITE(6,10)                                        05360000
      IF(KEYIN.EQ.1) WRITE(6,11)                                        05361000
11    FORMAT(1X,'HOW MANY MOVES?')                                      05362000
10    FORMAT(1X,'RESET BOARD TO WHICH MOVE?')                           05363000
      CALL INPUT(MOVENO)                                                05364000
      IF(MOVENO.EQ.0) RETURN                                            05365000
   99 IF((KEYIN.EQ.1).OR.(RESTRT.EQ.1)) NMOVES=999                      05366000
      PLY=1                                                             05367000
      IF(COLOR.EQ.1) PLY=0                                              05368000
C                                                                       05369000
C------------------------------< DETERMINE EXACTLY HOW MANY MOVES       05370000
C------------------------------< TO PROCESS.  LEAVE THE HUMAN'S LAST    05371000
C------------------------------< MOVE OUT SO IT WILL BE HIS TURN.       05372000
C                                                                       05373000
      NCMOVS=MOVENO                                                     05374000
      NHMOVS=MOVENO                                                     05375000
      IF(COLOR.EQ.1) NHMOVS=NHMOVS-1                                    05376000
      MOVENO=MOVENO*2                                                   05377000
      IF(COLOR.EQ.1) MOVENO=MOVENO-1                                    05378000
C     IF(MOVENO.GT.NMOVES) GO TO 60                                     05379000
      NMOVES=MOVENO                                                     05380000
      CALL SETGB                                                        05381000
      COUNT=0                                                           05382000
      TEMP1=ORDER1                                                      05383000
      TEMP2=ORDER2                                                      05384000
      ORDER1=0                                                          05385000
      ORDER2=0                                                          05386000
C                                                                       05387000
C------------------------------< NOW, EITHER READ THE MOVE FILE OR      05388000
C------------------------------< FROM THE USER THE LIST OF MOVES        05389000
C------------------------------< TO MAKE.                               05390000
C                                                                       05391000
30    PLY=2-MOD(PLY+1,2)                                                05392000
      COUNT=COUNT+1                                                     05393000
      IF(COUNT.GT.MOVENO) GO TO 45                                      05394000
      IF(KEYIN.EQ.1) GO TO 35                                           05395000
      READ(1@COUNT,END=999)TEXT                                         05396000
      GO TO 37                                                          05397000
35    READ(5,100,END=45) TEXT                                           05398000
100   FORMAT(30R1)                                                      05399000
      WRITE(1@COUNT) TEXT, ZERO, ZERO                                   05400000
37    CALL INMOVE(PLY,$35)                                              05401000
40    CALL PMOVER                                                       05402000
      GO TO 30                                                          05403000
45    ORDER1=TEMP1                                                      05404000
      ORDER2=TEMP2                                                      05405000
      CALL ENTERD(VCMOVE)                                               05406000
      RETURN                                                            05407000
60    WRITE(6,70)                                                       05408000
70    FORMAT(1X,'THAT MOVE HASN''T BEEN MADE YET!')                     05409000
      GO TO 5                                                           05410000
  999 NMOVES=COUNT-1                                                    05411000
      NHMOVS=NMOVES/2                                                   05412000
      NCMOVS=NHMOVS                                                     05413000
      RESTRT=0                                                          05414000
      RETURN                                                            05415000
      END                                                               05416000
$CONTROL SEGMENT=PC                                                     05417000
      SUBROUTINE ROOK                                                   05418000
C                                                                       05419000
C       ************************************************************    05420000
C       *                                                          *    05421000
C       *      ROOK GENERATES ALL ROOK MOVES AND VERTICAL/HORI-    *    05422000
C       *  ZONTAL MOVES FOR THE QUEEN.  SUBROUTINE SCORE IS CALLED *    05423000
C       *  TO COMPUTE THE PLAUSIBILITY SCORE FOR THE MOVE, AFTER   *    05424000
C       *  WHICH THE MOVE IS ENTERED IN THE MOVE LIST.             *    05425000
C       *                                                          *    05426000
C       ************************************************************    05427000
C                                                                       05428000
      IMPLICIT INTEGER*4 (A-Z)                                          05429000
      COMMON /BOARD/ BOARD(120)                                         05430000
      COMMON /MOVES/ RK(4),BP(4),KT(8),KG(8)                            05431000
      COMMON /MOVE CM/ FROMSQ, TOSQ, SIDE                               05432000
      LOGICAL SIDE, CHECK                                               05433000
      COMMON /INFO/ TYPE8, VALUE8, TO8, FROM8                           05434000
      COMMON /TYPES/ NORMAL,CASTRT,CASTLF,ENPASS,PROMOTE                05435000
1000  DO 1030 I=1,4                                                     05436000
          TO8=FROM8                                                     05437000
          DIREC=RK(I)                                                   05438000
1010      TO8=TO8+DIREC                                                 05439000
          TOSQ=BOARD(TO8)                                               05440000
          TYPE8=NORMAL                                                  05441000
          IF(SIDE.AND.TOSQ.LT.7) GO TO 1030                             05442000
          IF(.NOT.SIDE.AND.TOSQ.GT.7) GO TO 1030                        05443000
          IF(TOSQ.EQ.14) GO TO 1030                                     05444000
          BOARD(TO8)=FROMSQ                                             05445000
          IF(CHECK(SIDE)) GO TO 1020                                    05446000
          CALL SCORE                                                    05447000
          CALL ENTER                                                    05448000
1020      BOARD(TO8)=TOSQ                                               05449000
          IF(TOSQ.EQ.7) GO TO 1010                                      05450000
1030  CONTINUE                                                          05451000
      RETURN                                                            05452000
      END                                                               05453000
      INTEGER FUNCTION RSCORE(SQUARE,SIDE)                              05454000
C                                                                       05455000
C       ************************************************************    05456000
C       *                                                          *    05457000
C       *      RSCORE IS USED TO COMPUTE THE PLAUSIBILITY SCORE    *    05458000
C       *  FOR ROOK MOVES.  THE SCORE IS OBTAINED DIRECTLY FROM    *    05459000
C       *  THE ROOK CONTROL BOARD FOR THE SIDE TO MOVE. (CRSCOR,   *    05460000
C       *  HRSCOR IN COMMON BLOCK 'R BD SM').                      *    05461000
C       *      THE SCORE IS ADJUSTED AS INDICATED FOR EACH OF THE  *    05462000
C       *  FOLLOWING FACTORS PRESENT:                              *    05463000
C       *      1)  BONUS FOR MOVING TO THE 7TH OR 8TH RANK WHILE   *    05464000
C       *          THE OPPONENT'S KING IS STILL ON THE 8TH RANK.   *    05465000
C       *      2)  BONUS FOR MOVING TO AN OPEN OR HALF OPEN FILE.  *    05466000
C       *      3)  BONUS FOR DOUBLING ROOKS ON AN OPEN FILE.       *    05467000
C       *                                                          *    05468000
C       ************************************************************    05469000
C                                                                       05470000
      IMPLICIT INTEGER*4 (A-Z)                                          05471000
      COMMON /BOARD/ BOARD(120)                                         05472000
      COMMON /R BD SM/ CRSCOR(100), HRSCOR(100)                         05473000
      COMMON /MOVES/ RK(4),BP(4),KT(8),KG(8)                            05474000
      COMMON /R SM/ ERMOVE, RANK78, ROPEN, RHALF, DROOKS, CROOKS,       05475000
     * RPASS, R EDGE                                                    05476000
      COMMON /K LOC CM/ CKINGL, HKINGL                                  05477000
      COMMON /R LOC CM/ ONECRK, ONEHRK                                  05478000
      COMMON /PHASE/ OPEN, MIDDLE, END                                  05479000
      LOGICAL OPEN, MIDDLE, END                                         05480000
      LOGICAL ONECRK, ONEHRK, SIDE, CP, HP, NOTTWO                      05481000
      NOTTWO=.FALSE.                                                    05482000
      IF(SIDE) GO TO 200                                                05483000
C                                                                       05484000
C==============================< COMPUTER SCORING                       05485000
C                                                                       05486000
100   RSCORE=CRSCOR(SQUARE)                                             05487000
      ROOK=11                                                           05488000
      PAWN=8                                                            05489000
150   IF(ONECRK) GO TO 275                                              05490000
      GO TO 300                                                         05491000
C                                                                       05492000
C==============================< HUMAN SCORING                          05493000
C                                                                       05494000
200   RSCORE=HRSCOR(SQUARE)                                             05495000
      ROOK=4                                                            05496000
      PAWN=1                                                            05497000
250   IF(.NOT.ONEHRK) GO TO 300                                         05498000
275   NOTTWO=.TRUE.                                                     05499000
C                                                                       05500000
C------------------------------< DETERMINE IF THERE ARE PAWNS ON        05501000
C------------------------------< FILE AND WHICH SIDE THEY BELONG TO.    05502000
C                                                                       05503000
300   CP=.FALSE.                                                        05504000
      HP=.FALSE.                                                        05505000
      J=MOD(SQUARE,10)+30                                               05506000
      DO 500 I=J,90,10                                                  05507000
          T=BOARD(I)                                                    05508000
          IF(T.NE.1) GO TO 400                                          05509000
          HP=.TRUE.                                                     05510000
          H=I                                                           05511000
          GO TO 500                                                     05512000
400       IF(T.NE.8) GO TO 500                                          05513000
          CP=.TRUE.                                                     05514000
          C=I                                                           05515000
500   CONTINUE                                                          05516000
C                                                                       05517000
C------------------------------< IF THERE ARE NO PAWNS, ADD A BONUS     05518000
C------------------------------< FOR MOVING A ROOK TO AN OPEN FILE.     05519000
C                                                                       05520000
      IF(HP.AND.CP) GO TO 9999                                          05521000
      IF(HP.OR.CP) GO TO 900                                            05522000
      RSCORE=RSCORE+ROPEN                                               05523000
C                                                                       05524000
C------------------------------< CHECK TO SEE IF THERE IS ANOTHER       05525000
C------------------------------< ROOK ON THIS FILE.  IF SO, ADD A       05526000
C------------------------------< BONUS FOR DOUBLING ON AN OPEN FILE.    05527000
C                                                                       05528000
      IF(NOTTWO) GO TO 9999                                             05529000
      DO 700 I=1,2                                                      05530000
          SQ=SQUARE                                                     05531000
          DIREC=RK(I)                                                   05532000
600       SQ=SQ+DIREC                                                   05533000
          TEMP=BOARD(SQ)                                                05534000
          IF(TEMP.EQ.7) GO TO 600                                       05535000
          IF(TEMP.EQ.ROOK) GO TO 800                                    05536000
700   CONTINUE                                                          05537000
      GO TO 9999                                                        05538000
800   RSCORE=RSCORE+DROOKS                                              05539000
      GO TO 9999                                                        05540000
C                                                                       05541000
C------------------------------< IF THERE IS ONE PAWN ON THIS FILE,     05542000
C------------------------------< AND IT DOES NOT BELONG TO THE SIDE     05543000
C------------------------------< TO MOVE, ADD A BONUS FOR MOVING A      05544000
C------------------------------< ROOK TO A HALF-OPEN FILE.              05545000
C                                                                       05546000
900   IF(SIDE) GO TO 950                                                05547000
      IF(HP) RSCORE=RSCORE+RHALF                                        05548000
      GO TO 975                                                         05549000
950   IF(CP) RSCORE=RSCORE+RHALF                                        05550000
C                                                                       05551000
C------------------------------< IF THE FILE HAS PAWNS PRESENT,         05552000
C------------------------------< CHECK TO SEE IF ONE IS PASSED.  IF     05553000
C------------------------------< SO, ADD A BONUS TO THE SCORE TO        05554000
C------------------------------< ENCOURAGE THE ROOKS TO GET BEHIND      05555000
C------------------------------< THE PAWN.                  ======      05556000
C                                                                       05557000
975   IF(OPEN) GO TO 9999                                               05558000
      IF(SIDE) GO TO 2000                                               05559000
1000  IF(CP) GO TO 1100                                                 05560000
      TEMP=PASSED(H,.NOT.SIDE)                                          05561000
      IF(TEMP.EQ.0) GO TO 9999                                          05562000
      IF(SQUARE.GT.H) RSCORE=RSCORE+RPASS+TEMP/2                        05563000
      GO TO 9999                                                        05564000
1100  TEMP=PASSED(C,SIDE)                                               05565000
      IF(TEMP.EQ.0) GO TO 9999                                          05566000
      IF(SQUARE.LT.C) RSCORE=RSCORE+RPASS+TEMP/2                        05567000
      GO TO 9999                                                        05568000
2000  IF(HP) GO TO 2100                                                 05569000
      TEMP=PASSED(C,.NOT.SIDE)                                          05570000
      IF(TEMP.EQ.0) GO TO 9999                                          05571000
      IF(SQUARE.LT.C) RSCORE=RSCORE+RPASS+TEMP/2                        05572000
      GO TO 9999                                                        05573000
2100  TEMP=PASSED(H,SIDE)                                               05574000
      IF(TEMP.EQ.0) GO TO 9999                                          05575000
      IF(SQUARE.GT.H) RSCORE=RSCORE+RPASS+TEMP/2                        05576000
9999  RETURN                                                            05577000
      END                                                               05578000
      SUBROUTINE SAVER                                                  05579000
C                                                                       05580000
C       ************************************************************    05581000
C       *                                                          *    05582000
C       *      SAVER WITH IT'S TWO ENTRY POINTS 'SAVE GB' AND      *    05583000
C       *  'REST GB' IS USED TO SAVE/RESTORE THE GAME BOARD AND    *    05584000
C       *  CASTLING STATUS.  THIS IS USED BY ROUTINES WHICH        *    05585000
C       *  MUST MODIFY THE GAME BOARD TO PROCESS VARIOUS COMMANDS  *    05586000
C       *  AND THEN NEED TO RESTORE IT TO 'AS IT WAS' AFTER FIN-   *    05587000
C       *  ISHING PROCESSING.                                      *    05588000
C       *                                                          *    05589000
C       ************************************************************    05590000
C                                                                       05591000
      IMPLICIT INTEGER*4 (A-Z)                                          05592000
      COMMON /BOARD/ BOARD(120)                                         05593000
      COMMON /SAVE CM/ SBOARD(100)                                      05594000
      COMMON /CAST CM/ CKINGM,CROOKR,CROOKL,HKINGM,HROOKR,HROOKL        05595000
      LOGICAL SAVE1,SAVE2,SAVE3,SAVE4,SAVE5,SAVE6                       05596000
      LOGICAL CKINGM,CROOKR,CROOKL,HKINGM,HROOKR,HROOKL                 05597000
C                                                                       05598000
C                                                                       05599000
C                                                                       05600000
      ENTRY SAVE GB                                                     05601000
      DO 10 I=1,100                                                     05602000
          SBOARD(I)=BOARD(I)                                            05603000
10    CONTINUE                                                          05604000
      SAVE1=CKINGM                                                      05605000
      SAVE2=CROOKR                                                      05606000
      SAVE3=CROOKL                                                      05607000
      SAVE4=HKINGM                                                      05608000
      SAVE5=HROOKR                                                      05609000
      SAVE6=HROOKL                                                      05610000
      RETURN                                                            05611000
C                                                                       05612000
C                                                                       05613000
C                                                                       05614000
      ENTRY REST GB                                                     05615000
      DO 20 I=1,100                                                     05616000
          BOARD(I)=SBOARD(I)                                            05617000
20    CONTINUE                                                          05618000
      CKINGM=SAVE1                                                      05619000
      CROOKR=SAVE2                                                      05620000
      CROOKL=SAVE3                                                      05621000
      HKINGM=SAVE4                                                      05622000
      HROOKR=SAVE5                                                      05623000
      HROOKL=SAVE6                                                      05624000
      RETURN                                                            05625000
      END                                                               05626000
$CONTROL SEGMENT=CMND                                                   05627000
      SUBROUTINE SCMND(*)                                               05628000
C                                                                       05629000
C       ************************************************************    05630000
C       *                                                          *    05631000
C       *       SCMND IS USED TO CONTROL THE PRUNING OF THE TREE   *    05632000
C       *  DURING MOVE CALCULATION.  THERE ARE FOUR BASIC PRUNING  *    05633000
C       *  FUNCTIONS TO CONTROL:                                   *    05634000
C       *     1)  'SD' : LOOK-AHEAD DEPTH CONTROL.  THIS CONTROLS  *    05635000
C       *         HOW FAR THE PROGRAM LOOKS AHEAD IN TERMS OF      *    05636000
C       *         HALF MOVES OR 'PLIES'.                           *    05637000
C       *     2)  'SW' : FORWARD PRUNING WIDTHS.  THIS CONTROLS    *    05638000
C       *         'FANOUT' OR NUMBER OF MOVES AT EACH LEVEL THE    *    05639000
C       *         PROGRAM WILL CONSIDER.  FOR EXAMPLE, IF ON THE   *    05640000
C       *         FIRST PLY, THE MACHINE HAS 40 LEGAL MOVES AND    *    05641000
C       *         PRUNING WIDTH FOR PLY 1 IS SET AT 20, ONLY THE   *    05642000
C       *         BEST (HOPEFULLY) 20 MOVES WILL BE CONSIDERED,    *    05643000
C       *         IGNORING THE BOTTOM 20.  THIS CAN RESULT IN A    *    05644000
C       *         TREMENDOUS SPEED-UP IN MOVE CALCULATION TIME,    *    05645000
C       *         BUT CAN ALSO RESULT IN PATHETIC BLUNDERS SINCE   *    05646000
C       *         THE PROGRAM CAN'T KNOW WHICH ARE THE BEST 20     *    05647000
C       *         MOVES UNTIL IT HAS ACTUALLY LOOKED AT THEM.  THIS*    05648000
C       *         SOMEWHAT PROBABLISTIC PRUNING STILL IS QUITE AD- *    05649000
C       *         VANTAGEOUS JUST TO IGNORE THE LAST 5 MOVES.      *    05650000
C       *         'SW1' SETS THE MINIMUM FORWARD PRUNING WIDTHS    *    05651000
C       *         (ALSO THE DEFAULTS IF TIMING IS NOT IN EFFECT)   *    05652000
C       *         FOR THE PROGRAM TO USE. 'SW2' SETS THE MAXIMUM   *    05653000
C       *         VALUES THE WIDTHS MAY BE ADJUSTED TO WHEN USING  *    05654000
C       *         THE CLOCK TO CONTROL SEARCH TIME.                *    05655000
C       *     3)  'S1' CHECK RE-ORDERING LEVEL.  THIS IS THE LIMIT *    05656000
C       *         BELOW WHICH ALL CHECKING MOVES ARE EXAMINED.     *    05657000
C       *         AFTER  MOVE GENERATION, THE MOVE LIST IS RE-     *    05658000
C       *         ORDERED ACCORDING TO NORMAL RULES AND FORWARD    *    05659000
C       *         PRUNING IS DONE.  IF BELOW THE CHECK RE-ORDERING *    05660000
C       *         LEVEL, ALL CHECKING MOVES THAT WERE FORWARD      *    05661000
C       *         PRUNED ARE MOVED UP AND THE WIDTH IS INCREASED   *    05662000
C       *         TO INCLUDE THEM AS WELL.  THIS WILL HELP THE     *    05663000
C       *         PROGRAM FIND MATES AND AVOID THEM AS WELL.       *    05664000
C       *     4)  'S2' CAPTURE RE-ORDERING LEVEL.  THIS IS THE     *    05665000
C       *         LIMIT BELOW WHICH ALL CAPTURES WILL BE EXAMINED, *    05666000
C       *         EVEN IF THE CAPTURE IS A SACRIFICE OR LOSS.      *    05667000
C       *                                                          *    05668000
C       ************************************************************    05669000
C                                                                       05670000
      IMPLICIT INTEGER*4 (A-Z)                                          05671000
      COMMON /BUFFER/ TEXT(30)                                          05672000
      COMMON /PRUNE/ WIDTH(10), MIN(10), MAX(10),                       05673000
     * DEPTH, ORDER1, ORDER2                                            05674000
      COMMON /CHRSET/ ALPHA(44)                                         05675000
      EQUIVALENCE (D,ALPHA(4)),(W,ALPHA(23)),                           05676000
     *(ONE,ALPHA(28)),(TWO,ALPHA(29)),(QUEST,ALPHA(43))                 05677000
      IF(TEXT(2).EQ.ONE) GO TO 13                                       05678000
      IF(TEXT(2).EQ.TWO) GO TO 55                                       05679000
      IF(TEXT(2).EQ.W) GO TO 3                                          05680000
      IF(TEXT(2).EQ.QUEST) GO TO 17                                     05681000
      IF(TEXT(2).NE.D) RETURN 1                                         05682000
C                                                                       05683000
C------------------------------< SD : SET MAXIMUM LOOK-AHEAD DEPTH      05684000
C                                                                       05685000
      WRITE(6,1)DEPTH                                                   05686000
1     FORMAT(1X,'MAXIMUM LOOK AHEAD IS NOW ',I2)                        05687000
      IF(TEXT(3).EQ.D) GO TO 999                                        05688000
105   WRITE(6,12)                                                       05689000
      CALL INPUT(DEP)                                                   05690000
      IF(DEP.EQ.0) GO TO 999                                            05691000
      IF(DEP.LT.2.OR.DEP.GT.10) GO TO 201                               05692000
      DEPTH=DEP                                                         05693000
      GO TO 999                                                         05694000
201   WRITE(6,202)                                                      05695000
202   FORMAT(1X,'LEGAL RANGE IS 2-10')                                  05696000
      GO TO 105                                                         05697000
12    FORMAT(1X,'ENTER MAXIMUM LOOK-AHEAD (PLY) ')                      05698000
C                                                                       05699000
C------------------------------< SW : SET SEARCH WIDTH LIMITS           05700000
C                                                                       05701000
3     IF(TEXT(3).EQ.TWO) GO TO 100                                      05702000
      IF(TEXT(3).EQ.D) GO TO 10                                         05703000
      I=1                                                               05704000
4     WRITE(6,5)I                                                       05705000
5     FORMAT(1X,'ENTER DEFAULT WIDTH FOR PLY ',I2)                      05706000
6     CALL INPUT(WT)                                                    05707000
      IF(WT.EQ.0)  GO TO 8                                              05708000
      WIDTH(I)=WT                                                       05709000
      MIN(I)=WT                                                         05710000
      I=I+1                                                             05711000
      IF(I.LT.DEPTH) GO TO 4                                            05712000
      GO TO 10                                                          05713000
8     IF(I.EQ.1) GO TO 10                                               05714000
      DO 9   J=I,10                                                     05715000
          WIDTH(J)=WIDTH(I-1)                                           05716000
          MIN(J)=MIN(J-1)                                               05717000
9     CONTINUE                                                          05718000
      GO TO 10                                                          05719000
100   I=1                                                               05720000
400   WRITE(6,500)I                                                     05721000
500   FORMAT(1X,'ENTER MAXIMUM WIDTH FOR PLY ',I2)                      05722000
600   CALL INPUT(WT)                                                    05723000
      IF(WT.EQ.0)  GO TO 800                                            05724000
      MAX(I)=WT                                                         05725000
      I=I+1                                                             05726000
      IF(I.LT.DEPTH) GO TO 400                                          05727000
      GO TO 10                                                          05728000
800   IF(I.EQ.1) GO TO 10                                               05729000
      DO 900   J=I,10                                                   05730000
          MAX(J)=MAX(I-1)                                               05731000
900   CONTINUE                                                          05732000
10    LIMIT=DEPTH-1                                                     05733000
      WRITE(6,11)(I,MIN(I),WIDTH(I),MAX(I),I=1,LIMIT)                   05734000
      WRITE(6,111)DEPTH                                                 05735000
111   FORMAT(1X,I2,3X,' 1',5X,'??',4X,'99')                             05736000
      GO TO 999                                                         05737000
11    FORMAT(1X,'PLY',2X,'MIN',2X,'WIDTH',2X,'MAX'/(1X,I2,2X,I3         05738000
     *,4X,I3,3X,I3))                                                    05739000
C                                                                       05740000
C------------------------------< S1 : SET CHECK REORDERING LEVEL        05741000
C                                                                       05742000
13    WRITE(6,14)ORDER1                                                 05743000
14    FORMAT(1X,'CHECK REORDERING LEVEL IS ',I2)                        05744000
      IF(TEXT(3).EQ.D) GO TO 999                                        05745000
      WRITE(6,151)                                                      05746000
15    CALL INPUT(ORDER1)                                                05747000
      IF(ORDER1.GE.0.AND.ORDER1.LE.DEPTH) GO TO 999                     05748000
      WRITE(6,16)DEPTH                                                  05749000
16    FORMAT(1X,'LEGAL RANGE IS 0-',I2)                                 05750000
151   FORMAT(1X,'ENTER PLAUSIBILITY REORDERING LEVEL')                  05751000
      GO TO 15                                                          05752000
C                                                                       05753000
C------------------------------< S2 : SET CAPTURE REORDERING LEVEL      05754000
C                                                                       05755000
55    WRITE(6,141)ORDER2                                                05756000
141   FORMAT(1X,'CAPTURE REORDERING LEVEL IS ',I2)                      05757000
      IF(TEXT(3).EQ.D) GO TO 999                                        05758000
      WRITE(6,151)                                                      05759000
56    CALL INPUT(ORDER2)                                                05760000
      IF(ORDER2.GE.0.AND.ORDER2.LE.DEPTH) GO TO 999                     05761000
      WRITE(6,16)DEPTH                                                  05762000
      GO TO 56                                                          05763000
C                                                                       05764000
C------------------------------< S? : PRUNE CONTROL HELP                05765000
C                                                                       05766000
17    WRITE(6,18)                                                       05767000
18    FORMAT(                                                           05768000
     *1X,'SD : SET MAXIMUM LOOK AHEAD (IN PLY)'/                        05769000
     *1X,'SW : SET FORWARD PRUNING WIDTHS'/                             05770000
     *1X,'SW1: SET DEFAULT/MINIMUM WIDTHS'/                             05771000
     *1X,'SW2: SET MAXIMUM WIDTHS'/                                     05772000
     *1X,'S1 : SET MAX LEVEL TO INCLUDE ALL CHECKS'/                    05773000
     *1X,'S2 : SET MAX LEVEL TO INCLUDE ALL UNSAFE CAPTURES'/           05774000
     *)                                                                 05775000
999   RETURN                                                            05776000
      END                                                               05777000
      SUBROUTINE SCORE                                                  05778000
C                                                                       05779000
C       ************************************************************    05780000
C       *                                                          *    05781000
C       *      THIS SUBROUTINE PERFORMS ALL PLAUSIBLITY SCORING    *    05782000
C       *  FOR MOVES AS THEY ARE GENERATED.  AFTER CALLING THE     *    05783000
C       *  APPROPRIATE SCORING MODULE, OTHER PLAUSIBILITY ANALYSIS *    05784000
C       *  IS CARRIED OUT IF THIS IS A PIECE MOVE. INDIVIDUAL      *    05785000
C       *  SCORING ALGORITHMS AND CALLS ARE EXPLAINED BELOW.       *    05786000
C       *                                                          *    05787000
C       ************************************************************    05788000
C                                                                       05789000
      IMPLICIT INTEGER*4 (A-Z)                                          05790000
      COMMON /BOARD/ BOARD(120)                                         05791000
      COMMON /TREE/ TREE(400),START(10),STOP(10),WHICH(10),BACKUP(10),  05792000
     *FROM(10),TO(10),VALUE(10),TYPE(10),PLY                            05793000
      COMMON /INFO/ TYPE8, VALUE8, TO8, FROM8                           05794000
      EQUIVALENCE (RVAL,VALUE8)                                         05795000
      COMMON / MOVE CM / FROMSQ, TOSQ, SIDE                             05796000
      COMMON /K LOC CM/ CKINGL, HKINGL                                  05797000
      COMMON /B LOC CM/ ONECBP, ONEHBP                                  05798000
      COMMON /P SM/ PADVNC, PPAWN, IPAWN, DPAWN, TPAWN, CPAWN,          05799000
     * ABREST, PPSHSC                                                   05800000
      COMMON /B SM/ EBMOVE, LDIAG, BPAIR                                05801000
      COMMON /GEN SM/ ATAK SC, BPAWN, BLKSC, TEMPO                      05802000
      LOGICAL ONECBP, ONEHBP, SIDE, ISOLAT                              05803000
      COMMON /PIEC CM/ PVALUE(13),  PINIT(13)                           05804000
      COMMON /PRUNE/ WIDTH(10), MIN(10), MAX(10),                       05805000
     * DEPTH, ORDER1, ORDER2                                            05806000
      COMMON /TYPES/ NORMAL,CASTRT,CASTLF,ENPASS,PROMOT                 05807000
      COMMON /PHASE/ OPEN, MIDDLE, END                                  05808000
      LOGICAL OPEN, MIDDLE, END                                         05809000
C                                                                       05810000
C------------------------------< DETERMINE PAWN VALUES                  05811000
C                                                                       05812000
      FPAWN=1                                                           05813000
      EPAWN=8                                                           05814000
      IF(SIDE) GO TO 131                                                05815000
      FPAWN=8                                                           05816000
      EPAWN=1                                                           05817000
131   CONTINUE                                                          05818000
C                                                                       05819000
C==============================< SCORE IS DEFINED AS THE VALUE OF       05820000
C==============================< THE SQUARE WE'RE MOVING TO MINUS       05821000
C==============================< THE SQUARE WE'RE MOVING FROM           05822000
C                                                                       05823000
      GO TO (10,20,30,40,50,60,9999,10,20,30,40,50,60,9999),FROMSQ      05824000
10    VALUE8=PSCORE(TO8,SIDE)                                           05825000
      IF(.NOT.END) VALUE8=VALUE8+EXPOSE(SIDE)                           05826000
C                                                                       05827000
C----------------------< CHECK TO SEE IF CAPTURING WITH THIS            05828000
C----------------------< PAWN CAUSES A FRIENDLY PAWN TO                 05829000
C----------------------< BECOME 'UN-ISOLATED'. IF SO, ADD               05830000
C----------------------< A BONUS TO THE SCORE.                          05831000
C                                                                       05832000
      IF(TOSQ.EQ.7) GO TO 16                                            05833000
      FILE=IABS(FROM8-TO8)-10                                           05834000
      IF(.NOT.SIDE) FILE=-FILE                                          05835000
13    FILEST=MOD(TO8-FILE,10)+30                                        05836000
      FILEND=FILEST+50                                                  05837000
      DO 14 SQ=FILEST,FILEND,10                                         05838000
          IF(BOARD(SQ).EQ.FPAWN)  GO TO 15                              05839000
14    CONTINUE                                                          05840000
      GO TO 155                                                         05841000
15    BOARD(TO8)=7                                                      05842000
      IF(ISOLAT(SQ,SIDE)) VALUE8=VALUE8+IPAWN                           05843000
      BOARD(TO8)=FROMSQ                                                 05844000
      IF(TYPE8.EQ.PROMOT) BOARD(TO8)=FROMSQ+4                           05845000
155   CONTINUE                                                          05846000
C                                                                       05847000
C----------------------< CHECK TO SEE IF CAPTURING WITH THIS            05848000
C----------------------< PAWN ALSO CAUSES A FREINDLY PAWN TO            05849000
C----------------------< BECOME ISOLATED. IF SO, PENALIZE THE           05850000
C----------------------< SCORE.                                         05851000
C                                                                       05852000
      FILEST=MOD(FROM8+FILE,10)+30                                      05853000
      FILEND=FILEST+50                                                  05854000
      DO 11 SQ=FILEST,FILEND,10                                         05855000
          IF(BOARD(SQ).EQ.FPAWN)  GO TO 12                              05856000
11    CONTINUE                                                          05857000
      GO TO 175                                                         05858000
12    IF(ISOLAT(SQ,SIDE)) VALUE8=VALUE8-IPAWN                           05859000
175   CONTINUE                                                          05860000
C                                                                       05861000
C----------------------< ADD A BONUS TO THE SCORE FOR ATTACKING         05862000
C----------------------< A PIECE SINCE IT WILL MOST LIKELY HAVE         05863000
C----------------------< TO MOVE AWAY.                                  05864000
C                                                                       05865000
16    VALUE8=VALUE8+PATACK(TO8,SIDE)                                    05866000
      GO TO 99                                                          05867000
20    VALUE8=NSCORE(TO8,SIDE)                                           05868000
      GO TO 70                                                          05869000
30    VALUE8=BSCORE(TO8,SIDE)                                           05870000
      GO TO 70                                                          05871000
40    VALUE8=RSCORE(TO8,SIDE)                                           05872000
      GO TO 70                                                          05873000
50    VALUE8=QSCORE(TO8,SIDE)                                           05874000
      GO TO 70                                                          05875000
60    VALUE8=KSCORE(TO8,SIDE)                                           05876000
70    IF(OPEN) GO TO 99                                                 05877000
      VALUE8=VALUE8+BLOCK(TO8,SIDE)                                     05878000
C                                                                       05879000
C==============================< SUBTRACT VALUE OF SQUARE THIS MOVE     05880000
C==============================< IS VACATING.                           05881000
C                                                                       05882000
99    BOARD(TO8)=TOSQ                                                   05883000
      BOARD(FROM8)=FROMSQ                                               05884000
      GO TO (101,201,301,401,501,601,9999,                              05885000
     *       101,201,301,401,501,601,9999),FROMSQ                       05886000
101   VALUE8=VALUE8-PSCORE(FROM8,SIDE)                                  05887000
      IF(END) GO TO 999                                                 05888000
      VALUE8=VALUE8-EXPOSE(SIDE)                                        05889000
      GO TO 999                                                         05890000
201   VALUE8=VALUE8-NSCORE(FROM8,SIDE)                                  05891000
      GO TO 701                                                         05892000
301   VALUE8=VALUE8-BSCORE(FROM8,SIDE)                                  05893000
      GO TO 701                                                         05894000
401   VALUE8=VALUE8-RSCORE(FROM8,SIDE)                                  05895000
      GO TO 701                                                         05896000
501   VALUE8=VALUE8-QSCORE(FROM8,SIDE)                                  05897000
      GO TO 701                                                         05898000
601   VALUE8=VALUE8-KSCORE(FROM8,SIDE)                                  05899000
701   IF(OPEN) GO TO 999                                                05900000
      VALUE8=VALUE8-BLOCK(FROM8,SIDE)                                   05901000
999   BOARD(TO8)=FROMSQ                                                 05902000
      BOARD(FROM8)=7                                                    05903000
      IF(TYPE8.EQ.PROMOT) BOARD(TO8)=FROMSQ+4                           05904000
C                                                                       05905000
C                                                                       05906000
C----------------------< IF MOVING A PIECE BACK TO WHERE                05907000
C----------------------< IT WAS EARLIER IN THE TREE, THEN               05908000
C----------------------< PENALIZE THE MOVES'S SCORE                     05909000
C                                                                       05910000
1000  IF(PLY.LE.2) GO TO 1010                                           05911000
      IF(END) GO TO 1010                                                05912000
      ST=2-MOD(PLY,2)                                                   05913000
      EN=PLY-2                                                          05914000
      DO 1020 I=ST,EN,2                                                 05915000
          IF(TO8.EQ.FROM(I).AND.FROM8.EQ.TO(I)) GO TO 1030              05916000
1020  CONTINUE                                                          05917000
      GO TO 1010                                                        05918000
1030  VALUE8=VALUE8-TEMPO                                               05919000
C                                                                       05920000
C                                                                       05921000
C==============================< ADD IN THE TACTICAL SCORE FOR THE      05922000
C==============================< PIECE WE ARE CAPTURING (IF ANY)        05923000
C                                                                       05924000
1010  GO TO (100,200,300,400,500,600,9999,                              05925000
     *       100,200,300,400,500,600,9999),TOSQ                         05926000
100   VALUE8=VALUE8+PVALUE(TOSQ)+PSCORE(TO8,.NOT.SIDE)                  05927000
      FILE=MOD(TO8,10)-1                                                05928000
C                                                                       05929000
C----------------------< ADD A BONUS TO THE SCORE IF CAPTURING          05930000
C----------------------< A PAWN WHICH IS ATTACKING A PIECE.             05931000
C                                                                       05932000
      VALUE8=VALUE8+PATACK(TO8,.NOT.SIDE)                               05933000
C                                                                       05934000
C----------------------< SEE IF CAPTURING THIS ENEMY PAWN               05935000
C----------------------< HAS CREATED A PASSED PAWN ON THIS              05936000
C----------------------< OR AN ADJACENT FILE. IF SO, ADJUST             05937000
C----------------------< THE SCORE TO REFLECT THIS.                     05938000
C                                                                       05939000
      DIR=-1                                                            05940000
      IF(SIDE) DIR=1                                                    05941000
130   L1=TO8-1                                                          05942000
      L2=TO8+1                                                          05943000
      DO 160 FILE=L1,L2                                                 05944000
          SQ=FILE                                                       05945000
140       SQ=SQ+DIR*10                                                  05946000
          IF(BOARD(SQ).EQ.FPAWN) GO TO 150                              05947000
          IF(BOARD(SQ).NE.14) GO TO 140                                 05948000
          GO TO 160                                                     05949000
150       VALUE8=VALUE8+PASSED(SQ,SIDE)                                 05950000
160   CONTINUE                                                          05951000
C                                                                       05952000
C----------------------< DETERMINE IF CAPTURING THIS PAWN               05953000
C----------------------< WILL RESULT IN THE SIDE NOT TO MOVE            05954000
C----------------------< HAVING AN ISOLATED PAWN. IF SO, ADD            05955000
C----------------------< A BONUS TO THE SCORE.                          05956000
C                                                                       05957000
      SQTO=TO8-1                                                        05958000
165   FILEST=MOD(SQTO,10)+30                                            05959000
      FILEND=FILEST+50                                                  05960000
      DO 170 SQ=FILEST,FILEND,10                                        05961000
          IF(BOARD(SQ).EQ.EPAWN) GO TO 180                              05962000
170   CONTINUE                                                          05963000
      GO TO 190                                                         05964000
180   IF(ISOLAT(SQ,.NOT.SIDE)) VALUE8=VALUE8+IPAWN                      05965000
190   SQTO=SQTO+2                                                       05966000
      IF(SQTO.EQ.TO8+1) GO TO 165                                       05967000
      GO TO 9999                                                        05968000
200   VALUE8=VALUE8+PVALUE(TOSQ)+NSCORE(TO8,.NOT.SIDE)                  05969000
      GO TO 9999                                                        05970000
300   VALUE8=VALUE8+PVALUE(TOSQ)+BSCORE(TO8,.NOT.SIDE)                  05971000
C                                                                       05972000
C----------------------< IF CAPTURING ONE OF A PAIR OF BISHOPS          05973000
C----------------------< ADD A BONUS FOR ELIMINATING THIS               05974000
C----------------------< STRATEGIC ADVANTAGE                            05975000
C                                                                       05976000
      IF(SIDE) GO TO 305                                                05977000
      IF(.NOT. ONEHBP) VALUE8=VALUE8+BPAIR                              05978000
      GO TO 9999                                                        05979000
305   IF(.NOT. ONECBP) VALUE8=VALUE8+BPAIR                              05980000
      GO TO 9999                                                        05981000
400   VALUE8=VALUE8+PVALUE(TOSQ)+RSCORE(TO8,.NOT.SIDE)                  05982000
      GO TO 9999                                                        05983000
500   VALUE8=VALUE8+PVALUE(TOSQ)+QSCORE(TO8,.NOT.SIDE)                  05984000
      GO TO 9999                                                        05985000
600   CONTINUE                                                          05986000
9999  RETURN                                                            05987000
      END                                                               05988000
$CONTROL SEGMENT=SET                                                    05989000
      SUBROUTINE SETBBD                                                 05990000
C                                                                       05991000
C       ************************************************************    05992000
C       *                                                          *    05993000
C       *      SETBBD IS USED TO SET THE BISHOP CONTROL BOARDS IN  *    05994000
C       *  COMMON BLOCK 'B BD SM'.  THE BOARD IS SET UP EITHER     *    05995000
C       *  AROUND THE CENTER OR AROUND THE OPPONENT'S KING BASED   *    05996000
C       *  ON WHETHER OR NOT THE OPENING IS COMPLETE.  THE         *    05997000
C       *  FOLLOWING SCORING CONSIDERATIONS ARE INCLUDED IN THE    *    05998000
C       *  CONTROL BOARD:                                          *    05999000
C       *     1)  THE SQUARES IN FRONT OF UNMOVED CENTER PAWNS ARE *    06000000
C       *         GIVEN PENALTIES TO PREVENT BLOCKING THEM IN.     *    06001000
C       *     2)  A BONUS IS GIVEN TO EJECT THE BISHOPS FROM THE   *    06002000
C       *         BACK ROW IN THE OPENING OF THE GAME.             *    06003000
C       *                                                          *    06004000
C       ************************************************************    06005000
C                                                                       06006000
      IMPLICIT INTEGER*4 (A-Z)                                          06007000
      COMMON /PHASE/ OPEN, MIDDLE, END                                  06008000
      LOGICAL OPEN, MIDDLE, END                                         06009000
      COMMON /BOARD/ BOARD(120)                                         06010000
      COMMON /B BD SM/ CBSCOR(100), HBSCOR(100)                         06011000
      COMMON /K LOC CM/ CKINGL, HKINGL                                  06012000
      COMMON /CAST CM/  CKINGM,CROOKR,CROOKL,HKINGM,HROOKR,HROOKL       06013000
      LOGICAL CKINGM, CROOKR, CROOKL, HKINGM, HROOKR, HROOKL            06014000
      COMMON /CAST SM/ CAST SC, UB CAST                                 06015000
      COMMON /B SM/ EBMOVE, LDIAG, BPAIR                                06016000
      COMMON /GEN SM/ ATAK SC, BPAWN, BLKSC, TEMPO                      06017000
      COMMON /DEV STS/ CDONE, HDONE                                     06018000
      LOGICAL CDONE, HDONE                                              06019000
      LOGICAL LEFT, RIGHT                                               06020000
C                                                                       06021000
C------------------------------< ADJUST THE CONTROL BOARD TO PREVENT    06022000
C------------------------------< POSTING A BISHOP IN FRONT OF CENTER    06023000
C------------------------------< PAWNS THAT HAVEN'T BEEN MOVED.         06024000
C                                                                       06025000
      IF(.NOT. OPEN) GO TO 50                                           06026000
      IF(BOARD(35).EQ.8) CBSCOR(45)=CBSCOR(45)-BPAWN                    06027000
      IF(BOARD(36).EQ.8) CBSCOR(46)=CBSCOR(46)-BPAWN                    06028000
      IF(BOARD(35).EQ.8.OR.BOARD(45).EQ.8)                              06029000
     *                   CBSCOR(55)=CBSCOR(55)-BPAWN                    06030000
      IF(BOARD(36).EQ.8.OR.BOARD(46).EQ.8)                              06031000
     *                   CBSCOR(56)=CBSCOR(56)-BPAWN                    06032000
      IF(BOARD(85).EQ.1) HBSCOR(75)=HBSCOR(75)-BPAWN                    06033000
      IF(BOARD(86).EQ.1) HBSCOR(76)=HBSCOR(76)-BPAWN                    06034000
      IF(BOARD(85).EQ.1.OR.BOARD(75).EQ.1)                              06035000
     *                   HBSCOR(65)=HBSCOR(65)-BPAWN                    06036000
      IF(BOARD(86).EQ.1.OR.BOARD(76).EQ.1)                              06037000
     *                   HBSCOR(66)=HBSCOR(66)-BPAWN                    06038000
50    CONTINUE                                                          06039000
C                                                                       06040000
C------------------------------< IF IN THE OPENING, ADJUST THE CONTROL  06041000
C------------------------------< BOARD TO FORCE BISHOPS OFF OF THE      06042000
C------------------------------< BACK RANK (DEVELOP)                    06043000
C                                                                       06044000
      IF(CDONE) GO TO 100                                               06045000
      CBSCOR(24)=CBSCOR(24)+EBMOVE                                      06046000
      CBSCOR(27)=CBSCOR(27)+EBMOVE                                      06047000
100   CONTINUE                                                          06048000
      IF(CKINGM) GO TO 300                                              06049000
      IF(CROOKR) GO TO 200                                              06050000
      CBSCOR(24)=CBSCOR(24)+UB CAST                                     06051000
200   IF(CROOKL) GO TO 300                                              06052000
      CBSCOR(27)=CBSCOR(27)+UB CAST                                     06053000
300   CONTINUE                                                          06054000
      IF(HDONE) GO TO 400                                               06055000
      HBSCOR(94)=HBSCOR(94)+EBMOVE                                      06056000
      HBSCOR(97)=HBSCOR(97)+EBMOVE                                      06057000
400   CONTINUE                                                          06058000
      IF(HKINGM) GO TO 600                                              06059000
      IF(HROOKR) GO TO 500                                              06060000
      HBSCOR(97)=HBSCOR(97)+UB CAST                                     06061000
500   IF(HROOKL) GO TO 600                                              06062000
      HBSCOR(94)=HBSCOR(94)+UB CAST                                     06063000
600   CONTINUE                                                          06064000
      RETURN                                                            06065000
      END                                                               06066000
$CONTROL SEGMENT=SET                                                    06067000
      SUBROUTINE SETBRD                                                 06068000
C                                                                       06069000
C       ************************************************************    06070000
C       *                                                          *    06071000
C       *      SETBRD IS USED TO SET UP THE BOARD IN ANY POSITION  *    06072000
C       *  DESIRED.  IT USES A FORSYTHE LIKE STRING OF CHARACTERS  *    06073000
C       *  TO DESCRIBE THE BOARD POSITION.  THE BOARD SQUARES      *    06074000
C       *  ARE NUMBERED AS FOLLOWS:                                *    06075000
C       *                                                          *    06076000
C       *          1  2  3  4  5  6  7  8                          *    06077000
C       *          9 10 11 12 13 14 15 16                          *    06078000
C       *         17 18 19 20 21 22 23 24                          *    06079000
C       *         25 26 27 28 29 30 31 32                          *    06080000
C       *         33 34 35 36 37 38 39 40                          *    06081000
C       *         41 42 43 44 45 46 47 48                          *    06082000
C       *         49 50 51 52 53 54 55 56                          *    06083000
C       *         57 58 59 60 61 62 63 64                          *    06084000
C       *                                                          *    06085000
C       *      USING STANDARD PIECE CODES, SIMPLY TYPE IN THE      *    06086000
C       *  CODE FOR THE PIECE YOU WISH TO PLACE THERE STARTING     *    06087000
C       *  WITH COMPUTER PIECES.  USE A NUMBER BETWEEN 1 AND 8 TO  *    06088000
C       *  INDICATE EMPTY SQUARES.  WHEN ALL COMPUTER PIECES ARE   *    06089000
C       *  DEFINED, TYPE A '.' OR PERIOD IN THE STRING. CONTINUING,*    06090000
C       *  START BACK AT SQUARE 1 AND START DEFINING HUMAN PIECES. *    06091000
C       *  FOR EXAMPLE, 'K2R4PPP.88888Q75PPP7K ' WOULD DEFINE THE  *    06092000
C       *  FOLLOWING BOARD POSITION:                               *    06093000
C       *                                                          *    06094000
C       *          CK  *  * CR  *  *  *  *                         *    06095000
C       *          CP CP CP  *  *  *  *  *                         *    06096000
C       *           *  *  *  *  *  *  *  *                         *    06097000
C       *           *  *  *  *  *  *  *  *                         *    06098000
C       *           *  *  *  *  *  *  *  *                         *    06099000
C       *          HQ  *  *  *  *  *  *  *                         *    06100000
C       *           *  *  *  *  * HP HP HP                         *    06101000
C       *           *  *  *  *  *  *  * HK                         *    06102000
C       *                                                          *    06103000
C       ************************************************************    06104000
C                                                                       06105000
      IMPLICIT INTEGER*4 (A-Z)                                          06106000
      COMMON /K LOC CM/ CKINGL, HKINGL                                  06107000
      COMMON /COLR CM/ CCOLOR, HCOLOR, COLOR                            06108000
      CHARACTER*5 CCOLOR, HCOLOR                                        06109000
      LOGICAL CKINGM,CROOKR,CROOKL,MODIFY,HKINGM,HROOKR,HROOKL          06110000
      COMMON /CAST CM/ CKINGM,CROOKR,CROOKL,HKINGM,HROOKR,HROOKL        06111000
      COMMON /BOARD/ BOARD(120)                                         06112000
      INTEGER*4 CHAR(16), INPUT(72)                                     06113000
      COMMON /TREE/ TREE(400),DMY(81)                                   06114000
      COMMON /V CM/ VCMOVE                                              06115000
      COMMON /BUFFER/ TEXT(30)                                          06116000
      COMMON /CHR SET/ ALPHA(44)                                        06117000
      EQUIVALENCE (O,ALPHA(15))                                         06118000
      EQUIVALENCE (TREE(1), INPUT(1))                                   06119000
      DATA CHAR /%"P"J,%"N"J,%"B"J,%"R"J,%"Q"J,%"K"J,%" "J,             06120000
     *%"."J,%"1"J,%"2"J,%"3"J,%"4"J,%"5"J,%"6"J,%"7"J,%"8"J/            06121000
9999  WRITE(6,6)                                                        06122000
6     FORMAT(1X,'ENTER BOARD POSITION')                                 06123000
      READ(5,5)INPUT                                                    06124000
5     FORMAT(72R1)                                                      06125000
      IF(INPUT(1).EQ.%'  ') GO TO 6000                                  06126000
      CKINGM = .FALSE.                                                  06127000
      HKINGM = .FALSE.                                                  06128000
      CROOKR = .FALSE.                                                  06129000
      CROOKL = .FALSE.                                                  06130000
      HROOKR = .FALSE.                                                  06131000
      HROOKL = .FALSE.                                                  06132000
      MODIFY=.FALSE.                                                    06133000
      IF(TEXT(3).EQ.O) MODIFY=.TRUE.                                    06134000
      IF(MODIFY) GO TO 9                                                06135000
      SQ=21                                                             06136000
      DO 400 I=1,8                                                      06137000
          DO 390 J=1,8                                                  06138000
            SQ=SQ+1                                                     06139000
            BOARD(SQ)=7                                                 06140000
390       CONTINUE                                                      06141000
          SQ=SQ+2                                                       06142000
400   CONTINUE                                                          06143000
9     SQ = 21                                                           06144000
      SIDE = 1                                                          06145000
      DO 110 J = 1, 72                                                  06146000
          DO 100 K = 1, 16                                              06147000
              IF(INPUT(J).EQ.CHAR(K)) GO TO 101                         06148000
100       CONTINUE                                                      06149000
          GO TO 120                                                     06150000
101       IF(K.EQ.7) GO TO 80                                           06151000
          IF(K.EQ.8) GO TO 60                                           06152000
          IF(K.GT.8) GO TO 70                                           06153000
C                                                                       06154000
C--------------------------------------< CHARACTER INDICATES A PIECE    06155000
C                                                                       06156000
50        SQ = SQ + 1                                                   06157000
          IF(MOD(SQ-1,10).GT.8) SQ = SQ + 2                             06158000
          IF (SQ .GT. 99) GO TO 120                                     06159000
          IF (BOARD (SQ) .NE. 7 .AND. .NOT.MODIFY) GO TO 120            06160000
          BOARD (SQ) = K + 7 * SIDE                                     06161000
          GO TO 110                                                     06162000
C                                                                       06163000
C--------------------------------------< PERIOD INDICATES END OF LISTING06164000
C--------------------------------------< OF COMPUTER PIECES             06165000
C                                                                       06166000
60        IF (SQ .GT. 99) GO TO 120                                     06167000
          IF (SIDE .NE. 1) GO TO 120                                    06168000
          SIDE = 0                                                      06169000
          SQ = 21                                                       06170000
          GO TO 110                                                     06171000
C                                                                       06172000
C--------------------------------------< NUMBER INDICATES EMPTY SQUARE(S06173000
C                                                                       06174000
70        LIM = K - 8                                                   06175000
          DO 71 I = 1, LIM                                              06176000
              SQ = SQ + 1                                               06177000
              IF (MOD(SQ-1,10) .GT. 8 .OR. MOD(SQ-1,10) .LT.1)          06178000
     *                  SQ = SQ + 2                                     06179000
71        CONTINUE                                                      06180000
110   CONTINUE                                                          06181000
C                                                                       06182000
C--------------------------------------< BLANK INDICATES END OF         06183000
C--------------------------------------< STRING                         06184000
C                                                                       06185000
80    CKINGL = 0                                                        06186000
      HKINGL = 0                                                        06187000
      SQ = 21                                                           06188000
85    DO 41 L = 1, 8                                                    06189000
          DO 40 L1 = 1, 8                                               06190000
              SQ = SQ + 1                                               06191000
              IF (BOARD (SQ) .EQ. 6) HKINGL = SQ                        06192000
              IF (BOARD (SQ) .EQ. 13) CKINGL = SQ                       06193000
40        CONTINUE                                                      06194000
          SQ = SQ + 2                                                   06195000
41    CONTINUE                                                          06196000
      IF(HKINGL .EQ. 0 .OR. CKINGL .EQ. 0) GO TO 140                    06197000
      IF(COLOR.EQ.0) GO TO 6200                                         06198000
      IF(BOARD(25).NE.13) CKINGM=.TRUE.                                 06199000
      IF(BOARD(95).NE.6)  HKINGM=.TRUE.                                 06200000
      GO TO 6300                                                        06201000
6200  IF(BOARD(26).NE.13) CKINGM=.TRUE.                                 06202000
      IF(BOARD(96).NE.6) HKINGM=.TRUE.                                  06203000
6300  CONTINUE                                                          06204000
      IF (BOARD (22) .NE. 11) CROOKR = .TRUE.                           06205000
      IF (BOARD (29) .NE. 11) CROOKL = .TRUE.                           06206000
      IF (BOARD (92) .NE. 4) HROOKL = .TRUE.                            06207000
      IF (BOARD (99) .NE. 4) HROOKR = .TRUE.                            06208000
      VCMOVE=0                                                          06209000
6000  RETURN                                                            06210000
C                                                                       06211000
C--------------------------------------< INPUT ERROR                    06212000
C                                                                       06213000
120   WRITE(6,130)                                                      06214000
130   FORMAT (1X,'INPUT ERROR, TRY AGAIN')                              06215000
      GO TO 9999                                                        06216000
140   WRITE(6,150)                                                      06217000
150   FORMAT (1X,'EACH SIDE MUST HAVE 1 KING (K)')                      06218000
      GO TO 9999                                                        06219000
      END                                                               06220000
$CONTROL SEGMENT=SET                                                    06221000
      SUBROUTINE SETCLK                                                 06222000
C                                                                       06223000
C       ************************************************************    06224000
C       *                                                          *    06225000
C       *      THIS SUBROUTINE IS USED TO RESET THE CHESS CLOCK    *    06226000
C       *  AFTER THE INITIAL NUMBER OF MOVES HAVE BEEN MADE.  FOR  *    06227000
C       *  EXAMPLE, FOR 40 MOVES IN 2 HOURS AND 10 MOVES EACH 1/2  *    06228000
C       *  HOUR AFTER THAT, THE CLOCK IS SET TO 30 MINUTES EACH    *    06229000
C       *  AFTER THE FIRST 40 MOVES HAVE BEEN MADE AND IS RESET TO *    06230000
C       *  30 AFTER EACH SUCCEEDING 10 MOVES ARE MADE.             *    06231000
C       *                                                          *    06232000
C       ************************************************************    06233000
C                                                                       06234000
      IMPLICIT INTEGER*4 (A-Z)                                          06235000
      COMMON /CLOK CM/ CLOCK,CTYPE,CQUERY,GELAP,CELAP,HELAP,            06236000
     *ELAPC,ELAPH,MOVES,SMOVES,SELAP,CTOTAL,HTOTAL,OPTIME               06237000
      COMMON /MOV CNT/ NCMOVS, NHMOVS                                   06238000
      LOGICAL CLOCK, CQUERY                                             06239000
C------------------------------< IF NOT AT THE PRESET TIME LIMIT,       06240000
C------------------------------< RETURN WITHOUT RESETTING THE CLOCKS.   06241000
C                                                                       06242000
      IF(NHMOVS+NCMOVS.LT.2*MOVES) GO TO 100                            06243000
      MOVES=MOVES+SMOVES                                                06244000
      GELAP=SELAP                                                       06245000
      CTOTAL=CTOTAL+CELAP                                               06246000
      HTOTAL=HTOTAL+HELAP                                               06247000
      CELAP=0                                                           06248000
      HELAP=0                                                           06249000
100   RETURN                                                            06250000
      END                                                               06251000
$CONTROL SEGMENT=SET                                                    06252000
      SUBROUTINE SETGB                                                  06253000
C                                                                       06254000
C       ************************************************************    06255000
C       *                                                          *    06256000
C       *      SETGB IS USED TO SET THE GAME BOARD TO IT'S INITIAL *    06257000
C       *  POSITION.   CASTLING STATUS IS SET FOR THE START OF THE *    06258000
C       *  GAME ALSO.                                              *    06259000
C       *                                                          *    06260000
C       ************************************************************    06261000
C                                                                       06262000
      IMPLICIT INTEGER*4 (A-Z)                                          06263000
      COMMON /BOARD/ BOARD(120)                                         06264000
      COMMON /CAST CM/ CKINGM,CROOKR,CROOKL,HKINGM,HROOKR,HROOKL        06265000
      LOGICAL CKINGM, CROOKR, CROOKL, HKINGM, HROOKR, HROOKL            06266000
      COMMON /COLR CM/ CCOLOR, HCOLOR, COLOR                            06267000
      CHARACTER*5 CCOLOR, HCOLOR                                        06268000
      INTEGER*4 HP(8),CP(8)                                             06269000
      DATA HP/4J,2J,3J,5J,6J,3J,2J,4J/,CP/11J,9J,10J,12J,               06270000
     *13J,10J,9J,11J/                                                   06271000
C                                                                       06272000
C------------------------------< CLEAR THE BOARD                        06273000
C                                                                       06274000
      DO 11 I=4,7                                                       06275000
          DO 10 J=2,9                                                   06276000
              BOARD(I*10+J)=7                                           06277000
10        CONTINUE                                                      06278000
11    CONTINUE                                                          06279000
C                                                                       06280000
C------------------------------< SET PIECES AND PAWNS                   06281000
C                                                                       06282000
      DO 20 I=2,9                                                       06283000
          BOARD(20+I)=CP(I-1)                                           06284000
          BOARD(30+I)=8                                                 06285000
          BOARD(80+I)=1                                                 06286000
          BOARD(90+I)=HP(I-1)                                           06287000
20    CONTINUE                                                          06288000
C                                                                       06289000
C------------------------------< IF PROGRAM IS BLACK, THE KING AND      06290000
C------------------------------< QUEEN MUST BE REVERSED.                06291000
C                                                                       06292000
      IF(COLOR.EQ.0) GO TO 30                                           06293000
      BOARD(25)=13                                                      06294000
      BOARD(26)=12                                                      06295000
      BOARD(95)=6                                                       06296000
      BOARD(96)=5                                                       06297000
C                                                                       06298000
C------------------------------< INITIALIZE CASTLING STATUS             06299000
C                                                                       06300000
30    CKINGM=.FALSE.                                                    06301000
      CROOKR=.FALSE.                                                    06302000
      CROOKL=.FALSE.                                                    06303000
      HKINGM=.FALSE.                                                    06304000
      HROOKR=.FALSE.                                                    06305000
      HROOKL=.FALSE.                                                    06306000
      RETURN                                                            06307000
      END                                                               06308000
      SUBROUTINE SETIO(AUTO,*)                                          06309000
C                                                                       06310000
C       ************************************************************    06311000
C       *                                                          *    06312000
C       *      SETIO IS USED TO OPEN DCB'S F:1 AND F:2 FOR FORTRAN *    06313000
C       *  I/O UNITS 1 AND 2 TO SPECIFIC FILES.  THE FILE NAMES    *    06314000
C       *  ARE BASED ON THE PLAYER'S NAME.  THE FILES ARE OPENED   *    06315000
C       *  OUT FIRST TO CREATE THEM FOLLOWED BY INOUT TO BE ABLE   *    06316000
C       *  TO UPDATE THEM.  IF RESTARTING A GAME, INOUT IS USED    *    06317000
C       *  SO AS NOT TO DELETE THE STATUS OF THE GAME THAT IS      *    06318000
C       *  BEING RESTARTED.                                        *    06319000
C       *      'SAVEGM' IS AN ENTRY POINT USED TO SAVE THE GAME    *    06320000
C       *  STATUS AFTER EACH MOVE SO THAT THE GAME MAY BE RE-      *    06321000
C       *  STARTED IF COMMUNICATION IS LOST OF THE SYSTEM HAS      *    06322000
C       *  SOME TYPE OF MALFUNCTION.                               *    06323000
C       *                                                          *    06324000
C       ************************************************************    06325000
C                                                                       06326000
      IMPLICIT INTEGER*4 (A-Z)                                          06327000
      SYSTEM INTRINSIC COMMAND                                          06328000
      CHARACTER*24 BFFR, CNAME*6, BFR1*36, BFR2*16, ANAME*6             06329000
      INTEGER*2 IERR, IPARM, IERR1, IPARM1, IERR2, IPARM2               06330000
      EQUIVALENCE (NAME(1),ANAME)                                       06331000
      COMMON /NAME CM/ NAME(5)                                          06332000
      LOGICAL AUTO, TAUTO, BLNK                                         06333000
      DATA IERR/0/,IPARM/0/,IERR1/0/,IPARM1/0/,IERR2/0/,                06334000
     *IPARM2/0/                                                         06335000
      BFFR="BUILD X1      ;DISC=600"                                    06336000
      BFR1="FILE FTN01=X1      ,OLD;ACC=UPDATE"                         06337000
      BFR2="PURGE X1      "                                             06338000
      BFFR[24:1]=%15C                                                   06339000
      BFR1[36:1]=%15C                                                   06340000
      BFR2[16:1]=%15C                                                   06341000
      DO 1 I=1,6                                                        06342000
      IF(ANAME[I:1].EQ.%40C)BLNK=.TRUE.                                 06343000
      CNAME[I:1]=ANAME[I:1]                                             06344000
      IF(ANAME[I:1].NE.%40C.AND.BLNK)CNAME[I:1]=%40C                    06345000
    1 CONTINUE                                                          06346000
      BFFR[9:6]=CNAME[1:6]                                              06347000
      BFR1[14:6]=CNAME[1:6]                                             06348000
      BFR2[9:6]=CNAME[1:6]                                              06349000
  100 CALL COMMAND(BFFR,IERR,IPARM)                                     06350000
      IF(.CC.)90,200,90                                                 06351000
C     OPEN O.K.-ASSIGN TO FORTRAN UNIT 1                                06352000
  200 CALL COMMAND(BFR1,IERR1,IPARM1)                                   06353000
      IERR=IERR1                                                        06354000
      IPARM=IPARM1                                                      06355000
      IF(.CC.)300,999,300                                               06356000
C     IF ERR 116, FILE EXISTS-RESTART                                   06357000
   90 IF(IERR.EQ.116) GOTO 10                                           06358000
C     SHOULDN'T GET HERE-FILE ERROR!                                    06359000
  300 WRITE(6,40)IERR,IPARM                                             06360000
   40 FORMAT(1X,"FILE SYSTEM ERROR #",I6,1X,"PARM=",I6)                 06361000
      RETURN                                                            06362000
10    WRITE(6,20)NAME                                                   06363000
20    FORMAT(1X,'ARE YOU CONTINUING YOUR LAST GAME, ',5A4)              06364000
      READ(5,30)RESTRT                                                  06365000
30    FORMAT(R1)                                                        06366000
      IF(RESTRT.NE.%'Y'.AND.RESTRT.NE.%'N') GO TO 10                    06367000
      IF(RESTRT.EQ.%"Y")FLAG=1                                          06368000
      IF(RESTRT.EQ.%"Y")GOTO 200                                        06369000
      WRITE(6,60)                                                       06370000
   60 FORMAT(1X,"OLD GAME EXISTS- SHOULD I PURGE?")                     06371000
      READ(5,50)PURGE                                                   06372000
   50 FORMAT(R1)                                                        06373000
      IF(PURGE.EQ.%"N") RETURN 1                                        06374000
C     IF NO, GET NEW NAME.....ELSE PURGE!                               06375000
      CALL COMMAND(BFR2,IERR2,IPARM)                                    06376000
      IF(.CC.)300,100,300                                               06377000
  999 IF(RESTRT.EQ.%"Y")CALL RCMND(FLAG)                                06378000
      IF(RESTRT.EQ.%"Y")AUTO=.TRUE.                                     06379000
      RETURN                                                            06380000
      ENTRY SAVEGM                                                      06381000
      CONTINUE                                                          06382000
      RETURN                                                            06383000
      END                                                               06384000
$CONTROL SEGMENT=SET                                                    06385000
      SUBROUTINE SETKBD                                                 06386000
C                                                                       06387000
C       ************************************************************    06388000
C       *                                                          *    06389000
C       *      SETKBD IS USED TO SET THE KING CONTROL BOARDS IN    *    06390000
C       *  COMMON BLOCK 'K BD SM'.  THE BOARD IS SET UP EITHER     *    06391000
C       *  AROUND THE CENTER OR AROUND THE OPPONENT'S KING BASED   *    06392000
C       *  ON WHETHER OR NOT THE OPENING IS COMPLETE.  THE         *    06393000
C       *  FOLLOWING SCORING CONSIDERATIONS ARE INCLUDED IN THE    *    06394000
C       *  CONTROL BOARD:                                          *    06395000
C       *     1)  IF THE OPPONENT'S QUEEN IS STILL ON THE BOARD,   *    06396000
C       *         THE CONTROL BOARD IS SET UP TO KEEP THE KING BE  *    06397000
C       *         HIND THE PAWNS HE IS CLOSE TO.  THIS KEEPS THE   *    06398000
C       *         KING FROM BEING EXPOSED TO ATTACK.               *    06399000
C       *     2)  IF THE ONE SIDE DOESN'T HAVE A QUEEN, OR THE     *    06400000
C       *         GAME IS IN THE ENDGAME PHASE, THEN THE KINGS     *    06401000
C       *         ARE GIVEN MORE SPECIFIC GOALS.  THAT IS, IF      *    06402000
C       *         PAWNS ARE ONLY ON 1 WING, THEN THE KINGS         *    06403000
C       *         GO IN THAT DIRECTION (TRY TO HEAD THEM OFF/      *    06404000
C       *         ADVANCE THEM).  IF PAWNS ARE PRESENT ON BOTH     *    06405000
C       *         SIDES OF THE BOARD, THEN THE KINGS WILL CEN-     *    06406000
C       *         TRALIZE.                                         *    06407000
C       *                                                          *    06408000
C       ************************************************************    06409000
C                                                                       06410000
      IMPLICIT INTEGER*4 (A-Z)                                          06411000
      COMMON /PHASE/ OPEN, MIDDLE, END                                  06412000
      LOGICAL OPEN, MIDDLE, END                                         06413000
      LOGICAL CQUEEN, HQUEEN, TEMP                                      06414000
      COMMON /BOARD/ BOARD(120)                                         06415000
      COMMON /K BD SM/ CKSCOR(100), HKSCOR(100)                         06416000
      COMMON /K SM/ EKMOVE, KSAFE                                       06417000
      COMMON /K LOC CM/ CKINGL, HKINGL                                  06418000
      COMMON /Q LOC CM/ CQUEEN, HQUEEN                                  06419000
      LOGICAL CKINGM,CROOKR,CROOKL,HKINGM,HROOKR,HROOKL                 06420000
      COMMON /CAST CM/  CKINGM,CROOKR,CROOKL,HKINGM,HROOKR,HROOKL       06421000
      COMMON /P LOC CM/ CPLOC(8), HPLOC(8), NCPNS, NHPNS                06422000
      INTEGER*4 CPL(8),HPL(8)                                           06423000
      IF(END) GO TO 600                                                 06424000
C                                                                       06425000
C------------------------------< IF THE COMPUTER HAS A QUEEN ON THE     06426000
C------------------------------< BOARD, SET THE KING CONTROL BOARD      06427000
C------------------------------< TO ATTRACT THE KING BEHIND THE PAWNS   06428000
C------------------------------< ON THE SIDE HE IS ON.                  06429000
C                                                                       06430000
      IF(.NOT. CQUEEN) GO TO 200                                        06431000
      SIDE=MOD(CKINGL,10)-1                                             06432000
      FILES=2                                                           06433000
      IF(SIDE.GT.4) FILES=7                                             06434000
      RANK=1                                                            06435000
      DO 100 I=3,5                                                      06436000
      RANK=RANK+1                                                       06437000
      START=FILES+I*10                                                  06438000
      ENDING=START+2                                                    06439000
      DO 110 SQ=START,ENDING                                            06440000
          IF(BOARD(SQ).EQ.8) GO TO 120                                  06441000
110   CONTINUE                                                          06442000
100   CONTINUE                                                          06443000
      GO TO 200                                                         06444000
120   LOC=RANK*10+FILES+1                                               06445000
      IF(BOARD(LOC).EQ.13) GO TO 130                                    06446000
      LOC1=LOC-1                                                        06447000
      IF(FILES.GT.4) LOC1=LOC+1                                         06448000
      IF(BOARD(LOC1).EQ.13) LOC=LOC1                                    06449000
130   IF(.NOT. CKINGM) LOC=CKINGL                                       06450000
      TEMP=OPEN                                                         06451000
      OPEN=.FALSE.                                                      06452000
      CALL SETSQ(CKSCOR,LOC,KSAFE)                                      06453000
      OPEN=TEMP                                                         06454000
C                                                                       06455000
C------------------------------< IF THE HUMAN HAS A QUEEN ON THE        06456000
C------------------------------< BOARD, SET THE KING CONTROL BOARD      06457000
C------------------------------< TO ATTRACT THE KING BEHIND THE PAWNS   06458000
C------------------------------< ON THE SIDE HE IS ON.                  06459000
C                                                                       06460000
200   IF(.NOT. HQUEEN) GO TO 400                                        06461000
      SIDE=MOD(HKINGL,10)-1                                             06462000
      FILES=2                                                           06463000
      IF(SIDE.GT.4) FILES=7                                             06464000
      RANK=10                                                           06465000
      DO 300 I=1,3                                                      06466000
      RANK=RANK-1                                                       06467000
      START=FILES+(9-I)*10                                              06468000
      ENDING=START+2                                                    06469000
      DO 310 SQ=START,ENDING                                            06470000
          IF(BOARD(SQ).EQ.1) GO TO 320                                  06471000
310   CONTINUE                                                          06472000
300   CONTINUE                                                          06473000
      GO TO 400                                                         06474000
320   LOC=RANK*10+FILES+1                                               06475000
      IF(BOARD(LOC).EQ.6) GO TO 330                                     06476000
      LOC1=LOC-1                                                        06477000
      IF(FILES.GT.4) LOC1=LOC+1                                         06478000
      IF(BOARD(LOC1).EQ.6) LOC=LOC1                                     06479000
330   IF(.NOT. HKINGM) LOC=HKINGL                                       06480000
      TEMP=OPEN                                                         06481000
      OPEN=.FALSE.                                                      06482000
      CALL SETSQ(HKSCOR,LOC,KSAFE)                                      06483000
      OPEN=TEMP                                                         06484000
C                                                                       06485000
C------------------------------< IF THE COMPUTER KING HASN'T CASTLED,   06486000
C------------------------------< AND STILL CAN, DISCOURAGE IT FROM      06487000
C------------------------------< MOVING AND LOSING THAT PRIVILEGE.      06488000
C                                                                       06489000
400   IF(CKINGM.OR.(CROOKR.AND.CROOKL)) GO TO 500                       06490000
      IF(BOARD(25).EQ.13) CKSCOR(25)=CKSCOR(25)+EKMOVE                  06491000
      IF(BOARD(26).EQ.13) CKSCOR(26)=CKSCOR(26)+EKMOVE                  06492000
C                                                                       06493000
C------------------------------< IF THE HUMAN KING HASN'T CASTLED,      06494000
C------------------------------< AND STILL CAN, DISCOURAGE IT FROM      06495000
C------------------------------< MOVING AND LOSING THAT PRIVILEGE.      06496000
C                                                                       06497000
500   IF(HKINGM.OR.(HROOKR.AND.HROOKL)) GO TO 600                       06498000
      IF(BOARD(95).EQ.6) HKSCOR(95)=HKSCOR(95)+EKMOVE                   06499000
      IF(BOARD(96).EQ.6) HKSCOR(96)=HKSCOR(96)+EKMOVE                   06500000
C                                                                       06501000
C------------------------------< LOCATE PAWN MASSES TO DETERMINE        06502000
C------------------------------< WHERE KINGS SHOULD GO.                 06503000
C                                                                       06504000
600   IF(NCPNS.EQ.0) GO TO 700                                          06505000
      DO 650 I=1,NCPNS                                                  06506000
          CPL(I)=MOD(CPLOC(I),10)-1                                     06507000
650   CONTINUE                                                          06508000
700   IF(NHPNS.EQ.0) GO TO 800                                          06509000
      DO 750 I=1,NHPNS                                                  06510000
          HPL(I)=MOD(HPLOC(I),10)-1                                     06511000
750   CONTINUE                                                          06512000
C                                                                       06513000
C------------------------------< IF ALL TESTS FAIL, THEN CENTRALIZE     06514000
C------------------------------< THE KINGS.                             06515000
C                                                                       06516000
800   IF(NCPNS+NHPNS.EQ.0) GO TO 9999                                   06517000
      CLOC=65                                                           06518000
      CLOC1=CLOC                                                        06519000
      HLOC=55                                                           06520000
      HLOC1=HLOC                                                        06521000
C                                                                       06522000
C------------------------------< IF THERE ARE PAWNS ON BOTH WINGS,      06523000
C------------------------------< CENTRALIZE THE KINGS (FOR NOW).        06524000
C                                                                       06525000
      IF(NCPNS.EQ.0) GO TO 900                                          06526000
      IF(NCPNS.EQ.1) GO TO 850                                          06527000
      IF(CPL(1).LT.4.AND.CPL(NCPNS).GT.4) GO TO 900                     06528000
850   CLOC=CPLOC((NCPNS+1)/2)                                           06529000
      CLOC1=CLOC+10                                                     06530000
900   IF(NHPNS.EQ.0) GO TO 1000                                         06531000
      IF(NHPNS.EQ.1) GO TO 950                                          06532000
      IF(HPL(1).LT.4.AND.HPL(NHPNS).GT.4) GO TO 1000                    06533000
950   HLOC=HPLOC((NHPNS+1)/2)                                           06534000
      HLOC1=HLOC-10                                                     06535000
C                                                                       06536000
C------------------------------< THE KING SHOULD:                       06537000
C------------------------------<   A) MOVE TOWARD IT'S OWN PAWN MASS    06538000
C------------------------------<      IF IT HAS ONE, OR                 06539000
C------------------------------<   B) MOVE TOWARD THE OPPONENTS PAWN    06540000
C------------------------------<      MASS IF IT DOESN'T HAVE ONE, OR   06541000
C------------------------------<   C) MOVE TOWARD THE OPPONENT'S        06542000
C------------------------------<      KING IF NEITHER HAVE ONE.         06543000
C                                                                       06544000
1000  IF(NCPNS.EQ.0.AND.NHPNS.GT.0) CLOC1=HLOC-10                       06545000
      IF(NHPNS.EQ.0.AND.NCPNS.GT.0) HLOC1=CLOC+10                       06546000
      IF(.NOT.HQUEEN .OR. END) CALL SETSQ(CKSCOR,CLOC1,KSAFE)           06547000
      IF(.NOT.CQUEEN .OR. END) CALL SETSQ(HKSCOR,HLOC1,KSAFE)           06548000
9999  RETURN                                                            06549000
      END                                                               06550000
$CONTROL SEGMENT=SET                                                    06551000
      SUBROUTINE SETNBD                                                 06552000
C                                                                       06553000
C       ************************************************************    06554000
C       *                                                          *    06555000
C       *      SETNBD IS USED TO SET THE KNIGHT CONTROL BOARDS IN  *    06556000
C       *  COMMON BLOCK 'N BD SM'.  THE BOARD IS SET UP EITHER     *    06557000
C       *  AROUND THE CENTER  OR AROUND THE OPPONENT'S KING BASED  *    06558000
C       *  ON WHETHER OR NOT THE OPENING IS COMPLETE.  THE         *    06559000
C       *  FOLLOWING SCORING CONSIDERATIONS ARE INCLUDED IN THE    *    06560000
C       *  CONTROL BOARD:                                          *    06561000
C       *     1)  THE BORDER SQUARES ARE GIVEN LOWER VALUES TO     *    06562000
C       *        PREVENT THE KNIGHT FROM GETTING ON THE EDGE OF    *    06563000
C       *        THE BOARD WHERE MUCH OF IT'S EFFECTIVENESS IS     *    06564000
C       *        LOST DUE TO RESTRICTED MOBILITY.                  *    06565000
C       *                                                          *    06566000
C       ************************************************************    06567000
C                                                                       06568000
      IMPLICIT INTEGER*4 (A-Z)                                          06569000
      COMMON /PHASE/ OPEN, MIDDLE, END                                  06570000
      LOGICAL OPEN, MIDDLE, END                                         06571000
      COMMON /BOARD/ BOARD(120)                                         06572000
      COMMON /N SM/ ENMOVE, OUTPST, N EDGE                              06573000
      COMMON /N BD SM/ CNSCOR(100), HNSCOR(100)                         06574000
      COMMON /GEN SM/ ATAK SC, BPAWN, BLKSC, TEMPO                      06575000
      COMMON /CAST CM/  CKINGM,CROOKR,CROOKL,HKINGM,HROOKR,HROOKL       06576000
      LOGICAL CKINGM, CROOKR, CROOKL, HKINGM, HROOKR, HROOKL            06577000
      COMMON /CAST SM/ CAST SC, UB CAST                                 06578000
      COMMON /DEV STS/ CDONE, HDONE                                     06579000
      LOGICAL CDONE, HDONE                                              06580000
C                                                                       06581000
C------------------------------< SET THE KNIGHT CONTROL BOARD TO        06582000
C------------------------------< DISCOURAGE KNIGHTS FROM MOVING TO      06583000
C------------------------------< SQUARES ON THE EDGE (RIM) OF THE       06584000
C------------------------------< BOARD WHERE THEY ARE RESTRICTED        06585000
C------------------------------< AND SUBJECT TO BECOMING TRAPPED.       06586000
C                                                                       06587000
      DO 100 I=23,28                                                    06588000
          CNSCOR(I)=CNSCOR(I)-N EDGE                                    06589000
          HNSCOR(I)=HNSCOR(I)-N EDGE                                    06590000
          CNSCOR(I+70)=CNSCOR(I+70)-N EDGE                              06591000
          HNSCOR(I+70)=HNSCOR(I+70)-N EDGE                              06592000
100   CONTINUE                                                          06593000
      DO 200 I=22,92,10                                                 06594000
          CNSCOR(I)=CNSCOR(I)-N EDGE                                    06595000
          HNSCOR(I)=HNSCOR(I)-N EDGE                                    06596000
          CNSCOR(I+7)=CNSCOR(I+7)-N EDGE                                06597000
          HNSCOR(I+7)=HNSCOR(I+7)-N EDGE                                06598000
200   CONTINUE                                                          06599000
C                                                                       06600000
C------------------------------< ADJUST THE CONTROL BOARD TO PREVENT    06601000
C------------------------------< POSTING A KNIGHT IN FRONT OF CENTER    06602000
C------------------------------< PAWNS THAT HAVEN'T BEEN MOVED.         06603000
C                                                                       06604000
250   IF(.NOT. OPEN) GO TO 275                                          06605000
      IF(BOARD(85).EQ.1) HNSCOR(75)=HNSCOR(75)-BPAWN                    06606000
      IF(BOARD(86).EQ.1) HNSCOR(76)=HNSCOR(76)-BPAWN                    06607000
      IF(BOARD(85).EQ.1.OR.BOARD(75).EQ.1)                              06608000
     *                   HNSCOR(65)=HNSCOR(65)-BPAWN                    06609000
      IF(BOARD(86).EQ.1.OR.BOARD(76).EQ.1)                              06610000
     *                   HNSCOR(66)=HNSCOR(66)-BPAWN                    06611000
505   IF(BOARD(35).EQ.8) CNSCOR(45)=CNSCOR(45)-BPAWN                    06612000
      IF(BOARD(36).EQ.8) CNSCOR(46)=CNSCOR(46)-BPAWN                    06613000
      IF(BOARD(35).EQ.8.OR.BOARD(45).EQ.8)                              06614000
     *                   CNSCOR(55)=CNSCOR(55)-BPAWN                    06615000
      IF(BOARD(36).EQ.8.OR.BOARD(46).EQ.8)                              06616000
     *                   CNSCOR(56)=CNSCOR(56)-BPAWN                    06617000
275   CONTINUE                                                          06618000
C                                                                       06619000
C------------------------------< IF IN THE OPENING, ADJUST THE CONTROL  06620000
C------------------------------< BOARD TO FORCE KNIGHTS OFF OF THE      06621000
C------------------------------< BACK RANK (DEVELOP)                    06622000
C                                                                       06623000
      IF(CDONE) GO TO 300                                               06624000
      CNSCOR(23)=CNSCOR(23)+ENMOVE                                      06625000
      CNSCOR(28)=CNSCOR(28)+ENMOVE                                      06626000
      IF(CKINGM) GO TO 300                                              06627000
      IF(CROOKR) GO TO 350                                              06628000
      CNSCOR(23)=CNSCOR(23)+UB CAST                                     06629000
350   IF(CROOKL) GO TO 300                                              06630000
      CNSCOR(28)=CNSCOR(28)+UB CAST                                     06631000
300   CONTINUE                                                          06632000
      IF(HDONE) GO TO 500                                               06633000
      HNSCOR(93)=HNSCOR(93)+ENMOVE                                      06634000
      HNSCOR(98)=HNSCOR(98)+ENMOVE                                      06635000
      IF(HKINGM) GO TO 500                                              06636000
      IF(HROOKR) GO TO 450                                              06637000
      HNSCOR(98)=HNSCOR(98)+UB CAST                                     06638000
450   IF(HROOKL) GO TO 500                                              06639000
      HNSCOR(93)=HNSCOR(93)+UB CAST                                     06640000
500   CONTINUE                                                          06641000
      RETURN                                                            06642000
      END                                                               06643000
$CONTROL SEGMENT=SET                                                    06644000
      SUBROUTINE SETOPN                                                 06645000
C                                                                       06646000
C       ************************************************************    06647000
C       *                                                          *    06648000
C       *      SETOPN IS USED TO GIVE THE USER SOME DEGREE OF      *    06649000
C       *  CONTROL OVER WHICH OPENING THE PROGRAM WILL PLAY AND    *    06650000
C       *  ALSO WHICH LINE THE PROGRAM WILL USE OUT OF THE LINES   *    06651000
C       *  INCLUDED IN THE BOOKMOVE FILE.  THIS SUBROUTINE SETS    *    06652000
C       *  VARIABLE 'MVNUMB' SO THAT BOOK WILL CHOSE 'MVNUMB'      *    06653000
C       *  MOVE OUT OF IT'S LIST OF ALTERNATIVE MOVES.  FOR EX-    *    06654000
C       *  AMPLE, '3' WOULD CAUSE IT TO CHOSE THE 3RD POSSIBILITY  *    06655000
C       *  FOR IT'S NEXT MOVE.  EACH TIME BOOK USES 'MVNUMB' IT IS *    06656000
C       *  RESET TO 1 SINCE USUALLY THE GOOD VARIATIONS WILL BE    *    06657000
C       *  FIRST.  'SO' CAN BE USED AS MANY TIMES AS DESIRED TO    *    06658000
C       *  MAKE THE PROGRAM FOLLOW ANY LINE IN IT'S 'BOOK'.        *    06659000
C       *                                                          *    06660000
C       ************************************************************    06661000
C                                                                       06662000
      IMPLICIT INTEGER*4 (A-Z)                                          06663000
      COMMON /OPEN CM/ MVNUMB                                           06664000
      WRITE(6,10)                                                       06665000
10    FORMAT(1X,'WHICH VARIATION SHOULD I PLAY?')                       06666000
      CALL INPUT(TEMP)                                                  06667000
      IF(TEMP.EQ.0) RETURN                                              06668000
      MVNUMB=TEMP                                                       06669000
      RETURN                                                            06670000
      END                                                               06671000
$CONTROL SEGMENT=SET                                                    06672000
      SUBROUTINE SETPBD                                                 06673000
C                                                                       06674000
C       ************************************************************    06675000
C       *                                                          *    06676000
C       *      SETPBD IS USED TO SET THE PAWN CONTROL BOARDS       *    06677000
C       *  USED IN CONTROLLING PAWN ADVANCES.  THE CENTER TWO      *    06678000
C       *  PAWNS ARE ALWAYS ENCOURAGED TO ADVANCE, THE PAWNS ON    *    06679000
C       *  THE OPPOSITE SIDE OF THE BOARD FROM THE CASTLED KING    *    06680000
C       *  ARE ENCOURAGED ALSO.  THE PAWNS IN FRONT OF THE CASTLED *    06681000
C       *  KING ARE ENCOURAGED TO STAY PUT UNTIL THE OPPONENT'S    *    06682000
C       *  QUEEN IS OFF OF THE BOARD OR UNTIL THE KING HAS MOVED   *    06683000
C       *  OUT FROM BEHIND THEIR PROTECTIVE SCREEN.                *    06684000
C       *                                                          *    06685000
C       ************************************************************    06686000
C                                                                       06687000
      IMPLICIT INTEGER*4 (A-Z)                                          06688000
      COMMON /BOARD/ BOARD(120)                                         06689000
      COMMON /P SM/ PADVNC, PPAWN, IPAWN, DPAWN, TPAWN, CPAWN,          06690000
     * ABREST, PPSHSC                                                   06691000
      COMMON /CAST CM/  CKINGM,CROOKR,CROOKL,HKINGM,HROOKR,HROOKL       06692000
      LOGICAL CKINGM, CROOKR, CROOKL, HKINGM, HROOKR, HROOKL            06693000
      COMMON /K LOC CM/ CKINGL, HKINGL                                  06694000
      COMMON /Q LOC CM/ CQUEEN, HQUEEN                                  06695000
      COMMON /PHASE/ OPEN, MIDDLE, END                                  06696000
      LOGICAL OPEN, MIDDLE, END                                         06697000
      COMMON /P BD SM/ CPSCOR(100), HPSCOR(100)                         06698000
      COMMON /PIEC CM/ PVALUE(13), PINIT(13)                            06699000
      COMMON /DATA/ CMOVE, SMOVE, HFROM8, HTO8, HTYPE8, MOVE            06700000
C                                                                       06701000
C------------------------------< INITIALIZE THE PAWN CONTROL BOARD      06702000
C------------------------------< TO ENCOURAGE ALL PAWNS TO ADVANCE      06703000
C                                                                       06704000
      DO 50 SQ=22,99                                                    06705000
          FILE=MOD(SQ,10)-2                                             06706000
          IF(FILE.GT.3) FILE=7-FILE                                     06707000
          CPSCOR(SQ)=(SQ/10-2)*(PADVNC/2+FILE*2)                        06708000
          HPSCOR(SQ)=(9-SQ/10)*(PADVNC/2+FILE*2)                        06709000
50    CONTINUE                                                          06710000
      DO 100 I=22,29                                                    06711000
          CPSCOR(I+70)=PVALUE(12)                                       06712000
          HPSCOR(I)=PVALUE(5)                                           06713000
100   CONTINUE                                                          06714000
      L=+1                                                              06715000
      R=+1                                                              06716000
C                                                                       06717000
C------------------------------< IF THE KING HAS CASTLED AND THE        06718000
C------------------------------< HUMAN STILL HAS A QUEEN ON THE         06719000
C------------------------------< BOARD, DISCOURAGE ADVANCING PAWNS      06720000
C------------------------------< IN FRONT OF THE CASTLED KING.          06721000
C------------------------------< IF THE KING HASN'T CASTLED YET,        06722000
C------------------------------< DISCOURAGE MOVING PAWNS ON EITHER      06723000
C------------------------------< SIDE OF THE CENTER PAWNS.              06724000
C                                                                       06725000
      IF(CKINGL.GT.30 .OR. END) GO TO 225                               06726000
      IF(CKINGM) GO TO 200                                              06727000
      IF(.NOT. CROOKR) R=-1                                             06728000
      IF(.NOT. CROOKL) L=-1                                             06729000
200   IF(CKINGL.GE.26) L=-1                                             06730000
      IF(CKINGL.LE.25) R=-1                                             06731000
225   DO 255 J=42,44                                                    06732000
          L2=J+40                                                       06733000
          DO 250 I=J,L2,10                                              06734000
              CPSCOR(I)=CPSCOR(I)*R                                     06735000
              CPSCOR(I+5)=CPSCOR(I+5)*L                                 06736000
250       CONTINUE                                                      06737000
255   CONTINUE                                                          06738000
      IF(.NOT. OPEN) GO TO 260                                          06739000
      CPSCOR(45)=CPSCOR(45)+PADVNC/2                                    06740000
      CPSCOR(46)=CPSCOR(46)+PADVNC/2                                    06741000
      CPSCOR(55)=CPSCOR(55)+PADVNC                                      06742000
      CPSCOR(56)=CPSCOR(56)+PADVNC                                      06743000
260   CONTINUE                                                          06744000
      IF(MOVE.GT.1) GO TO 275                                           06745000
      IF(BOARD(65).NE.1) CPSCOR(56)=CPSCOR(56)+200                      06746000
      IF(BOARD(66).NE.1) CPSCOR(55)=CPSCOR(55)+200                      06747000
275   CONTINUE                                                          06748000
C                                                                       06749000
C------------------------------< IF THE KING HAS CASTLED AND THE        06750000
C------------------------------< COMPUTER STILL HAS A QUEEN ON THE      06751000
C------------------------------< BOARD, DISCOURAGE ADVANCING PAWNS      06752000
C------------------------------< IN FRONT OF THE CASTLED KING.          06753000
C------------------------------< IF THE KING HASN'T CASTLED YET,        06754000
C------------------------------< DISCOURAGE MOVING PAWNS ON EITHER      06755000
C------------------------------< SIDE OF THE CENTER PAWNS.              06756000
C                                                                       06757000
      L=+1                                                              06758000
      R=+1                                                              06759000
      IF(HKINGL.LT.90 .OR. END) GO TO 325                               06760000
      IF(HKINGM) GO TO 300                                              06761000
      IF(.NOT. HROOKR) R=-1                                             06762000
      IF(.NOT. HROOKL) L=-1                                             06763000
300   IF(HKINGL.LE.95) L=-1                                             06764000
      IF(HKINGL.GE.96) R=-1                                             06765000
325   DO 355 J=32,34                                                    06766000
          L2=J+40                                                       06767000
          DO 350 I=J,L2,10                                              06768000
              HPSCOR(I)=HPSCOR(I)*L                                     06769000
              HPSCOR(I+5)=HPSCOR(I+5)*R                                 06770000
350       CONTINUE                                                      06771000
355   CONTINUE                                                          06772000
      IF(.NOT. OPEN) GO TO 360                                          06773000
      HPSCOR(75)=HPSCOR(75)+PADVNC/2                                    06774000
      HPSCOR(76)=HPSCOR(76)+PADVNC/2                                    06775000
      HPSCOR(65)=HPSCOR(65)+PADVNC                                      06776000
      HPSCOR(66)=HPSCOR(66)+PADVNC                                      06777000
360   CONTINUE                                                          06778000
      RETURN                                                            06779000
      END                                                               06780000
$CONTROL SEGMENT=SET                                                    06781000
      SUBROUTINE SETPCV                                                 06782000
C                                                                       06783000
C       ************************************************************    06784000
C       *                                                          *    06785000
C       *      SETPCV IS USED TO SET THE MATERIAL VALUE FOR EACH   *    06786000
C       *  SIDE SO THAT THE SIDE WHICH IS MATERIAL AHEAD WILL      *    06787000
C       *  TEND TO EXCHANGE WHILE THE SIDE THAT IS MATERIAL BE-    *    06788000
C       *  HIND WILL TEND TO AVOID EXCHANGES.                      *    06789000
C       *                                                          *    06790000
C       ************************************************************    06791000
C                                                                       06792000
      IMPLICIT INTEGER*4 (A-Z)                                          06793000
      REAL RATIO                                                        06794000
      COMMON /BOARD/ BOARD(120)                                         06795000
      COMMON /PIEC CM/ PVALUE(13), PINIT(13)                            06796000
      COMMON /MTRL SC/ CPCVAL, HPCVAL                                   06797000
C                                                                       06798000
C------------------------------< ADD UP MATERIAL FOR BOTH SIDES         06799000
C                                                                       06800000
      CPCVAL=0                                                          06801000
      HPCVAL=0                                                          06802000
      SQ=21                                                             06803000
      DO 3   I=1,8                                                      06804000
          DO 2 J=1,8                                                    06805000
              SQ=SQ+1                                                   06806000
              TEMP=BOARD(SQ)                                            06807000
              IF(TEMP.GT.7) GO TO 1                                     06808000
              HPCVAL=HPCVAL+PINIT(TEMP)                                 06809000
              GO TO 2                                                   06810000
1             CPCVAL=CPCVAL+PINIT(TEMP)                                 06811000
2         CONTINUE                                                      06812000
          SQ=SQ+2                                                       06813000
3     CONTINUE                                                          06814000
C                                                                       06815000
C------------------------------< COMPUTE MATERIAL RATIO AND SET THE     06816000
C------------------------------< VALUE OF COMPUTER PIECES SO THAT       06817000
C------------------------------< THE SIDE MATERIAL AHEAD WILL TRY       06818000
C------------------------------< TO EXCHANGE, WHILE THE SIDE BEHIND     06819000
C------------------------------< WILL TRY TO AVOID EXCHANGING.          06820000
C                                                                       06821000
      RATIO=1                                                           06822000
      IF(HPCVAL.EQ.0.OR.CPCVAL.EQ.0) GO TO 4                            06823000
      RATIO=FLOAT(HPCVAL-8000)/FLOAT(CPCVAL-8000)                       06824000
      IF(RATIO.LT..90) RATIO=.90                                        06825000
      IF(RATIO.GT.1.10) RATIO=1.10                                      06826000
4     DO 5   I=1,13                                                     06827000
          PVALUE(I)=PINIT(I)                                            06828000
5     CONTINUE                                                          06829000
      DO 6   I=8,12                                                     06830000
          PVALUE(I)=RATIO*PINIT(I)                                      06831000
6     CONTINUE                                                          06832000
      RETURN                                                            06833000
      END                                                               06834000
$CONTROL SEGMENT=SET                                                    06835000
      SUBROUTINE SETQBD                                                 06836000
C                                                                       06837000
C       ************************************************************    06838000
C       *                                                          *    06839000
C       *      SETQBD IS USED TO SET THE QUEEN CONTROL BOARDS IN   *    06840000
C       *  COMMON BLOCK 'Q BD SM'.  THE BOARD IS SET UP EITHER     *    06841000
C       *  AROUND THE CENTER  OR AROUND THE OPPONENT'S KING BASED  *    06842000
C       *  ON WHETHER OR NOT THE OPENING IS COMPLETE.  THE         *    06843000
C       *  FOLLOWING SCORING CONSIDERATIONS ARE INCLUDED IN THE    *    06844000
C       *  CONTROL BOARD:                                          *    06845000
C       *     1)  THE SQUARE WHERE THE QUEEN IS SITTING IS GIVEN   *    06846000
C       *        A HIGHER VALUE DURING THE OPENING OF THE GAME TO  *    06847000
C       *        TEND TO MAKE THE QUEEN STAY IN ONE PLACE UNTIL    *    06848000
C       *        DEVELOPMENT IS COMPLETE.  EARLY QUEEN MOVES       *    06849000
C       *        USUALLY RESULT IN LOST TEMPI DUE TO MOVING THE    *    06850000
C       *        QUEEN AROUND TO AVOID ATTACKS.                    *    06851000
C       *                                                          *    06852000
C       ************************************************************    06853000
C                                                                       06854000
      IMPLICIT INTEGER*4 (A-Z)                                          06855000
      COMMON /PHASE/ OPEN, MIDDLE, END                                  06856000
      LOGICAL OPEN, MIDDLE, END                                         06857000
      COMMON /BOARD/ BOARD(120)                                         06858000
      COMMON /Q BD SM/ CQSCOR(100), HQSCOR(100)                         06859000
      COMMON /Q SM/ EQMOVE, Q EDGE                                      06860000
      COMMON /DEV STS/ CDONE, HDONE                                     06861000
      LOGICAL CDONE, HDONE                                              06862000
C                                                                       06863000
C------------------------------< IF STILL IN THE OPENING PHASE OF       06864000
C------------------------------< THE GAME, DISCOURAGE THE QUEEN         06865000
C------------------------------< FROM MOVING TO AVOID HAVING TO         06866000
C------------------------------< REPEATEDLY MOVE IT AWAY FROM ATTACKS   06867000
C------------------------------< AND LOSING TEMPI.                      06868000
C                                                                       06869000
      IF(CDONE) GO TO 100                                               06870000
      IF(BOARD(25).EQ.12) CQSCOR(25)=EQMOVE                             06871000
      IF(BOARD(26).EQ.12) CQSCOR(26)=EQMOVE                             06872000
100   CONTINUE                                                          06873000
      IF(HDONE) GO TO 200                                               06874000
      IF(BOARD(95).EQ.5) HQSCOR(95)=EQMOVE                              06875000
      IF(BOARD(96).EQ.5) HQSCOR(96)=EQMOVE                              06876000
200   CONTINUE                                                          06877000
C                                                                       06878000
C------------------------------< SET THE QUEEN CONTROL BOARD TO         06879000
C------------------------------< DISCOURAGE QUEENS FROM MOVING TO       06880000
C------------------------------< SQUARES ON THE EDGE (RIM) OF THE       06881000
C------------------------------< BOARD WHERE THEY ARE RESTRICTED        06882000
C------------------------------< AND SUBJECT TO BECOMING TRAPPED.       06883000
C                                                                       06884000
      IF(.NOT. END) GO TO 500                                           06885000
      DO 300 I=23,28                                                    06886000
          CQSCOR(I)=CQSCOR(I)-Q EDGE                                    06887000
          HQSCOR(I)=HQSCOR(I)-Q EDGE                                    06888000
          CQSCOR(I+70)=CQSCOR(I+70)-Q EDGE                              06889000
          HQSCOR(I+70)=HQSCOR(I+70)-Q EDGE                              06890000
300   CONTINUE                                                          06891000
      DO 400 I=22,92,10                                                 06892000
          CQSCOR(I)=CQSCOR(I)-Q EDGE                                    06893000
          HQSCOR(I)=HQSCOR(I)-Q EDGE                                    06894000
          CQSCOR(I+7)=CQSCOR(I+7)-Q EDGE                                06895000
          HQSCOR(I+7)=HQSCOR(I+7)-Q EDGE                                06896000
400   CONTINUE                                                          06897000
500   RETURN                                                            06898000
      END                                                               06899000
$CONTROL SEGMENT=SET                                                    06900000
      SUBROUTINE SETRBD                                                 06901000
C                                                                       06902000
C       ************************************************************    06903000
C       *                                                          *    06904000
C       *      SETRBD IS USED TO SET THE ROOK CONTROL BOARDS IN    *    06905000
C       *  COMMON BLOCK 'R BD SM'.  THE BOARD IS SET UP EITHER     *    06906000
C       *  AROUND THE CENTER  OR AROUND THE OPPONENT'S KING BASED  *    06907000
C       *  ON WHETHER OR NOT THE OPENING IS COMPLETE.  THE         *    06908000
C       *  FOLLOWING SCORING CONSIDERATIONS ARE INCLUDED IN THE    *    06909000
C       *  CONTROL BOARD:                                          *    06910000
C       *     1)  THE SQUARES WHERE ROOKS ARE SITTING ARE GIVEN    *    06911000
C       *        HIGH VALUES DURING THE OPENING OF THE GAME TO     *    06912000
C       *        TEND TO MAKE THE ROOK STAY IN ONE PLACE UNTIL     *    06913000
C       *        DEVELOPMENT IS COMPLETE.                          *    06914000
C       *                                                          *    06915000
C       ************************************************************    06916000
C                                                                       06917000
      IMPLICIT INTEGER*4 (A-Z)                                          06918000
      COMMON /PHASE/ OPEN, MIDDLE, END                                  06919000
      LOGICAL OPEN, MIDDLE, END                                         06920000
      COMMON /BOARD/ BOARD(120)                                         06921000
      COMMON /R BD SM/ CRSCOR(100), HRSCOR(100)                         06922000
      COMMON /R SM/ ERMOVE, RANK78, ROPEN, RHALF, DROOKS, CROOKS,       06923000
     * RPASS, R EDGE                                                    06924000
      COMMON /K LOC CM/ CKINGL, HKINGL                                  06925000
C                                                                       06926000
C------------------------------< IF IN THE OPENING PHASE OF THE         06927000
C------------------------------< GAME, DISCOURAGE ROOKS FROM MOVING     06928000
C------------------------------< SINCE PROBABLY THE MOVE WILL NOT BE    06929000
C------------------------------< STRONG UNTIL OPEN LINES DEVELOP.       06930000
C                                                                       06931000
      IF(.NOT. OPEN) GO TO 100                                          06932000
      IF(BOARD(22).EQ.11) CRSCOR(22)=CRSCOR(22)+ERMOVE                  06933000
      IF(BOARD(29).EQ.11) CRSCOR(29)=CRSCOR(29)+ERMOVE                  06934000
      IF(BOARD(92).EQ.4) HRSCOR(92)=HRSCOR(92)+ERMOVE                   06935000
      IF(BOARD(99).EQ.4) HRSCOR(99)=HRSCOR(99)+ERMOVE                   06936000
C                                                                       06937000
C------------------------------< SET THE CONTROL BOARD TO ATTRACT       06938000
C------------------------------< ROOKS TO THE 7TH/8TH RANK WHEN THE     06939000
C------------------------------< OPPONENT'S KING IS STILL ON THE 8TH.   06940000
C                                                                       06941000
100   IF(CKINGL.GT.40) GO TO 300                                        06942000
      DO 200 I=21,40                                                    06943000
          HRSCOR(I)=HRSCOR(I)+RANK78                                    06944000
200   CONTINUE                                                          06945000
300   IF(HKINGL.LT.80) GO TO 500                                        06946000
      DO 400 I=81,100                                                   06947000
          CRSCOR(I)=CRSCOR(I)+RANK78                                    06948000
400   CONTINUE                                                          06949000
C                                                                       06950000
C------------------------------< SET THE ROOK CONTROL BOARD TO          06951000
C------------------------------< DISCOURAGE ROOKS FROM MOVING TO        06952000
C------------------------------< SQUARES ON THE EDGE (RIM) OF THE       06953000
C------------------------------< BOARD WHERE THEY ARE RESTRICTED        06954000
C------------------------------< AND SUBJECT TO BECOMING TRAPPED.       06955000
C                                                                       06956000
500   IF(.NOT. END) GO TO 800                                           06957000
      DO 600 I=23,28                                                    06958000
          CRSCOR(I)=CRSCOR(I)-R EDGE                                    06959000
          HRSCOR(I)=HRSCOR(I)-R EDGE                                    06960000
          CRSCOR(I+70)=CRSCOR(I+70)-R EDGE                              06961000
          HRSCOR(I+70)=HRSCOR(I+70)-R EDGE                              06962000
600   CONTINUE                                                          06963000
      DO 700 I=22,92,10                                                 06964000
          CRSCOR(I)=CRSCOR(I)-R EDGE                                    06965000
          HRSCOR(I)=HRSCOR(I)-R EDGE                                    06966000
          CRSCOR(I+7)=CRSCOR(I+7)-R EDGE                                06967000
          HRSCOR(I+7)=HRSCOR(I+7)-R EDGE                                06968000
700   CONTINUE                                                          06969000
800   RETURN                                                            06970000
      END                                                               06971000
$CONTROL SEGMENT=SET                                                    06972000
      SUBROUTINE SETSQ(VALUE,SQ,SCORE)                                  06973000
C                                                                       06974000
C       ************************************************************    06975000
C       *                                                          *    06976000
C       *      SETSQ IS USED BY THE PRE-ANALYZER TO SET UP THE     *    06977000
C       *  CONTROL BOARDS.  IT SETS UP THE BOARD PASSED TO IT AS   *    06978000
C       *  AN ARGUMENT TO HAVE A VALUE OF 66 IN SQUARE 'SQ' AND    *    06979000
C       *  8 LESS IN EACH RING AWAY FROM SQ USING THE DISTANCE     *    06980000
C       *  FORMULA.  NORMALLY, SQ IS THE SQUARE THAT THE KING IS   *    06981000
C       *  LOCATED ON TO MAKE MOVES TOWARD THE KING GET A HIGHER   *    06982000
C       *  SCORE AND MOVES AWAY FROM THE KING GET A LOWER SCORE.   *    06983000
C       *                                                          *    06984000
C       ************************************************************    06985000
C                                                                       06986000
      IMPLICIT INTEGER*4 (A-Z)                                          06987000
      DIMENSION VALUE(10,10)                                            06988000
      COMMON /PHASE/ OPEN, MIDDLE, END                                  06989000
      LOGICAL OPEN, MIDDLE, END                                         06990000
      REAL A, SQRT                                                      06991000
      KFILE=MOD(SQ,10)                                                  06992000
      KRANK=((SQ-1)/10)+1                                               06993000
      DO 2 J=3,10                                                       06994000
          DO 1 I=2,9                                                    06995000
              DIST=(I-KFILE)**2 + (J-KRANK)**2                          06996000
              IF(OPEN.AND.I.GT.5)                                       06997000
     *                       DIST=(I-KFILE-1)**2 + (J-KRANK)**2         06998000
              A=FLOAT(DIST)                                             06999000
              A=SQRT(A)                                                 07000000
              DIST=IFIX(A)                                              07001000
              VALUE(I,J)=(9-DIST)*SCORE                                 07002000
1         CONTINUE                                                      07003000
2     CONTINUE                                                          07004000
      RETURN                                                            07005000
      END                                                               07006000
$CONTROL SEGMENT=SET                                                    07007000
      SUBROUTINE SETTG                                                  07008000
C                                                                       07009000
C       ************************************************************    07010000
C       *                                                          *    07011000
C       *      SETTG IS USED TO SET THE PROGRAM UP FOR TOURNAMENT  *    07012000
C       *  PLAY WITH AS LITTLE HASSLE AS POSSIBLE.  THE FOLLOWING  *    07013000
C       *  THINGS ARE SET UP AUTOMATICALLY:                        *    07014000
C       *                                                          *    07015000
C       *      A)  THE SEARCH DEPTH IS SET TO 5, THE DEFAULT       *    07016000
C       *          FORWARD PRUNING WIDTHS ARE SET TO 6,6,6,6,??,   *    07017000
C       *          THE MAXIMUM WIDTHS ARE SET TO 13,13,13,13,??.   *    07018000
C       *                                                          *    07019000
C       *      B)  THE CLOCK IS TURNED ON AND SET FOR 40 MOVES     *    07020000
C       *          IN THE FIRST 2 HOURS AND 10 MOVES EACH 1/2      *    07021000
C       *          HOUR AFTER THAT.                                *    07022000
C       *                                                          *    07023000
C       *      C)  THE QUERY CLOCK FLAG IS SET SO THE PROGRAM WILL *    07024000
C       *          ASK ABOUT THE CHESS CLOCK.                      *    07025000
C       *                                                          *    07026000
C       *      D)  THE CLOCK IS SET TO USE ELAPSED TIME RATHER     *    07027000
C       *          THAN CPU TIME.                                  *    07028000
C       *                                                          *    07029000
C       *      E)  THINK-AHEAD MODE IS TURNED ON                   *    07030000
C       *                                                          *    07031000
C       *      F)  PROGRAMMED COMMAND MODE IS SET AND A 'P'        *    07032000
C       *          COMMAND IS ENTERED TO AID THE OPERATOR IN       *    07033000
C       *          USING THINK-AHEAD.                              *    07034000
C       *                                                          *    07035000
C       ************************************************************    07036000
C                                                                       07037000
      IMPLICIT INTEGER*4 (A-Z)                                          07038000
      COMMON /CLOK CM/ CLOCK,CTYPE,CQUERY,GELAP,CELAP,HELAP,            07039000
     *ELAPC,ELAPH,MOVES,SMOVES,SELAP,CTOTAL,HTOTAL,OPTIME               07040000
      COMMON /THAH CM/ THNK AH, LOOK AH, FOUND M, MTCHED, BRKFLG        07041000
      COMMON /PRUNE/ WIDTH(10), MIN(10), MAX(10),                       07042000
     * DEPTH, ORDER1, ORDER2                                            07043000
      COMMON /PC CM/ CMNDS(10,3), NCMNDS, PCMODE, EXMODE                07044000
      LOGICAL CLOCK,CQUERY,THNK AH,PCMODE,EXMODE,LOOK AH,MTCHED,        07045000
     *FOUND M, BRKFLG                                                   07046000
      COMMON /CHR SET/ ALPHA(44)                                        07047000
      EQUIVALENCE (BLANK,ALPHA(44)),(P,ALPHA(16))                       07048000
C                                                                       07049000
C------------------------------< SET UP LOOKAHEAD/FORWARD PRUNING       07050000
C                                                                       07051000
      DO 100 I=1,10                                                     07052000
          MIN(I)=6                                                      07053000
          MAX(I)=13                                                     07054000
          WIDTH(I)=MIN(I)                                               07055000
100   CONTINUE                                                          07056000
      DEPTH=5                                                           07057000
      ORDER1=4                                                          07058000
      ORDER2=4                                                          07059000
C                                                                       07060000
C------------------------------< SET UP CHESS CLOCK                     07061000
C                                                                       07062000
      MOVES=40                                                          07063000
      GELAP=120*60                                                      07064000
      SMOVES=10                                                         07065000
      SELAP=30*60                                                       07066000
      CTYPE=2                                                           07067000
      CLOCK=.TRUE.                                                      07068000
      CQUERY=.TRUE.                                                     07069000
      OPTIME=15                                                         07070000
C                                                                       07071000
C------------------------------< TURN ON THINK-AHEAD MODE               07072000
C                                                                       07073000
      THNK AH=.TRUE.                                                    07074000
      LOOK AH=.FALSE.                                                   07075000
      FOUND M=.FALSE.                                                   07076000
      MTCHED=.FALSE.                                                    07077000
C                                                                       07078000
C------------------------------< TURN ON PROGRAMMED COMMAND MODE AND    07079000
C------------------------------< FORCE A 'P' (PREDICTED MOVE) COMMAND   07080000
C                                                                       07081000
      PC MODE=.TRUE.                                                    07082000
      CMNDS(1,1)=P                                                      07083000
      CMNDS(1,2)=BLANK                                                  07084000
      CMNDS(1,3)=BLANK                                                  07085000
      NCMNDS=1                                                          07086000
      WRITE(6,200)                                                      07087000
200   FORMAT(1X,'PROGRAM IS SET AT TOURNAMENT SETTING')                 07088000
      RETURN                                                            07089000
      END                                                               07090000
$CONTROL SEGMENT=CMND                                                   07091000
      SUBROUTINE SRCMND                                                 07092000
C                                                                       07093000
C       ************************************************************    07094000
C       *                                                          *    07095000
C       *      THIS SUBROUTINE IS USED TO SET THE PERFORMANCE      *    07096000
C       *  RATING FOR THE OPPONENT.  THIS IS USED IN DETERMINING   *    07097000
C       *  WHEN TO ACCEPT/REJECT A DRAW OR STALEMATE.  IF THE      *    07098000
C       *  OPPONENT IS MUCH BETTER (2 CLASSES OR MORE), THE PRO-   *    07099000
C       *  WILL ALWAYS ACCEPT.  IF ONLY 1 CLASS BETTER, IT WILL    *    07100000
C       *  ACCEPT UNLESS IT IS 1 1/2 PAWNS OR MORE AHEAD.  IF      *    07101000
C       *  THE PROGRAM IS AS GOOD OR BETTER THAN IT'S OPPONENT,    *    07102000
C       *  IT WILL ONLY DRAW WHEN BEHIND.                          *    07103000
C       *                                                          *    07104000
C       ************************************************************    07105000
C                                                                       07106000
      IMPLICIT INTEGER*4 (A-Z)                                          07107000
      COMMON /RATE CM/ CRATE, HRATE                                     07108000
      COMMON /BUFFER/ TEXT(30)                                          07109000
      COMMON /CHRSET/ ALPHA(44)                                         07110000
      EQUIVALENCE (D,ALPHA(4))                                          07111000
      IF(TEXT(3).EQ.D) GO TO 30                                         07112000
      WRITE(6,10)                                                       07113000
10    FORMAT(1X,'ENTER OPPONENT''S PERFORMANCE RATING')                 07114000
      CALL INPUT(TEMP)                                                  07115000
      IF(TEMP.EQ.0) GO TO 20                                            07116000
      HRATE=TEMP                                                        07117000
20    RETURN                                                            07118000
30    WRITE(6,40)CRATE,HRATE                                            07119000
40    FORMAT(1X,'BLITZ:',I5,3X,'OPPONENT:',I5)                          07120000
      RETURN                                                            07121000
      END                                                               07122000
$CONTROL SEGMENT=DSP                                                    07123000
      SUBROUTINE STATS(DEVICE)                                          07124000
C                                                                       07125000
C       ************************************************************    07126000
C       *                                                          *    07127000
C       *      STATS IS USED TO PROCESS THE 'S' COMMAND WHICH WILL *    07128000
C       *  OUTPUT STATISTICS ABOUT THE GAME AND LAST MOVE SE-      *    07129000
C       *  LECTION.  THE STATISTICS PRINTED ARE:                   *    07130000
C       *      1)  NUMBER OF MOVES GENERATED BY THE MOVE GEN-      *    07131000
C       *          ERATORS FOR THE LAST MOVE.                      *    07132000
C       *      2)  NUMBER OF NON-TERMINAL NODES IN THE MOVE TREE   *    07133000
C       *          FOR THE LAST MOVE.  THIS IS THE NUMBER OF TIMES *    07134000
C       *          THE MOVE GENERATOR WAS CALLED TO GENERATE ALL   *    07135000
C       *          LEGAL MOVES FOR A POSITION.                     *    07136000
C       *      3)  NUMBER OF TERMINAL NODES IN THE TREE FOR THE    *    07137000
C       *          LAST MOVE.  THIS IS THE NUMBER OF BOARD         *    07138000
C       *          POSITIONS OR VARIATIONS THAT WERE EXAMINED      *    07139000
C       *          DURING THE LAST MOVE SELECTION.                 *    07140000
C       *      4)  NUMBER OF NODES EXAMINED AT EACH LEVEL IN THE   *    07141000
C       *          SEARCH.                                         *    07142000
C       *      5)  MINIMAXED SCORE FOR THE MOVE SELECTED.          *    07143000
C       *      6)  MAXIMUM LOOK-AHEAD INCLUDING MOVES LOOKED EX-   *    07144000
C       *          AMINED BY SUBROUTINE 'EXCHNG'.                  *    07145000
C       *      7)  AVERAGE TIME/MOVE FOR THE HUMAN AND PROGRAM,    *    07146000
C       *          AND TIME FOR THE LAST MOVE FOR BOTH SIDES ALSO. *    07147000
C       *      8)  NUMBER OF TIMES THE COMPUTER HAS CORRECTLY PRE- *    07148000
C       *          DICTED THE OPPONENT'S MOVE WHEN IN 'THINK-AHEAD'*    07149000
C       *          MODE.                                           *    07150000
C       *                                                          *    07151000
C       ************************************************************    07152000
C                                                                       07153000
      IMPLICIT INTEGER*4 (A-Z)                                          07154000
      COMMON /STAT CM/ NODES(10), NGEN, MAXPLY, PRIGHT                  07155000
      COMMON /CLOK CM/ CLOCK,CTYPE,CQUERY,GELAP,CELAP,HELAP,            07156000
     *ELAPC,ELAPH,MOVES,SMOVES,SELAP,CTOTAL,HTOTAL,OPTIME               07157000
      COMMON /TREE/ TREE(400),START(10),STOP(10),WHICH(10),BACKUP(10),  07158000
     *FROM(10),TO(10),VALUE(10),TYPE(10),PLY                            07159000
      COMMON /THAH CM/ THNK AH, LOOK AH, FOUND M, MATCH                 07160000
      LOGICAL THNK AH, LOOK AH, FOUND M, MATCH                          07161000
      COMMON /BOOK CM/ KEY, IN BOOK                                     07162000
      COMMON /DATA/ CMOVE, SMOVE, HFROM8, HTO8, HTYPE8, MOVE            07163000
      LOGICAL IN BOOK, CLOCK, CQUERY                                    07164000
      COMMON /MOV CNT/ NCMOVS, NHMOVS                                   07165000
      COMMON /PRUNE/ WIDTH(10), MIN(10), MAX(10),                       07166000
     * DEPTH, ORDER1, ORDER2                                            07167000
      C1=(CELAP+CTOTAL)/NCMOVS                                          07168000
      H1=(HELAP+HTOTAL)/NHMOVS                                          07169000
600   IF(IN BOOK) GO TO 640                                             07170000
610   WRITE(DEVICE,620)MOVE                                             07171000
620   FORMAT(1X,'MOVE NUMBER ',I3)                                      07172000
      NTERM=0                                                           07173000
      LIM=DEPTH-1                                                       07174000
      DO 888 I=1,LIM                                                    07175000
          NTERM=NTERM+NODES(I)                                          07176000
888   CONTINUE                                                          07177000
      IF(.NOT. IN BOOK) WRITE(DEVICE,630) MAXPLY, NGEN, NTERM,          07178000
     * NODES(DEPTH), BACKUP(1),(NODES(I),I,I=1,DEPTH)                   07179000
630   FORMAT(                                                           07180000
     *1X,'MAXIMUM LOOK AHEAD WAS',I3,' PLY'/                            07181000
     *1X,'NUMBER OF MOVES GENERATED WAS',I7/                            07182000
     *1X,'NUMBER OF NON-TERMINAL NODES SEARCHED WAS',I6/                07183000
     *1X,'NUMBER OF TERMINAL NODES SCORED WAS',I7/                      07184000
     *1X,'SCORE FOR SELECTED MOVE WAS',I6/                              07185000
     *1X,'NODES BY LEVEL',5(I6,'/',I1)/T16,                             07186000
     *5(I6,'/',I1))                                                     07187000
640   WRITE(DEVICE,650)ELAPC,ELAPH,C1,H1                                07188000
650   FORMAT(                                                           07189000
     *1X,'TIME FOR MY LAST MOVE WAS',I5,' SECONDS'/                     07190000
     *1X,'TIME FOR YOUR LAST MOVE WAS',I4,' SECONDS'/                   07191000
     *1X,'I AM AVERAGING ',I4,' SECONDS PER MOVE'/                      07192000
     *1X,'YOU ARE AVERAGING ',I4,' SECONDS PER MOVE')                   07193000
      MVS=NHMOVS                                                        07194000
      IF(PRIGHT.GT.MVS) MVS=PRIGHT                                      07195000
      WRITE(DEVICE,660)PRIGHT,MVS                                       07196000
660   FORMAT(1X,'I HAVE PREDICTED ',I2,' OUT OF ',I2,' MOVES')          07197000
      RETURN                                                            07198000
      END                                                               07199000
      SUBROUTINE THINK(*,*)                                             07200000
C                                                                       07201000
C       ************************************************************    07202000
C       *                                                          *    07203000
C       *      THINK IS THE DRIVER FOR THE 'THINK ON OPPONENT'S    *    07204000
C       *  TIME' ALGORITHM.  BRIEFLY, THINK TAKES THE PREDICTED    *    07205000
C       *  MOVE, MAKES IT AND CALLS <LOOK> TO DETERMINE THE PRO-   *    07206000
C       *  RAMS RESPONSE TO IT.  THIS MOVE IS SAVED AND IF THE     *    07207000
C       *  OPPONENT ACTUALLY MAKES THIS MOVE, THE PROGRAM HAS A    *    07208000
C       *  RESPONSE READY IMMEDIATELY.  THE BREAK KEY MAY BE HIT   *    07209000
C       *  TO ENTER A MOVE OR COMMAND BEFORE THE PROGRAM HAS       *    07210000
C       *  FINISHED CALCULATION.  IN THIS CASE ONE OF TWO ACTIONS  *    07211000
C       *  WILL BE TAKEN:                                          *    07212000
C       *      1)  IF A COMMAND IS ENTERED (OR A MOVE NOT IN THE   *    07213000
C       *          FORM DESCRIBED IN 2) BELOW) THE THINK-AHEAD     *    07214000
C       *          SEARCH IS ABORTED TO CARRY OUT THE COMMAND.     *    07215000
C       *          THE SEARCH WILL BE RE-STARTED FROM SCRATCH IF   *    07216000
C       *          A COMMAND IS ENTERED.                           *    07217000
C       *      2)  IF A MOVE IS ENTERED IN IT'S FULLY QUALIFIED    *    07218000
C       *          FORM (IE P/K2-K4 RATHER THAN P-K4) THEN THE     *    07219000
C       *          PROGRAM WILL ABORT THE THINK-AHEAD ONLY IF      *    07220000
C       *          THE MOVE IS NOT IT'S PREDICTED MOVE.  THIS      *    07221000
C       *          MEANS THAT WHATEVER TIME THE PROGRAM HAS USED   *    07222000
C       *          WHILE CALCULATING WILL NOT BE LOST.  IF THE     *    07223000
C       *          FREE FORM OF INPUT (IE P-K4, ETC.) IS USED      *    07224000
C       *          THE SEARCH MUST BE RE-STARTED FROM SCRATCH      *    07225000
C       *          TO FIND THE RESPONSE, EVEN IF IT MATCHED THE    *    07226000
C       *          PREDICTED MOVE. (NOTE THAT THIS ONLY OCCURS     *    07227000
C       *          WHEN THE <BREAK> BUTTON IS HIT TO GET THE       *    07228000
C       *          PROGRAM'S ATTENTION.  IF CALCULATION HAS BEEN   *    07229000
C       *          COMPLETED, THEN THE FREE FORM OF INPUT MAY BE   *    07230000
C       *          USED WITHOUT HINDERING THE PROGRAM.             *    07231000
C       *                                                          *    07232000
C       ************************************************************    07233000
C                                                                       07234000
      IMPLICIT INTEGER*4 (A-Z)                                          07235000
      COMMON /THAH CM/ THNK AH, LOOK AH, FOUND M, MTCHED, BRKFLG        07236000
      LOGICAL IN BOOK, THNK AH, LOOK AH, FOUND M, MTCHED, BRKFLG        07237000
      COMMON /DATA/ CMOVE, SMOVE, HFROM8, HTO8, HTYPE8, MOVE            07238000
      COMMON /TREE/ TREE(400),START(10),STOP(10),WHICH(10),BACKUP(10),  07239000
     *FROM(10),TO(10),VALUE(10),TYPE(10),PLY                            07240000
      COMMON /TYPES/ NORMAL,CASTRT,CASTLF,ENPASS,PROMOTE                07241000
      COMMON /TRCE CM/ STRACE(20),TSCORE                                07242000
      COMMON /P V MOVE/ PVMOVE, OVMOVE                                  07243000
      COMMON /THNK CM/ PTYPE8, PTO8, PFROM8                             07244000
      COMMON /MOV TIM/ MELAP, MSEC1, MSEC2                              07245000
      COMMON /BOOK CM/ KEY ,IN BOOK                                     07246000
      COMMON /PRED CM/ PTEXT(30)                                        07247000
      COMMON /BUFFER/ TEXT(30)                                          07248000
      COMMON /BOARD/ BOARD(120)                                         07249000
      COMMON /INFO/ TYPE8, VALUE8, TO8, FROM8                           07250000
      IF(FOUNDM.OR.IN BOOK) RETURN                                      07251000
C                                                                       07252000
C------------------------------< REMEMBER PREDICTED MOVE                07253000
C                                                                       07254000
      MOVE=MOVE+1                                                       07255000
      FROM8=STRACE(2)                                                   07256000
      CALL EXTRCT                                                       07257000
      FOUNDM=.FALSE.                                                    07258000
      MTCHED=.FALSE.                                                    07259000
      PTO8=TO8                                                          07260000
      PFROM8=FROM8                                                      07261000
      PTYPE8=TYPE8                                                      07262000
C                                                                       07263000
C------------------------------< IF NOT IN THINK-AHEAD MODE, RETURN;    07264000
C------------------------------< OTHERWISE, MAKE THE PREDICTED MOVE     07265000
C------------------------------< AND CALL <LOOK> TO CALCULATE A         07266000
C------------------------------< RESPONSE.                              07267000
C                                                                       07268000
      IF(STRACE(2).EQ.0.OR..NOT. THNK AH) RETURN                        07269000
      CALL OUTMOV(PFROM8,PTO8,PTYPE8,0,0,BOARD)                         07270000
      DO 200 I=1,30                                                     07271000
          PTEXT(I)=TEXT(I)                                              07272000
200   CONTINUE                                                          07273000
      CALL SAVE GB                                                      07274000
      PLY=20                                                            07275000
      CALL PMOVER                                                       07276000
      ON CONTROLY CALL BRK ON2                                          07277000
      BRKFLG=.FALSE.                                                    07278000
C------------------------------< ACTUAL THINK-AHEAD STARTS HERE         07279000
C                                                                       07280000
      LOOKAH=.TRUE.                                                     07281000
      CALL PREANL                                                       07282000
      IF(BRKFLG)GOTO 100                                                07283000
      CALL CTIME(MSEC1)                                                 07284000
      IF(BRKFLG) GOTO 100                                               07285000
      CALL LOOK                                                         07286000
      IF(BRKFLG) GOTO 100                                               07287000
      CALL CTIME(MSEC2)                                                 07288000
      MELAP=MSEC2-MSEC1                                                 07289000
      FOUNDM=.TRUE.                                                     07290000
      CALL REST GB                                                      07291000
      LOOKAH=.FALSE.                                                    07292000
      IF(MTCHED) GO TO 300                                              07293000
      RETURN                                                            07294000
C                                                                       07295000
C------------------------------< OPERATOR HIT BREAK AND DID NOT         07296000
C------------------------------< TYPE IN A FULLY QUALIFIED MOVE         07297000
C------------------------------< (OR HE TYPED IN A COMMAND) SO          07298000
C------------------------------< ABORT THE LOOK-AHEAD AND SEE           07299000
C------------------------------< WHAT HE HAS ON HIS MIND.               07300000
C                                                                       07301000
100   FOUNDM=.FALSE.                                                    07302000
      LOOK AH=.FALSE.                                                   07303000
      CALL REST GB                                                      07304000
      RETURN 2                                                          07305000
C                                                                       07306000
C------------------------------< OPERATOR TYPED IN A FULLY QUALIFIED    07307000
C------------------------------< MOVE WHICH MATCHED THE PREDICTED       07308000
C------------------------------< RESPONSE, RETURN SKIPPING THE READ     07309000
C------------------------------< SO HE DON'T GOTTA TYPE IT IN AGAIN.    07310000
C                                                                       07311000
300   TO8=PTO8                                                          07312000
      FROM8=PFROM8                                                      07313000
      TYPE8=PTYPE8                                                      07314000
      RETURN 1                                                          07315000
      END                                                               07316000
      SUBROUTINE TIMEX                                                  07317000
C                                                                       07318000
C       ************************************************************    07319000
C       *                                                          *    07320000
C       *      TIMER IS USED TO OBTAIN ELAPSED/CPU TIME FOR THE    *    07321000
C       *  PROGRAM.  'ETIME' IS THE ELAPSED TIME ENTRY POINT AND   *    07322000
C       * 'CTIME' IS THE CPU TIME ENTRY POINT.  IF THE CLOCK       *    07323000
C       *  TYPE HAS BEEN FORCED TO ELAPSED BY THE 'CT' COMMAND,    *    07324000
C       *  THE CPU TIME ROUTINE RETURNS ELAPSED TIME ALSO.         *    07325000
C       *      ALL TIMES ARE IN SECONDS.                           *    07326000
C       *                                                          *    07327000
C       ************************************************************    07328000
C                                                                       07329000
      IMPLICIT INTEGER*4 (A-Z)                                          07330000
      SYSTEM INTRINSIC TIMER, PROCTIME                                  07331000
      COMMON /INIT/ INITIM                                              07332000
      COMMON /CLOK CM/ CLOCK,CTYPE,CQUERY,GELAP,CELAP,HELAP,            07333000
     *ELAPC,ELAPH,MOVES,SMOVES,SELAP,CTOTAL,HTOTAL,OPTIME               07334000
      LOGICAL CLOCK, CQUERY                                             07335000
      DATA IELAP /0J/, I/500J/                                          07336000
      ENTRY ETIME(TIME)                                                 07337000
200   CONTINUE                                                          07338000
      IELAP=TIMER/1000-INITIM                                           07339000
      TIME=IELAP                                                        07340000
      RETURN                                                            07341000
      ENTRY CTIME(TIME)                                                 07342000
      GO TO (100,200),CTYPE                                             07343000
100   CONTINUE                                                          07344000
      I=PROCTIME/1000                                                   07345000
      TIME=I                                                            07346000
      RETURN                                                            07347000
      END                                                               07348000
      SUBROUTINE TSCORE                                                 07349000
C                                                                       07350000
C       ************************************************************    07351000
C       *                                                          *    07352000
C       *      TSCORE IS USED TO COMPUTE THE SCORE OF THE CURRENT  *    07353000
C       *  VARIATION OF MOVES.  WHEN A TERMINAL NODE IS REACHED,   *    07354000
C       *  TSCORE IS CALLED TO MINIMAX THE PLAUSIBILITY SCORES OF  *    07355000
C       *  EACH MOVE IN THE CURRENT VARIATION.  THIS SIMPLY MEANS  *    07356000
C       *  ADD UP THE SCORES FOR THE COMPUTER MOVES AND SUBTRACT   *    07357000
C       *  THE SCORES FOR THE HUMAN MOVES.  IF THE LAST MOVE IN    *    07358000
C       *  THE VARIATION IS NOT A CASTLE, EXCHNG IS CALLED TO      *    07359000
C       *  ANALYZE THE EXCHANGE POTENTIAL OF THE LAST MOVE.  THIS  *    07360000
C       *  PREVENTS THE PROGRAM FROM GIVING A GOOD SCORE TO A LINE *    07361000
C       *  THAT LEAVE A PIECE OPEN TO CAPTURE.                     *    07362000
C       *                                                          *    07363000
C       ************************************************************    07364000
C                                                                       07365000
      IMPLICIT INTEGER*4 (A-Z)                                          07366000
      COMMON /INFO/ TYPE8, VALUE8, TO8, FROM8                           07367000
      COMMON /TREE/ TREE(400),START(10),STOP(10),WHICH(10),BACKUP(10),  07368000
     *FROM(10),TO(10),VALUE(10),TYPE(10),PLY                            07369000
      COMMON /MSCORE/ SCORE                                             07370000
      COMMON /MOVE CM/ FROMSQ, TOSQ, SIDE                               07371000
      LOGICAL SIDE                                                      07372000
      COMMON /STAT CM/ NODES(10), NGEN, MAXPLY, PRIGHT                  07373000
      COMMON /TYPES/ NORMAL,CASTRT,CASTLF,ENPASS,PROMOTE                07374000
      SCORE=VALUE(1)                                                    07375000
C                                                                       07376000
C------------------------------< MINIMAX THE SCORE FOR THE CURRENT      07377000
C------------------------------< VARIATION UNDER ANALYSIS.              07378000
C                                                                       07379000
      TOGGLE=-1                                                         07380000
      DO 1 I=2,PLY                                                      07381000
          SCORE=SCORE+TOGGLE*VALUE(I)                                   07382000
          TOGGLE=-TOGGLE                                                07383000
1     CONTINUE                                                          07384000
C                                                                       07385000
C------------------------------< IF THE LAST MOVE IS NOT A CASTLE       07386000
C------------------------------< MOVE, CALL EXCHNG TO EVALUATE THE      07387000
C------------------------------< EXCHANGE POSSIBILITIES FOR IT.         07388000
C                                                                       07389000
      IF(TYPE8.EQ.CASTLF.OR.TYPE8.EQ.CASTRT) GO TO 3                    07390000
C                                                                       07391000
C------------------------------< IF THIS MOVE HAS AN EXCHNG SCORE       07392000
C------------------------------< OF ZERO (0), THERE IS NO USE IN        07393000
C------------------------------< EXAMINING FURTHER MOVES AT THIS        07394000
C------------------------------< LEVEL SINCE THE HIGHEST SCORES         07395000
C------------------------------< ARE ORDERED FIRST.  SET THE LAST       07396000
C------------------------------< MOVE POINTER TO THE CURRENT MOVE       07397000
C------------------------------< AND RETURN.                            07398000
C                                                                       07399000
      TEMP=EXCHNG(TO8,SIDE)                                             07400000
      IF(TEMP.GT.0) GO TO 2                                             07401000
      STOP(PLY)=WHICH(PLY)                                              07402000
2     SCORE=SCORE+TOGGLE*TEMP                                           07403000
3     RETURN                                                            07404000
      END                                                               07405000
$CONTROL SEGMENT=CMND                                                   07406000
      SUBROUTINE VCMND(DEVICE)                                          07407000
C                                                                       07408000
C       ************************************************************    07409000
C       *                                                          *    07410000
C       *      VCMND IS USED TO PROCESS THE 'V' COMMAND WHICH OUT- *    07411000
C       *  PUTS THE PRINCIPLE VARIATION FOR THE MACHINE'S CHOSEN   *    07412000
C       *  MOVE.  THE MOVES ARE LISTED AS MACHINES CHOSEN MOVE,    *    07413000
C       *  HUMAN'S BEST RESPONSE, COMPUTER'S BEST RESPONSE, ETC.   *    07414000
C       *  FOR AS DEEP AS THE VARIATION GOES.  OUTPUT MAY GO TO    *    07415000
C       *  THE USER TERMINAL OR THE LINE PRINTER.                  *    07416000
C       *                                                          *    07417000
C       ************************************************************    07418000
C                                                                       07419000
      IMPLICIT INTEGER*4 (A-Z)                                          07420000
      COMMON /BOARD/ BOARD(120)                                         07421000
      COMMON /INFO/ TYPE8, VALUE8, TO8, FROM8                           07422000
      COMMON /TREE/ TREE(400),START(10),STOP(10),WHICH(10),BACKUP(10),  07423000
     *FROM(10),TO(10),VALUE(10),TYPE(10),PLY                            07424000
      COMMON /PRUNE/ WIDTH(10), MIN(10), MAX(10),                       07425000
     * DEPTH, ORDER1, ORDER2                                            07426000
      COMMON /DATA/ CMOVE, SMOVE, HFROM8, HTO8, HTYPE8, MOVE            07427000
      COMMON /TRCE CM/ STRACE(20), TSCORE                               07428000
      COMMON /BUFFER/ TEXT(30)                                          07429000
      COMMON /V CM/ VCMOVE                                              07430000
C                                                                       07431000
C------------------------------< IF NO VARIATION WAS FOUND, RETURN      07432000
C                                                                       07433000
      IF(STRACE(2).EQ.0) GO TO 8                                        07434000
      CALL SAVE GB                                                      07435000
C                                                                       07436000
C------------------------------< UNMAKE PROGRAM'S LAST MOVE             07437000
C                                                                       07438000
      FROM8=VCMOVE                                                      07439000
      CALL EXTRCT                                                       07440000
      PLY=1                                                             07441000
      CALL PUMVER                                                       07442000
1     WRITE(DEVICE,2)                                                   07443000
2     FORMAT(1X,'ORDER VALUE  MOVE')                                    07444000
C                                                                       07445000
C------------------------------< DETERMINE DEPTH OF VARIATION           07446000
C                                                                       07447000
      MAXD=9999-IABS(TSCORE)                                            07448000
      IF(MAXD.GT.DEPTH) MAXD=DEPTH                                      07449000
3     CONTINUE                                                          07450000
C                                                                       07451000
C------------------------------< CONVERT MOVES AND OUTPUT WITH SCORES   07452000
C                                                                       07453000
4     DO 6 PLY=1,MAXD                                                   07454000
      FROM8=STRACE(PLY)                                                 07455000
      CALL EXTRCT                                                       07456000
      ETYPE8=0                                                          07457000
      IF(ABS(TSCORE).GT.7900.AND.PLY.EQ.MAXD)    ETYPE8=3               07458000
      CALL OUTMOV(FROM8,TO8,TYPE8,ETYPE8,PLY,BOARD)                     07459000
      T=STRACE(PLY+10)+1                                                07460000
      WRITE(DEVICE,5)T,VALUE8,TEXT                                      07461000
5     FORMAT(2X,I3,1X,I6,2X,30R1)                                       07462000
6     CALL MOVER                                                        07463000
      WRITE(DEVICE,7)TSCORE                                             07464000
7     FORMAT(1X,'MINIMAXED SCORE: ',I5)                                 07465000
      CALL REST GB                                                      07466000
      RETURN                                                            07467000
8     WRITE(DEVICE,9)                                                   07468000
      RETURN                                                            07469000
9     FORMAT(1X,'NO VARIATION IS PRESENT')                              07470000
      END                                                               07471000
      INTEGER FUNCTION WORTH(SQUARE,SIDE)                               07472000
C                                                                       07473000
C       ************************************************************    07474000
C       *                                                          *    07475000
C       *      WORTH COMPUTES THE VALUE OR WORTH OF A PIECE ON A   *    07476000
C       *  GIVEN SQUARE FOR EITHER SIDE.  THE VALUE IS THE VALUE   *    07477000
C       *  OF THE PIECE PLUS THE VALUE RETURNED BY THE SCORING     *    07478000
C       *  FUNCTION FOR THAT PIECE.                                *    07479000
C       *                                                          *    07480000
C       ************************************************************    07481000
C                                                                       07482000
      IMPLICIT INTEGER*4 (A-Z)                                          07483000
      COMMON /BOARD/ BOARD(120)                                         07484000
      COMMON /PIEC CM/ PVALUE(13), PINIT(13)                            07485000
      LOGICAL SIDE                                                      07486000
C                                                                       07487000
C------------------------------< COMPUTE MATERIAL VALUE OF PIECE        07488000
C                                                                       07489000
      TEMP=BOARD(SQUARE)                                                07490000
      WORTH=PVALUE(TEMP)                                                07491000
C                                                                       07492000
C------------------------------< COMPUTE TACTICAL VALUE OF PIECE        07493000
C                                                                       07494000
      TEMP=MOD(TEMP,7)                                                  07495000
      GO TO (100,200,300,400,500,600,999,                               07496000
     *       100,200,300,400,500,600,999),TEMP                          07497000
100   WORTH=WORTH+PSCORE(SQUARE,SIDE)                                   07498000
      GO TO 999                                                         07499000
200   WORTH=WORTH+NSCORE(SQUARE,SIDE)                                   07500000
      GO TO 999                                                         07501000
300   WORTH=WORTH+BSCORE(SQUARE,SIDE)                                   07502000
      GO TO 999                                                         07503000
400   WORTH=WORTH+RSCORE(SQUARE,SIDE)                                   07504000
      GO TO 999                                                         07505000
500   WORTH=WORTH+QSCORE(SQUARE,SIDE)                                   07506000
      GO TO 999                                                         07507000
600   WORTH=WORTH+KSCORE(SQUARE,SIDE)                                   07508000
999   RETURN                                                            07509000
      END                                                               07510000
      GO TO 999                                                         07505000
500   WORTH=WORTH+QSCORE(SQUARE,SIDE)                                   07506000
      GO TO 999                                                         07507000
600   WORTH=WORTH+KSCORE(SQUARE,SIDE)                                   07508000
999   RETURN                                                            07509000
      END                                                               07510000
      GO TO 999                                                         07505000
500   WORTH=WORTH+QSCORE(SQUARE,SIDE)                                   07506000
      GO TO 999                                                         07507000
600   WORTH=WORTH+KSCORE(SQUARE,SIDE)                                   07508000
999   RETURN                                                            07509000
      END                                                               07510000
      GO TO 999                                                         07505000
500   WORTH=WORTH+QSCORE(SQUARE,SIDE)                                   07506000
      GO TO 999                                                         07507000
600   WORTH=WORTH+KSCORE(SQUARE,SIDE)                                   07508000
999   RETURN                                                            07509000
      END                                                               07510000
      GO TO 999                                                         07505000
500   WORTH=WORTH+QSCORE(SQUARE,SIDE)                                   07506000
