#include <perms.h>

//          Edinburgh IMP77 Compiler - Version 8.4
//
//     1  %EXTERNALROUTINE DRAUGHTS(%STRING(12) S)

void DRAUGHTS(_imp_string12 S) {
  //     2  !%EXTERNALROUTINESPEC CPULIMIT (%STRING(255) S)
  //     3  %EXTERNALROUTINESPEC PROMPT(%STRING(15) S)

  extern void PROMPT(_imp_string15 S);

  //     4  %OWNINTEGER MOB WT = 6

  static int MOBWT = 6;

  //     5  %CONSTINTEGER TRUE =1, FALSE = 0
  //     6
  //     7  %OWNINTEGER BACK WT = 4

  static int BACKWT = 4;

  //     8  %OWNINTEGER CENT WT = 4

  static int CENTWT = 4;

  //     9  %OWNINTEGER ADV1 WT = 450

  static int ADV1WT = 450;

  //    10  %OWNINTEGER ADV2 WT = 50

  static int ADV2WT = 50;

  //    11  %OWNINTEGER CRAMP WT = 6

  static int CRAMPWT = 6;

  //    12  %OWNINTEGER MON = 'Q'

  static int MON = 81;

  //    13  %OWNINTEGER A WIN = 0

  static int AWIN = 0;

  //    14  %OWNINTEGER SEARCH LIMIT = 3

  static int SEARCHLIMIT = 3;

  //    15  %OWNINTEGER CROWN = 1800

  static int CROWN = 1800;

  //    16  %OWNINTEGERARRAY BACK1(1:5) = 77, 75, 73, 71, 64

  static int BACK1[5] = {77, 75, 73, 71, 64};
  struct _imp_dv BACK1_dv = {BACK1, sizeof(int) /*, dims, <bounds> */};

  //    17  %OWNINTEGERARRAY BACK2(1:5) =  0,  2,  4,  6, 13

  static int BACK2[5] = {0, 2, 4, 6, 13};
  struct _imp_dv BACK2_dv = {BACK2, sizeof(int) /*, dims, <bounds> */};

  //    18  %OWNINTEGERARRAY CENTSQ(0:7) = 51, 53, 42, 44, 33, 35, 24, 26

  static int CENTSQ[8] = {51, 53, 42, 44, 33, 35, 24, 26};
  struct _imp_dv CENTSQ_dv = {CENTSQ, sizeof(int) /*, dims, <bounds> */};

  //    19  %OWNINTEGERARRAY MOVE(0:7) =  9, 18, 11, 22, -9,-18,-11,-22

  static int MOVE[8] = {9, 18, 11, 22, -9, -18, -11, -22};
  struct _imp_dv MOVE_dv = {MOVE, sizeof(int) /*, dims, <bounds> */};

  //    20  %OWNINTEGERARRAY PLAYER1(-1:26) =     'W',    1,

  static int PLAYER1[28] = {87,   1,    77,   75,   73,   71,   64,   66,   62,   60,   57,   55,   53, 51,
                            1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 12, 0};
  struct _imp_dv PLAYER1_dv = {PLAYER1, sizeof(int) /*, dims, <bounds> */};

  //    21+    77,   75,   73,   71,   64,   66,   62,   60,   57,   55,   53,   51,
  //    22+  1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000,
  //    23+    12,    0
  //    24  %OWNINTEGERARRAY PLAYER2(-1:26) =     'B',    2,

  static int PLAYER2[28] = {66,   2,    0,    2,    4,    6,    13,   11,   15,   17,   20,   22,   24, 26,
                            1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 12, 0};
  struct _imp_dv PLAYER2_dv = {PLAYER2, sizeof(int) /*, dims, <bounds> */};

  //    25+     0,    2,    4,    6,   13,   11,   15,   17,   20,   22,   24,   26,
  //    26+  1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000,
  //    27+    12,    0
  //    28  %OWNINTEGERARRAY BOARD(-1:78) = %C

  static int BOARD[80] = {32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
                          32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
                          32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
                          32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32};
  struct _imp_dv BOARD_dv = {BOARD, sizeof(int) /*, dims, <bounds> */};

  //    29+   ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
  //    30+   ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
  //    31+   ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
  //    32+   ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
  //    33+   ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
  //    34+   ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
  //    35+   ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
  //    36+   ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '
  //    37  %INTEGERARRAY MIN, MAX(1:12)

  int MIN[12];
  struct _imp_dv MIN_dv = {MIN, sizeof(int) /*, dims, <bounds> */};

  int MAX[12];
  struct _imp_dv MAX_dv = {MAX, sizeof(int) /*, dims, <bounds> */};

  //    38  %INTEGERARRAY REPLY(1:9)

  int REPLY[9];
  struct _imp_dv REPLY_dv = {REPLY, sizeof(int) /*, dims, <bounds> */};

  //    39  %INTEGERARRAY COMP, OPP(-1:26)

  int COMP[28];
  struct _imp_dv COMP_dv = {COMP, sizeof(int) /*, dims, <bounds> */};

  int OPP[28];
  struct _imp_dv OPP_dv = {OPP, sizeof(int) /*, dims, <bounds> */};

  //    40  %INTEGERNAME COMPNUM, OPPNUM

  int *COMPNUM;
  int *OPPNUM;

  //    41  %INTEGERARRAY PSTACK(1:12);            ! piece position take stack

  int PSTACK[12];
  struct _imp_dv PSTACK_dv = {PSTACK, sizeof(int) /*, dims, <bounds> */};

  //    42  %INTEGERARRAY TSTACK(1:12);            ! piece type stack

  int TSTACK[12];
  struct _imp_dv TSTACK_dv = {TSTACK, sizeof(int) /*, dims, <bounds> */};

  //    43  %INTEGERARRAY NSTACK(1:12);            ! piece number stack

  int NSTACK[12];
  struct _imp_dv NSTACK_dv = {NSTACK, sizeof(int) /*, dims, <bounds> */};

  //    44  %OWNINTEGER SP;                        ! stack pointer

  static int SP;

  //    45  %OWNINTEGER ME = 1

  static int ME = 1;

  //    46  %OWNINTEGER ONE = 1

  static int ONE = 1;

  //    47  %OWNINTEGER TWO = 2

  static int TWO = 2;

  //    48  %OWNINTEGER THREE = 3

  static int THREE = 3;

  //    49  %INTEGER BEST PIECE, BEST MOVE, BEST TAKE

  int BESTPIECE;
  int BESTMOVE;
  int BESTTAKE;

  //    50  %INTEGER VALUEB, I, P, M, PIECE, JMAN, JUMP, DIF, MODIF, MORE

  int VALUEB;
  int I;
  int P;
  int M;
  int PIECE;
  int JMAN;
  int JUMP;
  int DIF;
  int MODIF;
  int MORE;

  //    51  %INTEGER OLDPOS, NEWPOS, LASTPOS, COMPOS

  int OLDPOS;
  int NEWPOS;
  int LASTPOS;
  int COMPOS;

  //    52  %INTEGER NODES, PLY NUMBER, EXPECTED MOVE

  int NODES;
  int PLYNUMBER;
  int EXPECTEDMOVE;

  //    53  %INTEGER A,B,C,POS

  int A;
  int B;
  int C;
  int POS;

  //    54
  //    55  !*   P L A Y I N G   F U N C T I O N S
  //    56
  //    57     %INTEGERFN VALID POS(%INTEGER POS)

  int VALIDPOS(int POS) {
    //    58     %INTEGER I

    int I;

    //    59        ! on the board?
    //    60        I = POS>>1

    I = (unsigned int)POS >> 1;

    //    61        %RESULT = -1 %IF POS < 0 %OR POS > 77 %C

    if (POS < 0) goto L_0001;
    if (POS > 77) goto L_0001;
    if (I == 4) goto L_0001;
    if (I == 14) goto L_0001;
    if (I == 24) goto L_0001;
    if (I != 34) goto L_0002;
  L_0001:;
    return -1;
  L_0002:;

  //    62+                    %OR I = 4 %OR I = 14 %OR I = 24 %OR I = 34
  //    63        ! square vacant?
  //    64        %CYCLE I = 1, 1, 12

    // %for I = 1, 1, 12 %cycle
    {
      I = 0;
    L_0003:
      if (I == 12) goto L_0004;
      I += 1;

      //    65           %RESULT = 1 %IF (I <= COMPNUM %AND POS = COMP(I)) %C

      if (I > *COMPNUM) goto L_0006;
      if (POS == COMP[I + 1]) goto L_0007;
    L_0006:;
      if (I > *OPPNUM) goto L_0008;
      if (POS != OPP[I + 1]) goto L_0008;
    L_0007:;
      return 1;
    L_0008:;

    //    66+                      %OR (I <= OPPNUM %AND POS = OPP(I))
    //    67        %REPEAT

      goto L_0003;
    }

  L_0004:;

  //    68        %RESULT = 0

    return 0;

    //    69     %END

  } /* end of VALIDPOS */

  //    70
  //    71     %INTEGERFN VALID MOVE(%INTEGER M, P, %INTEGERARRAYNAME COMP, OPP)

  int VALIDMOVE(int M, int P, int *COMP, int *OPP) {
    //    72        %INTEGER CPOS, I, T

    int CPOS;
    int I;
    int T;

    //    73        %UNLESS COMP(P+12) = CROWN %START

    if (COMP[/*BUG*/ P + 12] == CROWN) goto L_0009;

      //    74           %IF COMP(0) = 1 %START;       ! player 1

    if (COMP[/*BUG*/ 0] != 1) goto L_000A;

      //    75              %RESULT = -1 %IF M&4 = 0;  ! backward move

    if (M & 4 != 0) goto L_000B;
    return -1;
  L_000B:;

  //    76           %FINISH %ELSE %START;         ! else player 2

    goto L_000C;
  L_000A:;

  //    77              %RESULT = -1 %IF M&4 # 0;  ! backward move

    if (M & 4 == 0) goto L_000D;
    return -1;
  L_000D:;

  //    78           %FINISH

  L_000C:;

  //    79        %FINISH

  L_0009:;

  //    80        CPOS = COMP(P)

    CPOS = COMP[/*BUG*/ P];

    //    81        %RESULT = -1 %UNLESS VALID POS(CPOS+MOVE(M)) = 0

    if (VALIDPOS(CPOS + MOVE[M]) == 0) goto L_000E;
    return -1;
  L_000E:;

  //    82        %RESULT = 0 %IF M&1 = 0;         ! ordinary move

    if (M & 1 != 0) goto L_000F;
    return 0;
  L_000F:;

  //    83        %RESULT = -1 %IF OPP(25)=0

    if (OPP[/*BUG*/ 25] != 0) goto L_0010;
    return -1;
  L_0010:;

  //    84        I = CPOS+MOVE(M-1);              !  else take-move

    I = CPOS + MOVE[M - 1];

    //    85        %CYCLE T = 1, 1, OPP(25)

    // %for T = 1, 1, OPP[/*BUG*/25] %cycle
    {
      int _final = OPP[/*BUG*/ 25];
      if (invalid_for_loop(1, 1, _final)) _imp_signal(5, 1, 0, "Illegal cycle T = 1, 1, OPP[/*BUG*/25]");
      T = 0;
    L_0011:
      if (T == _final) goto L_0012;
      T += 1;

      //    86           %RESULT = T %IF I = OPP(T);   ! piece to take?

      if (I != OPP[/*BUG*/ T]) goto L_0013;
      return T;
    L_0013:;

    //    87        %REPEAT

      goto L_0011;
    }

  L_0012:;

  //    88        %RESULT = -1

    return -1;

    //    89     %END

  } /* end of VALIDMOVE */

  //    90
  //    91     %INTEGERFN PENDING MOVE(%INTEGERARRAYNAME COMP, OPP)

  int PENDINGMOVE(int *COMP, int *OPP) {
    //    92     %INTEGER P, M, T, COMPNUM

    int P;
    int M;
    int T;
    int COMPNUM;

    //    93        COMPNUM = COMP(25)

    COMPNUM = COMP[/*BUG*/ 25];

    //    94        %RESULT = -1 %IF COMPNUM = 0;    ! no pieces left!!

    if (COMPNUM != 0) goto L_0014;
    return -1;
  L_0014:;

  //    95        %CYCLE P = 1, 1, COMPNUM

    // %for P = 1, 1, COMPNUM %cycle
    {
      int _final = COMPNUM;
      if (invalid_for_loop(1, 1, _final)) _imp_signal(5, 1, 0, "Illegal cycle P = 1, 1, COMPNUM");
      P = 0;
    L_0015:
      if (P == _final) goto L_0016;
      P += 1;

      //    96           %CYCLE M = 1, 2, 7

      // %for M = 1, 2, 7 %cycle
      {
        M = -1;
      L_0017:
        if (M == 7) goto L_0018;
        M += 2;

        //    97              T = VALID MOVE(M, P, COMP, OPP)

        T = VALIDMOVE(M, P, COMP, OPP);

        //    98              %RESULT = P %IF T > 0;     ! return piece doing take

        if (T <= 0) goto L_001A;
        return P;
      L_001A:;

      //    99           %REPEAT

        goto L_0017;
      }

    L_0018:;

    //   100        %REPEAT

      goto L_0015;
    }

  L_0016:;

  //   101        ! ordinary moves
  //   102        %CYCLE P = 1, 1, COMPNUM

    // %for P = 1, 1, COMPNUM %cycle
    {
      int _final = COMPNUM;
      if (invalid_for_loop(1, 1, _final)) _imp_signal(5, 1, 0, "Illegal cycle P = 1, 1, COMPNUM");
      P = 0;
    L_001B:
      if (P == _final) goto L_001C;
      P += 1;

      //   103           %CYCLE M = 0, 2, 6

      // %for M = 0, 2, 6 %cycle
      {
        M = -2;
      L_001D:
        if (M == 6) goto L_001E;
        M += 2;

        //   104              T = VALID MOVE(M, P, COMP, OPP)

        T = VALIDMOVE(M, P, COMP, OPP);

        //   105              %RESULT = 0 %IF T = 0;     ! move ok

        if (T != 0) goto L_001F;
        return 0;
      L_001F:;

      //   106           %REPEAT

        goto L_001D;
      }

    L_001E:;

    //   107        %REPEAT

      goto L_001B;
    }

  L_001C:;

  //   108        %RESULT = -1;                   ! no moves

    return -1;

    //   109     %END

  } /* end of PENDINGMOVE */

  //   110
  //   111     %INTEGERFN CROWNING(%INTEGER POS, PLAYER)

  int CROWNING(int POS, int PLAYER) {
    //   112        ! assumes valid pos
    //   113        %RESULT=TRUE %IF (PLAYER = 1 %AND POS < 7) %C

    if (PLAYER != 1) goto L_0020;
    if (POS < 7) goto L_0005;
  L_0020:;
    if (PLAYER != 2) goto L_0021;
    if (POS <= 70) goto L_0021;
  L_0005:;
    return 1;
  L_0021:;

  //   114+             %OR (PLAYER = 2 %AND POS > 70)
  //   115        %RESULT=FALSE

    return 0;

    //   116     %END

  } /* end of CROWNING */

  //   117
  //   118     %INTEGERFN MOD(%INTEGER N)

  int MOD(int N) {
    //   119
    //   120        %RESULT = -N %IF N<0

    if (N >= 0) goto L_0022;
    return -N;
  L_0022:;

  //   121        %RESULT = N

    return N;

    //   122
    //   123     %END

  } /* end of MOD */

  //   124
  //   125     %INTEGERFN VALUE OF SIDE(%INTEGERARRAYNAME COMP, OPP)

  int VALUEOFSIDE(int *COMP, int *OPP) {
    //   126     %INTEGER V1, V2, V3, V4, V5, V6, V7

    int V1;
    int V2;
    int V3;
    int V4;
    int V5;
    int V6;
    int V7;

    //   127     %INTEGER P, PP, M, MM, MV, ADV1, VM, PLAYER

    int P;
    int PP;
    int M;
    int MM;
    int MV;
    int ADV1;
    int VM;
    int PLAYER;

    //   128     %INTEGERNAME CPOS, CTYPE

    int *CPOS;
    int *CTYPE;

    //   129        PLAYER = COMP(0)

    PLAYER = COMP[/*BUG*/ 0];

    //   130
    //   131        ! back control
    //   132        V2 = 0

    V2 = 0;

    //   133        %IF OPP(26) = 0 %START;          ! OPP has no crowns yet

    if (OPP[/*BUG*/ 26] != 0) goto L_0023;

      //   134           %IF PLAYER = 1 %START;        ! player 1

    if (PLAYER != 1) goto L_0024;

      //   135              %CYCLE P = 1, 1, 5

    // %for P = 1, 1, 5 %cycle
    {
      P = 0;
    L_0025:
      if (P == 5) goto L_0026;
      P += 1;

      //   136                 V2 = V2+BACK WT %IF COMP(P) = BACK1(P)

      if (COMP[/*BUG*/ P] != BACK1[P - 1]) goto L_0028;
      V2 = V2 + BACKWT;
    L_0028:;

    //   137              %REPEAT

      goto L_0025;
    }

  L_0026:;

  //   138           %FINISH %ELSE %START;         ! player 2

    goto L_0029;
  L_0024:;

  //   139              %CYCLE P = 1, 1, 5

    // %for P = 1, 1, 5 %cycle
    {
      P = 0;
    L_002A:
      if (P == 5) goto L_002B;
      P += 1;

      //   140                 V2 = V2+BACK WT %IF COMP(P) = BACK2(P)

      if (COMP[/*BUG*/ P] != BACK2[P - 1]) goto L_002C;
      V2 = V2 + BACKWT;
    L_002C:;

    //   141              %REPEAT

      goto L_002A;
    }

  L_002B:;

  //   142           %FINISH

  L_0029:;

  //   143        %FINISH

  L_0023:;

  //   144
  //   145        V1 = 0;  V3 = 0;  V4 = 0;  V5 = 0;  V6 = 0;  V7 = 0

    V1 = 0;
    V3 = 0;
    V4 = 0;
    V5 = 0;
    V6 = 0;
    V7 = 0;

    //   146        %CYCLE P = 1, 1, COMP(25)

    // %for P = 1, 1, COMP[/*BUG*/25] %cycle
    {
      int _final = COMP[/*BUG*/ 25];
      if (invalid_for_loop(1, 1, _final)) _imp_signal(5, 1, 0, "Illegal cycle P = 1, 1, COMP[/*BUG*/25]");
      P = 0;
    L_002D:
      if (P == _final) goto L_002E;
      P += 1;

      //   147           CPOS ==COMP(P);  CTYPE ==  COMP(P+12)

      CPOS = (int *)/*?*/ &COMP[/*BUG*/ P];
      CTYPE = (int *)/*?*/ &COMP[/*BUG*/ P + 12];

      //   148           ADV1 = 0

      ADV1 = 0;

      //   149
      //   150           ! add up piece values
      //   151           V1 = V1+CTYPE

      V1 = V1 + *CTYPE;

      //   152
      //   153           %CYCLE M = 0, 1, 7

      // %for M = 0, 1, 7 %cycle
      {
        M = -1;
      L_0030:
        if (M == 7) goto L_0031;
        M += 1;

        //   154              VM = VALID MOVE(M, P, COMP, OPP)

        VM = VALIDMOVE(M, P, COMP, OPP);

        //   155              MV = MOVE(M)

        MV = MOVE[M];

        //   156
        //   157              ! centre control
        //   158              %IF CPOS = CENTSQ(M) %START

        if (*CPOS != CENTSQ[M]) goto L_0032;

          //   159                 V4 = V4+CENT WT

        V4 = V4 + CENTWT;

        //   160                 V4 = V4+CENT WT+1 %IF CTYPE = CROWN

        if (*CTYPE != CROWN) goto L_0033;
        V4 = V4 + CENTWT + 1;
      L_0033:;

      //   161              %FINISH

      L_0032:;

      //   162
      //   163              %IF VM >= 0 %START

        if (VM < 0) goto L_0034;

          //   164
          //   165                 ! mobility
          //   166                 V3 = V3+MOB WT

        V3 = V3 + MOBWT;

        //   167                 V3 = V3+MOB WT %IF VM > 0

        if (VM <= 0) goto L_0035;
        V3 = V3 + MOBWT;
      L_0035:;

      //   168
      //   169                 %IF CTYPE # CROWN %START

        if (*CTYPE == CROWN) goto L_0036;

          //   170
          //   171                    ! advancement 1
          //   172                    %IF ADV1 = 0 %AND TRUE=CROWNING(CPOS+MV, PLAYER) %THEN %C

        if (ADV1 != 0) goto L_0037;
        if (1 != CROWNING(*CPOS + MV, PLAYER)) goto L_0037;
        V5 = V5 + ADV1WT;
        ADV1 = 1;
      L_0037:;

      //   173+                    V5 = V5+ADV1 WT %AND ADV1 = 1
      //   174
      //   175                    ! advancement 2
      //   176                    %IF VM = 0 %START;   ! ignore jumps to crown

        if (VM != 0) goto L_0038;

          //   177                       CPOS = CPOS+MV

        *CPOS = *CPOS + MV;

        //   178                       %CYCLE MM = 0, 2, 6

        // %for MM = 0, 2, 6 %cycle
        {
          MM = -2;
        L_0039:
          if (MM == 6) goto L_003A;
          MM += 2;

          //   179                          %IF TRUE=CROWNING(CPOS+MOVE(MM), PLAYER) %C

          if (1 != CROWNING(*CPOS + MOVE[MM], PLAYER)) goto L_003C;
          if (VALIDMOVE(MM, P, COMP, OPP) < 0) goto L_003C;

            //   180+                          %AND VALID MOVE(MM, P, COMP, OPP) >= 0 %START
            //   181                             V6 = V6+ADV2 WT;  %EXIT

          V6 = V6 + ADV2WT;
          goto L_003A;

          //   182                          %FINISH

        L_003C:;

        //   183                       %REPEAT

          goto L_0039;
        }

      L_003A:;

      //   184                       CPOS = CPOS-MV

        *CPOS = *CPOS - MV;

        //   185                    %FINISH

      L_0038:;

      //   186                 %FINISH

      L_0036:;

      //   187
      //   188                 ! cramp
      //   189                 %IF VM = 0 %AND CTYPE = CROWN %AND OPP(25) > 0 %START

        if (VM != 0) goto L_003D;
        if (*CTYPE != CROWN) goto L_003D;
        if (OPP[/*BUG*/ 25] <= 0) goto L_003D;

          //   190                    CPOS = CPOS+MV

        *CPOS = *CPOS + MV;

        //   191                    %CYCLE PP = 1, 1, OPP(25)

        // %for PP = 1, 1, OPP[/*BUG*/25] %cycle
        {
          int _final = OPP[/*BUG*/ 25];
          if (invalid_for_loop(1, 1, _final)) _imp_signal(5, 1, 0, "Illegal cycle PP = 1, 1, OPP[/*BUG*/25]");
          PP = 0;
        L_003E:
          if (PP == _final) goto L_003F;
          PP += 1;

          //   192                       %CYCLE MM = 1, 2, 7

          // %for MM = 1, 2, 7 %cycle
          {
            MM = -1;
          L_0041:
            if (MM == 7) goto L_0042;
            MM += 2;

            //   193                          %IF VALID MOVE(MM, PP, OPP, COMP) >= 0 %START

            if (VALIDMOVE(MM, PP, OPP, COMP) < 0) goto L_0043;

              //   194                             V5 = V5-CRAMP WT;  %EXIT

            V5 = V5 - CRAMPWT;
            goto L_0042;

            //   195                          %FINISH

          L_0043:;

          //   196                       %REPEAT

            goto L_0041;
          }

        L_0042:;

        //   197                    %REPEAT

          goto L_003E;
        }

      L_003F:;

      //   198                    CPOS = CPOS-MV

        *CPOS = *CPOS - MV;

        //   199                 %FINISH

      L_003D:;

      //   200              %FINISH

      L_0034:;

      //   201           %REPEAT

        goto L_0030;
      }

    L_0031:;

    //   202        %REPEAT

      goto L_002D;
    }

  L_002E:;

  //   203        %RESULT = V1+V2+V3+V4+V5+V6+V7

    return V1 + V2 + V3 + V4 + V5 + V6 + V7;

    //   204     %END

  } /* end of VALUEOFSIDE */

  //   205
  //   206     %INTEGERFN VALUE OF POS(%INTEGERARRAYNAME COMP, OPP)

  int VALUEOFPOS(int *COMP, int *OPP) {
    //   207     %INTEGER VALUE

    int VALUE;

    //   208        %IF PENDING MOVE(COMP, OPP) >= 0 %START

    if (PENDINGMOVE(COMP, OPP) < 0) goto L_0044;

      //   209           VALUE = VALUE OF SIDE(COMP, OPP)-VALUE OF SIDE(OPP, COMP)-PLY NUMBER

    VALUE = VALUEOFSIDE(COMP, OPP) - VALUEOFSIDE(OPP, COMP) - PLYNUMBER;

    //   210        %FINISH %ELSE VALUE = -100000+PLYNUMBER;   ! no mobility!!

    goto L_0045;
  L_0044:;
    VALUE = (-100000) + PLYNUMBER;
  L_0045:;

  //   211        %RESULT = VALUE %IF COMP(0) = ME

    if (COMP[/*BUG*/ 0] != ME) goto L_0046;
    return VALUE;
  L_0046:;

  //   212        %RESULT = -VALUE

    return -VALUE;

    //   213     %END

  } /* end of VALUEOFPOS */

  //   214
  //   215     %ROUTINE MAKE MOVE(%INTEGER MV, P, %INTEGERNAME T, %C

  void MAKEMOVE(int MV, int P, int *T, int *COMP, int *OPP) {
    //   216+                                      %INTEGERARRAYNAME COMP, OPP)
    //   217     %INTEGERNAME CPOS, CTYPE, OPOS, OTYPE, ONUM, ONUMC

    int *CPOS;
    int *CTYPE;
    int *OPOS;
    int *OTYPE;
    int *ONUM;
    int *ONUMC;

    //   218        CPOS == COMP(P);  CTYPE == COMP(P+12)

    CPOS = (int *)/*?*/ &COMP[/*BUG*/ P];
    CTYPE = (int *)/*?*/ &COMP[/*BUG*/ P + 12];

    //   219        CPOS = CPOS+MV

    *CPOS = *CPOS + MV;

    //   220        %IF T # 0 %START;                ! a take

    if (*T == 0) goto L_0047;

      //   221           OPOS == OPP(T);  OTYPE == OPP(T+12)

    OPOS = (int *)/*?*/ &OPP[/*BUG*/ *T];
    OTYPE = (int *)/*?*/ &OPP[/*BUG*/ *T + 12];

    //   222           ONUM == OPP(25);  ONUMC == OPP(26)

    ONUM = (int *)/*?*/ &OPP[/*BUG*/ 25];
    ONUMC = (int *)/*?*/ &OPP[/*BUG*/ 26];

    //   223           SP = SP+1

    SP = SP + 1;

    //   224           PSTACK(SP) = OPOS;            ! save position of taken piece

    PSTACK[SP - 1] = *OPOS;

    //   225           TSTACK(SP) = OTYPE;           ! save piece type

    TSTACK[SP - 1] = *OTYPE;

    //   226           NSTACK(SP) = T;               ! save piece number

    NSTACK[SP - 1] = *T;

    //   227           OPOS = OPP(ONUM);             ! remove piece from board

    *OPOS = OPP[/*BUG*/ *ONUM];

    //   228           ONUM = ONUM-1;                ! reduce piece count for opp

    *ONUM = *ONUM - 1;

    //   229           ONUMC = ONUMC-1 %IF OTYPE = CROWN

    if (*OTYPE != CROWN) goto L_0048;
    *ONUMC = *ONUMC - 1;
  L_0048:;

  //   230           OTYPE = OPP(ONUM+13)

    *OTYPE = OPP[/*BUG*/ *ONUM + 13];

    //   231        %FINISH

  L_0047:;

  //   232        %IF CTYPE # CROWN %AND TRUE=CROWNING(CPOS, COMP(0)) %START

    if (*CTYPE == CROWN) goto L_0049;
    if (1 != CROWNING(*CPOS, COMP[/*BUG*/ 0])) goto L_0049;

      //   233           CTYPE = CROWN;                ! crown piece

    *CTYPE = CROWN;

    //   234           COMP(26) = COMP(26)+1;        ! increase crown count

    COMP[/*BUG*/ 26] = COMP[/*BUG*/ 26] + 1;

    //   235           T = 0;                        ! no more takes

    *T = 0;

    //   236        %FINISH

  L_0049:;

  //   237     %END

    return;
  } /* end of MAKEMOVE */

  //   238
  //   239     %INTEGERFN TRY POSSIBLE MOVES(%INTEGER PLY, DEPTH, %C

  int TRYPOSSIBLEMOVES(int PLY, int DEPTH, int *COMP, int *OPP) {
    //   240+                                  %INTEGERARRAYNAME COMP, OPP)
    //   241     %INTEGER M,MM,MMM,MMF,P,T,TT,APT,VALUE,TAKES,OLDPOS,OLDTYPE

    int M;
    int MM;
    int MMM;
    int MMF;
    int P;
    int T;
    int TT;
    int APT;
    int VALUE;
    int TAKES;
    int OLDPOS;
    int OLDTYPE;

    //   242     %INTEGERNAME MAXPLY, MINPLY

    int *MAXPLY;
    int *MINPLY;

    //   243
    //   244        %INTEGERFN PURSUIT

    int PURSUIT(void) {
      //   245           %RESULT = 1 %IF PLY = 1

      if (PLY != 1) goto L_004A;
      return 1;
    L_004A:;

    //   246           %RESULT = \M&1

      return (~M) & 1;

      //   247        %END

    } /* end of PURSUIT */

    //   248
    //   249        NODES = NODES+1

    NODES = NODES + 1;

    //   250        APT = PENDING MOVE(COMP, OPP)

    APT = PENDINGMOVE(COMP, OPP);

    //   251        PLY NUMBER = PLY-1 %AND %RESULT = VALUE OF POS(COMP, OPP) %C

    if (DEPTH < SEARCHLIMIT) goto L_004B;
    if (APT <= 0) goto L_002F;
  L_004B:;
    if (PLY <= 12) goto L_004C;
  L_002F:;
    PLYNUMBER = PLY - 1;
    return VALUEOFPOS(COMP, OPP);
  L_004C:;

  //   252+        %IF (DEPTH >= SEARCH LIMIT %AND APT <=0) %OR PLY > 12
  //   253        MINPLY == MIN(PLY);  MINPLY = 100000

    MINPLY = (int *)/*?*/ &MIN[PLY - 1];
    *MINPLY = 100000;

    //   254        MAXPLY == MAX(PLY);  MAXPLY =-100000

    MAXPLY = (int *)/*?*/ &MAX[PLY - 1];
    *MAXPLY = -100000;

    //   255        %IF APT >= 0 %START;             ! COMP able to move

    if (APT < 0) goto L_004D;

      //   256           %IF APT > 0 %START;           ! take priority

    if (APT <= 0) goto L_004E;

      //   257              P = APT;  APT = 2;  MMM = 1 ; MMF = 7

    P = APT;
    APT = 2;
    MMM = 1;
    MMF = 7;

    //   258              SEARCH LIMIT = 2 %IF PLY = 1

    if (PLY != 1) goto L_004F;
    SEARCHLIMIT = 2;
  L_004F:;

  //   259           %FINISH %ELSE %START

    goto L_0050;
  L_004E:;

  //   260              P = 1;  APT = 2;  MMM = 0; MMF=6

    P = 1;
    APT = 2;
    MMM = 0;
    MMF = 6;

    //   261           %FINISH

  L_0050:;

  //   262           %CYCLE P = P, 1, COMP(25)

    // %for P = P, 1, COMP[/*BUG*/25] %cycle
    {
      int _initial = P, _final = COMP[/*BUG*/ 25];
      if (invalid_for_loop(_initial, 1, _final)) _imp_signal(5, 1, 0, "Illegal cycle P = P, 1, COMP[/*BUG*/25]");
      P = _initial - (1);
    L_0051:
      if (P == _final) goto L_0052;
      P += 1;

      //   263              OLDPOS = COMP(P);  OLDTYPE = COMP(P+12)

      OLDPOS = COMP[/*BUG*/ P];
      OLDTYPE = COMP[/*BUG*/ P + 12];

      //   264              %CYCLE M = MMM, APT, MMF

      // %for M = MMM, APT, MMF %cycle
      {
        int _initial = MMM, _increment = APT, _final = MMF;
        if (invalid_for_loop(_initial, _increment, _final)) _imp_signal(5, 1, 0, "Illegal cycle M = MMM, APT, MMF");
        M = _initial - _increment;
      L_0053:
        if (M == _final) goto L_0054;
        M += _increment;

        //   265                 TAKES = 0

        TAKES = 0;

        //   266                 T = VALID MOVE(M, P, COMP, OPP)

        T = VALIDMOVE(M, P, COMP, OPP);

        //   267                 %IF T >= 0 %START;               ! valid move

        if (T < 0) goto L_0055;

          //   268                    MM = M;  TT = T

        MM = M;
        TT = T;

        //   269  ANOTHER TAKE:     TAKES = TAKES+1 %IF TT > 0

      U_1000:;
        if (TT <= 0) goto L_0056;
        TAKES = TAKES + 1;
      L_0056:;

      //   270                    MAKE MOVE(MOVE(MM), P, TT, COMP, OPP);! try this move

        MAKEMOVE(MOVE[MM], P, /*?*/ &TT, COMP, OPP);

        //   271                    %IF TT > 0 %START;             ! another take

        if (TT <= 0) goto L_0057;

          //   272                       %CYCLE MM = 1, 2, 7

        // %for MM = 1, 2, 7 %cycle
        {
          MM = -1;
        L_0058:
          if (MM == 7) goto L_0059;
          MM += 2;

          //   273                          TT = VALID MOVE(MM, P, COMP, OPP)

          TT = VALIDMOVE(MM, P, COMP, OPP);

          //   274                          -> ANOTHER TAKE %IF TT > 0

          if (TT <= 0) goto L_005A;
          goto U_1000;
        L_005A:;

        //   275                       %REPEAT

          goto L_0058;
        }

      L_0059:;

      //   276                    %FINISH

      L_0057:;

      //   277                    VALUE = TRY POSSIBLE MOVES(PLY+1, DEPTH+PURSUIT, OPP, COMP)

        VALUE = TRYPOSSIBLEMOVES(PLY + 1, DEPTH + PURSUIT(), OPP, COMP);

        //   278                    COMP(P) = OLDPOS;  COMP(P+12) = OLDTYPE

        COMP[/*BUG*/ P] = OLDPOS;
        COMP[/*BUG*/ P + 12] = OLDTYPE;

        //   279                    OPP(25) = OPP(25)+TAKES

        OPP[/*BUG*/ 25] = OPP[/*BUG*/ 25] + TAKES;

        //   280                    %WHILE TAKES > 0 %CYCLE

      L_005B:;
        if (TAKES <= 0) goto L_005C;

          //   281                       TT = NSTACK(SP)

        TT = NSTACK[SP - 1];

        //   282                       OPP(TT) = PSTACK(SP)

        OPP[/*BUG*/ TT] = PSTACK[SP - 1];

        //   283                       OPP(TT+12) = TSTACK(SP)

        OPP[/*BUG*/ TT + 12] = TSTACK[SP - 1];

        //   284                       TAKES = TAKES-1

        TAKES = TAKES - 1;

        //   285                       SP = SP-1

        SP = SP - 1;

        //   286                    %REPEAT

        goto L_005B;
      L_005C:;

      //   287                    %IF COMP(0) = ME %START

        if (COMP[/*BUG*/ 0] != ME) goto L_005D;

          //   288                       %IF VALUE > MAXPLY %START

        if (VALUE <= *MAXPLY) goto L_005E;

          //   289                          MAXPLY = VALUE

        *MAXPLY = VALUE;

        //   290                          %IF PLY = 1 %START

        if (PLY != 1) goto L_005F;

          //   291                             BEST MOVE = M

        BESTMOVE = M;

        //   292                             BEST TAKE = T

        BESTTAKE = T;

        //   293                             BEST PIECE = P

        BESTPIECE = P;

        //   294                          %FINISH

      L_005F:;

      //   295                       %FINISH

      L_005E:;

      //   296                       %RESULT = MAXPLY %IF PLY # 1 %AND MAXPLY >= MIN(PLY-1)

        if (PLY == 1) goto L_0060;
        if (*MAXPLY < MIN[PLY - 1 - 1]) goto L_0060;
        return *MAXPLY;
      L_0060:;

      //   297                    %FINISH %ELSE %START

        goto L_0061;
      L_005D:;

      //   298                       MINPLY = VALUE %IF VALUE < MINPLY

        if (VALUE >= *MINPLY) goto L_0062;
        *MINPLY = VALUE;
      L_0062:;

      //   299                       %RESULT = MINPLY %IF MINPLY <= MAX(PLY-1)

        if (*MINPLY > MAX[PLY - 1 - 1]) goto L_0063;
        return *MINPLY;
      L_0063:;

      //   300                    %FINISH

      L_0061:;

      //   301                 %FINISH

      L_0055:;

      //   302              %REPEAT

        goto L_0053;
      }

    L_0054:;

    //   303           %REPEAT

      goto L_0051;
    }

  L_0052:;

  //   304        %FINISH

  L_004D:;

  //   305        %RESULT = MAXPLY %IF COMP(0) = ME

    if (COMP[/*BUG*/ 0] != ME) goto L_0064;
    return *MAXPLY;
  L_0064:;

  //   306        %RESULT = MINPLY

    return *MINPLY;

    //   307     %END

  } /* end of TRYPOSSIBLEMOVES */

  //   308
  //   309     %ROUTINE SAY PLEASE

  void SAYPLEASE(void) {
    //   310        PRINTSTRING("Please re-type your move

    _imp_PRINTSTRING(_imp_str_literal("Please re-type your move\n"));

    //   311+ ")
    //   312     %END

    return;
  } /* end of SAYPLEASE */

  //   313
  //   314     %ROUTINE PRINT BOARD

  void PRINTBOARD(void) {
    //   315     %INTEGER I, J, POS

    int I;
    int J;
    int POS;

    //   316        %CYCLE I = 0, 1, 7

    // %for I = 0, 1, 7 %cycle
    {
      I = -1;
    L_0065:
      if (I == 7) goto L_0066;
      I += 1;

      //   317           %CYCLE J = 0, 2, 6

      // %for J = 0, 2, 6 %cycle
      {
        J = -2;
      L_0068:
        if (J == 6) goto L_0069;
        J += 2;

        //   318              BOARD(10*I+J+I&1) = '#'

        BOARD[10 * I + J + (I & 1) + 1] = 35;

        //   319           %REPEAT

        goto L_0068;
      }

    L_0069:;

    //   320        %REPEAT

      goto L_0065;
    }

  L_0066:;

  //   321        %CYCLE I = 1, 1, 12

    // %for I = 1, 1, 12 %cycle
    {
      I = 0;
    L_006A:
      if (I == 12) goto L_006B;
      I += 1;

      //   322           %IF I <= COMP(25) %START

      if (I > COMP[26]) goto L_006C;

        //   323              POS = COMP(I)

      POS = COMP[I + 1];

      //   324             %IF COMP(I+12) = CROWN %THEN BOARD(POS) = 'X' %C

      if (COMP[I + 12 + 1] != CROWN) goto L_006D;
      BOARD[POS + 1] = 88;
      goto L_006E;
    L_006D:;
      BOARD[POS + 1] = 120;
    L_006E:;

    //   325+              %ELSE BOARD(POS) = 'x'
    //   326           %FINISH

    L_006C:;

    //   327           %IF I <= OPP(25) %START

      if (I > OPP[26]) goto L_006F;

        //   328              POS = OPP(I)

      POS = OPP[I + 1];

      //   329              %IF OPP(I+12) = CROWN %THEN BOARD(POS) = 'O' %C

      if (OPP[I + 12 + 1] != CROWN) goto L_0070;
      BOARD[POS + 1] = 79;
      goto L_0071;
    L_0070:;
      BOARD[POS + 1] = 111;
    L_0071:;

    //   330+              %ELSE BOARD(POS) = 'o'
    //   331           %FINISH

    L_006F:;

    //   332        %REPEAT

      goto L_006A;
    }

  L_006B:;

  //   333        PRINTSTRING("

    _imp_PRINTSTRING(_imp_str_literal("\n  A B C D E F G H"));

    //   334+   A B C D E F G H")
    //   335        %CYCLE I = 70, -10, 0

    // %for I = 70,  -10, 0 %cycle
    {
      I = 80;
    L_0072:
      if (I == 0) goto L_0073;
      I -= 10;

      //   336           NEWLINE

      _imp_NEWLINE();

      //   337           PRINTSYMBOL(I//10+'1')

      _imp_PRINTSYMBOL(((long)I / (long)10) + 49);

      //   338           %CYCLE J = 0, 1, 7

      // %for J = 0, 1, 7 %cycle
      {
        J = -1;
      L_0074:
        if (J == 7) goto L_0075;
        J += 1;

        //   339              SPACE

        _imp_SPACE();

        //   340              PRINTSYMBOL(BOARD(J+I))

        _imp_PRINTSYMBOL(BOARD[J + I + 1]);

        //   341           %REPEAT

        goto L_0074;
      }

    L_0075:;

    //   342           SPACE

      _imp_SPACE();

      //   343           PRINTSYMBOL(I//10+'1')

      _imp_PRINTSYMBOL(((long)I / (long)10) + 49);

      //   344        %REPEAT

      goto L_0072;
    }

  L_0073:;

  //   345        PRINTSTRING("

    _imp_PRINTSTRING(_imp_str_literal("\n  A B C D E F G H\n"));

    //   346+   A B C D E F G H
    //   347+ ")
    //   348     %END

    return;
  } /* end of PRINTBOARD */

  //   349
  //   350     %ROUTINE TROUT(%INTEGER OLDPOS, NEWPOS, %INTEGERNAME MODE)

  void TROUT(int OLDPOS, int NEWPOS, int *MODE) {
    //   351     %INTEGER OLDX, OLDY, NEWX, NEWY

    int OLDX;
    int OLDY;
    int NEWX;
    int NEWY;

    //   352        OLDY = OLDPOS//10;  OLDX = OLDPOS-10*OLDY

    OLDY = ((long)OLDPOS / (long)10);
    OLDX = OLDPOS - 10 * OLDY;

    //   353        NEWY = NEWPOS//10;  NEWX = NEWPOS-10*NEWY

    NEWY = ((long)NEWPOS / (long)10);
    NEWX = NEWPOS - 10 * NEWY;

    //   354        %IF MODE = 0 %THEN PRINTSTRING("DRAFT4's move is ") %AND MODE = 1  %C

    if (*MODE != 0) goto L_0076;
    _imp_PRINTSTRING(_imp_str_literal("DRAFT4's move is "));
    *MODE = 1;
    goto L_0077;
  L_0076:;
    _imp_PRINTSTRING(_imp_str_literal(" , "));
  L_0077:;

  //   355+                    %ELSE PRINTSTRING(" , ")
  //   356        PRINTSYMBOL(OLDX+'A')

    _imp_PRINTSYMBOL(OLDX + 65);

    //   357        PRINTSYMBOL(OLDY+'1')

    _imp_PRINTSYMBOL(OLDY + 49);

    //   358        PRINTSYMBOL('-')

    _imp_PRINTSYMBOL(45);

    //   359        PRINTSYMBOL(NEWX+'A')

    _imp_PRINTSYMBOL(NEWX + 65);

    //   360        PRINTSYMBOL(NEWY+'1')

    _imp_PRINTSYMBOL(NEWY + 49);

    //   361     %END

    return;
  } /* end of TROUT */

  //   362
  //   363     %INTEGERFN POSITION OF(%INTEGER S1, S2)

  int POSITIONOF(int S1, int S2) {
    //   364        %RESULT = (S1-'A')+10*(S2-'1')

    return S1 - 65 + 10 * (S2 - 49);

    //   365     %END

  } /* end of POSITIONOF */

  //   366
  //   367     %ROUTINE SKIP SPACES AND NLS

  void SKIPSPACESANDNLS(void) {
    //   368        SKIP SYMBOL %WHILE NEXT SYMBOL=' ' %OR NEXT SYMBOL=NL

  L_0078:;
    if (_imp_NEXTSYMBOL() == 32) goto L_0067;
    if (_imp_NEXTSYMBOL() != 10) goto L_0079;
  L_0067:;
    _imp_SKIPSYMBOL();
    goto L_0078;
  L_0079:;

  //   369     %END

    return;
  } /* end of SKIPSPACESANDNLS */

  //   370
  //   371     COMPNUM == COMP(25);  OPPNUM == OPP(25)

  COMPNUM = (int *)/*?*/ &COMP[26];
  OPPNUM = (int *)/*?*/ &OPP[26];

  //   372     !CPULIMIT ("12"); ! FOR EMAS - JGH MOD, AS CS1 WERE RUNNING OUT
  //   373     PRINTSTRING("The Draughts programme  DRAFT4.4

  _imp_PRINTSTRING(_imp_str_literal("The Draughts programme  DRAFT4.4\n\n"));

  //   374+
  //   375+ ")
  //   376     PRINT STRING("Do you want some help?"); NEWLINE

  _imp_PRINTSTRING(_imp_str_literal("Do you want some help?"));
  _imp_NEWLINE();

  //   377     PROMPT(":")

  PROMPT(_imp_str_literal_size(15, ":"));

  //   378     READ SYMBOL(REPLY(1)); SKIP SYMBOL %WHILE NEXT SYMBOL#NL; SKIP SYMBOL

  _imp_READSYMBOL(/*?*/ &REPLY[0]);
L_007A:;
  if (_imp_NEXTSYMBOL() == 10) goto L_007B;
  _imp_SKIPSYMBOL();
  goto L_007A;
L_007B:;
  _imp_SKIPSYMBOL();

  //   379     REPLY(1) = REPLY(1)-32 %IF REPLY(1)>='a'

  if (REPLY[0] < 97) goto L_007C;
  REPLY[0] = REPLY[0] - 32;
L_007C:;

//   380     %IF REPLY(1)='Y' %START

  if (REPLY[0] != 89) goto L_007D;

    //   381        PRINTSTRING("

  _imp_PRINTSTRING(
      _imp_str_literal("\n\n   Moves are typed in in the following form:  (e.g.)\n\n      C3-D4      move the piece on "
                       "square C3 to square D4."));

  //   382+
  //   383+    Moves are typed in in the following form:  (e.g.)
  //   384+
  //   385+       C3-D4      move the piece on square C3 to square D4.")
  //   386  PRINTSTRING("

  _imp_PRINTSTRING(_imp_str_literal("\n      C3-E5      move C3 to E5, taking the piece on D4\n"));

  //   387+       C3-E5      move C3 to E5, taking the piece on D4
  //   388+ "); PRINTSTRING("      C3-E5,

  _imp_PRINTSTRING(
      _imp_str_literal("      C3-E5,\n      E5-C7      an example of a multiple jump\n\n                               "
                       "                     e.t.c."));

  //   389+       E5-C7      an example of a multiple jump
  //   390+
  //   391+                                                     e.t.c.")
  //   392     %FINISH

L_007D:;

//   393  RESTART:

U_1001:;

//   394     EXPECTED MOVE = 0

  EXPECTEDMOVE = 0;

  //   395     ! setting up the pieces
  //   396     %CYCLE P = -1, 1, 26

  // %for P =  -1, 1, 26 %cycle
  {
    P = -2;
  L_007E:
    if (P == 26) goto L_007F;
    P += 1;

    //   397        COMP(P) = PLAYER1(P)

    COMP[P + 1] = PLAYER1[P + 1];

    //   398        OPP(P) = PLAYER2(P)

    OPP[P + 1] = PLAYER2[P + 1];

    //   399     %REPEAT

    goto L_007E;
  }

L_007F:;

//   400     NEWLINE

  _imp_NEWLINE();

  //   401     PRINT STRING("Do you want to start?")

  _imp_PRINTSTRING(_imp_str_literal("Do you want to start?"));

  //   402     NEWLINE

  _imp_NEWLINE();

  //   403     PROMPT(":")

  PROMPT(_imp_str_literal_size(15, ":"));

  //   404     READ SYMBOL(REPLY(1))

  _imp_READSYMBOL(/*?*/ &REPLY[0]);

  //   405     REPLY(1) = REPLY(1)-32 %IF REPLY(1)>='a'

  if (REPLY[0] < 97) goto L_0081;
  REPLY[0] = REPLY[0] - 32;
L_0081:;

//   406     SKIP SYMBOL %WHILE NEXT SYMBOL#NL; SKIP SYMBOL

L_0082:;
  if (_imp_NEXTSYMBOL() == 10) goto L_0083;
  _imp_SKIPSYMBOL();
  goto L_0082;
L_0083:;
  _imp_SKIPSYMBOL();

  //   407     %IF REPLY(1)='R' %START

  if (REPLY[0] != 82) goto L_0084;

    //   408        ! Read board position
    //   409        %CYCLE P = -1,1,26

  // %for P =  -1, 1, 26 %cycle
  {
    P = -2;
  L_0085:
    if (P == 26) goto L_0086;
    P += 1;

    //   410           COMP(P) = 0

    COMP[P + 1] = 0;

    //   411           OPP(P) = 0

    OPP[P + 1] = 0;

    //   412        %REPEAT

    goto L_0085;
  }

L_0086:;

//   413        PRINT STRING("Where are your pieces?"); NEWLINE

  _imp_PRINTSTRING(_imp_str_literal("Where are your pieces?"));
  _imp_NEWLINE();

  //   414        PROMPT(":")

  PROMPT(_imp_str_literal_size(15, ":"));

  //   415        %CYCLE P = 1,1,12

  // %for P = 1, 1, 12 %cycle
  {
    P = 0;
  L_0087:
    if (P == 12) goto L_0088;
    P += 1;

    //   416           SKIP SPACES AND NLS

    SKIPSPACESANDNLS();

    //   417           READ SYMBOL(A); %IF A='.' %THEN %EXIT

    _imp_READSYMBOL(/*?*/ &A);
    if (A != 46) goto L_0089;
    goto L_0088;
  L_0089:;

  //   418           READ SYMBOL(B); READ SYMBOL(C)

    _imp_READSYMBOL(/*?*/ &B);
    _imp_READSYMBOL(/*?*/ &C);

    //   419           A = A-32 %IF A>='a'

    if (A < 97) goto L_008A;
    A = A - 32;
  L_008A:;

  //   420           B = B-32 %IF A>='a'

    if (A < 97) goto L_008B;
    B = B - 32;
  L_008B:;

  //   421           POS = POSITION OF(A,B)

    POS = POSITIONOF(A, B);

    //   422           OPP(P) = POS

    OPP[P + 1] = POS;

    //   423           %IF C=' ' %THEN OPP(P+12) = 1000 %ELSE OPP(P+12) = CROWN

    if (C != 32) goto L_008C;
    OPP[P + 12 + 1] = 1000;
    goto L_008D;
  L_008C:;
    OPP[P + 12 + 1] = CROWN;
  L_008D:;

  //   424        %REPEAT

    goto L_0087;
  }

L_0088:;

//   425        OPP(0) = 2

  OPP[1] = 2;

  //   426        OPP(25) = P;        ! no of pieces.

  OPP[26] = P;

  //   427        PRINT STRING("Where are my pieces?"); NEWLINE

  _imp_PRINTSTRING(_imp_str_literal("Where are my pieces?"));
  _imp_NEWLINE();

  //   428        %CYCLE P = 1,1,12

  // %for P = 1, 1, 12 %cycle
  {
    P = 0;
  L_008E:
    if (P == 12) goto L_008F;
    P += 1;

    //   429           SKIP SPACES AND NLS

    SKIPSPACESANDNLS();

    //   430           READ SYMBOL(A); %IF A='.' %THEN %EXIT

    _imp_READSYMBOL(/*?*/ &A);
    if (A != 46) goto L_0090;
    goto L_008F;
  L_0090:;

  //   431           READ SYMBOL(B); READ SYMBOL(C)

    _imp_READSYMBOL(/*?*/ &B);
    _imp_READSYMBOL(/*?*/ &C);

    //   432           A = A-32 %IF A>='a'

    if (A < 97) goto L_0091;
    A = A - 32;
  L_0091:;

  //   433           B = B-32 %IF B>='a'

    if (B < 97) goto L_0092;
    B = B - 32;
  L_0092:;

  //   434           POS = POSITION OF(A,B)

    POS = POSITIONOF(A, B);

    //   435           COMP(P) = POS

    COMP[P + 1] = POS;

    //   436           %IF C=' ' %THEN COMP(P+12) = 1000 %ELSE COMP(P+12) = CROWN

    if (C != 32) goto L_0093;
    COMP[P + 12 + 1] = 1000;
    goto L_0094;
  L_0093:;
    COMP[P + 12 + 1] = CROWN;
  L_0094:;

  //   437        %REPEAT

    goto L_008E;
  }

L_008F:;

//   438        COMP(0)  = ME

  COMP[1] = ME;

  //   439        COMP(25) = P;        ! NO OF PIECES

  COMP[26] = P;

  //   440        SKIP SYMBOL;       ! NL

  _imp_SKIPSYMBOL();

  //   441        PROMPT("Your move?")

  PROMPT(_imp_str_literal_size(15, "Your move?"));

  //   442        READ SYMBOL(A)

  _imp_READSYMBOL(/*?*/ &A);

  //   443        SKIP SYMBOL %WHILE NEXT SYMBOL#NL; SKIP SYMBOL

L_0095:;
  if (_imp_NEXTSYMBOL() == 10) goto L_0096;
  _imp_SKIPSYMBOL();
  goto L_0095;
L_0096:;
  _imp_SKIPSYMBOL();

  //   444        A = A-32 %IF A>='a'

  if (A < 97) goto L_0097;
  A = A - 32;
L_0097:;

//   445        %IF A='Y' %THEN -> READ MOVE %ELSE -> COMP MOVE

  if (A != 89) goto L_0098;
  goto U_1002;
L_0098:;
  goto U_1003;

  //   446     %FINISH

L_0084:;

//   447     %IF REPLY(1) = 'N' %START

  if (REPLY[0] != 78) goto L_0099;

    //   448        PRINT STRING("Think of a number please"); NEWLINE

  _imp_PRINTSTRING(_imp_str_literal("Think of a number please"));
  _imp_NEWLINE();

  //   449        READ SYMBOL(I); SKIP SYMBOL

  _imp_READSYMBOL(/*?*/ &I);
  _imp_SKIPSYMBOL();

  //   450        I = (I-'0')&3

  I = I - 48 & 3;

  //   451        COMP(-1) = 'B';  OPP(-1) = 'W'

  COMP[0] = 66;
  OPP[0] = 87;

  //   452        PRINTSTRING("DRAFT4's opening move is ")

  _imp_PRINTSTRING(_imp_str_literal("DRAFT4's opening move is "));

  //   453        %IF I = 1 %THEN PRINTSTRING("D6-C5") %AND COMP(11) = 42

  if (I != 1) goto L_009A;
  _imp_PRINTSTRING(_imp_str_literal("D6-C5"));
  COMP[12] = 42;
L_009A:;

//   454        %IF I = 2 %THEN PRINTSTRING("D6-E5") %AND COMP(11) = 44

  if (I != 2) goto L_009B;
  _imp_PRINTSTRING(_imp_str_literal("D6-E5"));
  COMP[12] = 44;
L_009B:;

//   455        %IF I = 3 %THEN PRINTSTRING("F6-E5") %AND COMP(10) = 44

  if (I != 3) goto L_009C;
  _imp_PRINTSTRING(_imp_str_literal("F6-E5"));
  COMP[11] = 44;
L_009C:;

//   456        NEWLINE

  _imp_NEWLINE();

  //   457     %FINISH

L_0099:;

//   458  READ MOVE:

U_1002:;

//   459     PRINT BOARD

  PRINTBOARD();

  //   460     PROMPT("Your move:")

  PROMPT(_imp_str_literal_size(15, "Your move:"));

  //   461     SKIP SYMBOL %WHILE NEXT SYMBOL <= ' '

L_009D:;
  if (_imp_NEXTSYMBOL() > 32) goto L_009E;
  _imp_SKIPSYMBOL();
  goto L_009D;
L_009E:;

//   462     %CYCLE I = 1, 1, 8

  // %for I = 1, 1, 8 %cycle
  {
    I = 0;
  L_009F:
    if (I == 8) goto L_00A0;
    I += 1;

    //   463        READ SYMBOL(REPLY(I))

    _imp_READSYMBOL(/*?*/ &REPLY[I - 1]);

    //   464        REPLY(I) = REPLY(I)-32 %IF REPLY(I)>='a'

    if (REPLY[I - 1] < 97) goto L_00A1;
    REPLY[I - 1] = REPLY[I - 1] - 32;
  L_00A1:;

  //   465        %EXIT %IF REPLY(I) = NL

    if (REPLY[I - 1] != 10) goto L_00A2;
    goto L_00A0;
  L_00A2:;

  //   466     %REPEAT

    goto L_009F;
  }

L_00A0:;

//   467     REPLY(I) = ' ' %AND I = I+1 %UNTIL I = 9

L_00A3:;
  REPLY[I - 1] = 32;
  I = I + 1;
  if (I == 9) goto L_00A4;
  goto L_00A3;
L_00A4:;

//   468     %IF REPLY(1) = 'M' %THEN MON = 'M' %AND -> READ MOVE

  if (REPLY[0] != 77) goto L_00A5;
  MON = 77;
  goto U_1002;
L_00A5:;

//   469     %IF REPLY(1) = 'Q' %THEN MON = 'Q' %AND -> READ MOVE

  if (REPLY[0] != 81) goto L_00A6;
  MON = 81;
  goto U_1002;
L_00A6:;

//   470  TRANS:

U_1004:;

//   471     %IF REPLY(1) = 'I' %THEN -> STOP

  if (REPLY[0] != 73) goto L_00A7;
  goto U_1005;
L_00A7:;

//   472     %IF REPLY(6) = ','%THEN MORE = 'M' %ELSE MORE = ' '

  if (REPLY[5] != 44) goto L_00A8;
  MORE = 77;
  goto L_00A9;
L_00A8:;
  MORE = 32;
L_00A9:;

//   473     OLDPOS = POSITION OF(REPLY(1), REPLY(2))

  OLDPOS = POSITIONOF(REPLY[0], REPLY[1]);

  //   474     NEWPOS = POSITION OF(REPLY(4), REPLY(5))

  NEWPOS = POSITIONOF(REPLY[3], REPLY[4]);

  //   475     %IF VALID POS(OLDPOS) = -1 %START

  if (VALIDPOS(OLDPOS) != -1) goto L_00AA;

    //   476        PRINTSTRING("The square ")

  _imp_PRINTSTRING(_imp_str_literal("The square "));

  //   477        PRINT SYMBOL(REPLY(1));  PRINT SYMBOL(REPLY(2))

  _imp_PRINTSYMBOL(REPLY[0]);
  _imp_PRINTSYMBOL(REPLY[1]);

  //   478        PRINTSTRING(" does not exist!

  _imp_PRINTSTRING(_imp_str_literal(" does not exist!\n"));

  //   479+ ")
  //   480        SAY PLEASE

  SAYPLEASE();

  //   481        -> READ MOVE

  goto U_1002;

  //   482     %FINISH

L_00AA:;

//   483     M = VALID POS(NEWPOS)

  M = VALIDPOS(NEWPOS);

  //   484     %IF M = -1 %START

  if (M != -1) goto L_00AB;

    //   485        PRINTSTRING("You cannot move to square ")

  _imp_PRINTSTRING(_imp_str_literal("You cannot move to square "));

  //   486        PRINTSYMBOL(REPLY(4));  PRINTSYMBOL(REPLY(5))

  _imp_PRINTSYMBOL(REPLY[3]);
  _imp_PRINTSYMBOL(REPLY[4]);

  //   487        PRINTSTRING(";  it does not exist!

  _imp_PRINTSTRING(_imp_str_literal(";  it does not exist!\n"));

  //   488+ ")
  //   489        SAY PLEASE

  SAYPLEASE();

  //   490        -> READ MOVE

  goto U_1002;

  //   491     %FINISH

L_00AB:;

//   492     %IF M = 1 %START

  if (M != 1) goto L_00AC;

    //   493        PRINTSTRING("You cannot move to square ")

  _imp_PRINTSTRING(_imp_str_literal("You cannot move to square "));

  //   494        PRINT SYMBOL(REPLY(4));  PRINT SYMBOL(REPLY(5))

  _imp_PRINTSYMBOL(REPLY[3]);
  _imp_PRINTSYMBOL(REPLY[4]);

  //   495        PRINTSTRING(";  it is already occupied!

  _imp_PRINTSTRING(_imp_str_literal(";  it is already occupied!\n"));

  //   496+ ")
  //   497        SAY PLEASE

  SAYPLEASE();

  //   498        -> READ MOVE

  goto U_1002;

  //   499     %FINISH

L_00AC:;

//   500     %CYCLE P = 1, 1, OPP(25)

  // %for P = 1, 1, OPP[26] %cycle
  {
    int _final = OPP[26];
    if (invalid_for_loop(1, 1, _final)) _imp_signal(5, 1, 0, "Illegal cycle P = 1, 1, OPP[26]");
    P = 0;
  L_00AD:
    if (P == _final) goto L_00AE;
    P += 1;

    //   501        %IF OLDPOS = OPP(P) %THENEXIT

    if (OLDPOS != OPP[P + 1]) goto L_00AF;
    goto L_00AE;
  L_00AF:;

  //   502     %REPEAT

    goto L_00AD;
  }

L_00AE:;

//   503     %UNLESS OLDPOS = OPP(P) %START

  if (OLDPOS == OPP[P + 1]) goto L_00B0;

    //   504        PRINTSTRING("You do not have a piece on square ")

  _imp_PRINTSTRING(_imp_str_literal("You do not have a piece on square "));

  //   505        PRINT SYMBOL(REPLY(1));  PRINT SYMBOL(REPLY(2))

  _imp_PRINTSYMBOL(REPLY[0]);
  _imp_PRINTSYMBOL(REPLY[1]);

  //   506        NEWLINE

  _imp_NEWLINE();

  //   507        SAY PLEASE

  SAYPLEASE();

  //   508        -> READ MOVE

  goto U_1002;

  //   509     %FINISH

L_00B0:;

//   510     PIECE = P

  PIECE = P;

  //   511     DIF = NEWPOS-OLDPOS

  DIF = NEWPOS - OLDPOS;

  //   512     MODIF = MOD(DIF)

  MODIF = MOD(DIF);

  //   513     %IF MODIF < 12 %AND EXPECTED MOVE > 0 %START

  if (MODIF >= 12) goto L_00B1;
  if (EXPECTEDMOVE <= 0) goto L_00B1;

    //   514        PRINTSTRING("You MUST take the piece that I am offering you

  _imp_PRINTSTRING(_imp_str_literal("You MUST take the piece that I am offering you\n"));

  //   515+ ")
  //   516        SAY PLEASE

  SAYPLEASE();

  //   517        -> READ MOVE

  goto U_1002;

  //   518     %FINISH

L_00B1:;

//   519     %IF MODIF < 12 %AND MORE = 'M' %START

  if (MODIF >= 12) goto L_00B2;
  if (MORE != 77) goto L_00B2;

    //   520        PRINTSTRING("That's not part of a multiple jump move

  _imp_PRINTSTRING(_imp_str_literal("That's not part of a multiple jump move\n"));

  //   521+ ")
  //   522        SAY PLEASE

  SAYPLEASE();

  //   523        -> READ MOVE

  goto U_1002;

  //   524     %FINISH

L_00B2:;

//   525     %IF DIF < 0 %AND OPP(PIECE+12) # CROWN %START

  if (DIF >= 0) goto L_00B3;
  if (OPP[PIECE + 12 + 1] == CROWN) goto L_00B3;

    //   526        PRINTSTRING("You cannot move that piece backwards!

  _imp_PRINTSTRING(_imp_str_literal("You cannot move that piece backwards!\n"));

  //   527+ ")
  //   528        SAY PLEASE

  SAYPLEASE();

  //   529        -> READ MOVE

  goto U_1002;

  //   530     %FINISH

L_00B3:;

//   531     %UNLESS MODIF = 11 %OR MODIF = 9 %OR MODIF = 22 %OR MODIF = 18 %START

  if (MODIF == 11) goto L_00B4;
  if (MODIF == 9) goto L_00B4;
  if (MODIF == 22) goto L_00B4;
  if (MODIF == 18) goto L_00B4;

    //   532        PRINTSTRING("That move does not exist in my rule book!

  _imp_PRINTSTRING(_imp_str_literal("That move does not exist in my rule book!\n"));

  //   533+ ")
  //   534        SAY PLEASE

  SAYPLEASE();

  //   535        -> READ MOVE

  goto U_1002;

  //   536     %FINISH

L_00B4:;

//   537     %IF MODIF > 11 %START

  if (MODIF <= 11) goto L_00B5;

    //   538        JUMP = DIF//2

  JUMP = ((long)DIF / (long)2);

  //   539        COMPOS = OLDPOS+JUMP

  COMPOS = OLDPOS + JUMP;

  //   540        %CYCLE I = 1, 1, COMP(25)

  // %for I = 1, 1, COMP[26] %cycle
  {
    int _final = COMP[26];
    if (invalid_for_loop(1, 1, _final)) _imp_signal(5, 1, 0, "Illegal cycle I = 1, 1, COMP[26]");
    I = 0;
  L_00B6:
    if (I == _final) goto L_00B7;
    I += 1;

    //   541           %EXIT %IF COMPOS = COMP(I)

    if (COMPOS != COMP[I + 1]) goto L_00B8;
    goto L_00B7;
  L_00B8:;

  //   542        %REPEAT

    goto L_00B6;
  }

L_00B7:;

//   543        %UNLESS COMPOS = COMP(I) %START

  if (COMPOS == COMP[I + 1]) goto L_00B9;

    //   544           PRINTSTRING("You cannot do that.  You are not jumping one of my pieces

  _imp_PRINTSTRING(_imp_str_literal("You cannot do that.  You are not jumping one of my pieces\n"));

  //   545+ ")
  //   546           SAY PLEASE

  SAYPLEASE();

  //   547           -> READ MOVE

  goto U_1002;

  //   548        %FINISH

L_00B9:;

//   549        JMAN = I

  JMAN = I;

  //   550     %FINISH %ELSE JMAN = 0

  goto L_00BA;
L_00B5:;
  JMAN = 0;
L_00BA:;

//   551     MAKE MOVE(DIF, PIECE, JMAN, OPP, COMP)

  MAKEMOVE(DIF, PIECE, /*?*/ &JMAN, OPP, COMP);

  //   552     %IF MORE = 'M' %START

  if (MORE != 77) goto L_00BB;

    //   553        LASTPOS = NEWPOS

  LASTPOS = NEWPOS;

  //   554  READ AGAIN:

U_1006:;

//   555        PROMPT("and:")

  PROMPT(_imp_str_literal_size(15, "and:"));

  //   556        %CYCLE I = 1, 1, 8

  // %for I = 1, 1, 8 %cycle
  {
    I = 0;
  L_00BC:
    if (I == 8) goto L_00BD;
    I += 1;

    //   557           READ SYMBOL(REPLY(I))

    _imp_READSYMBOL(/*?*/ &REPLY[I - 1]);

    //   558           REPLY(I) = REPLY(I)-32 %IF REPLY(I)>='a'

    if (REPLY[I - 1] < 97) goto L_00BE;
    REPLY[I - 1] = REPLY[I - 1] - 32;
  L_00BE:;

  //   559           %EXIT %IF REPLY(I) = NL

    if (REPLY[I - 1] != 10) goto L_00BF;
    goto L_00BD;
  L_00BF:;

  //   560        %REPEAT

    goto L_00BC;
  }

L_00BD:;

//   561        %IF REPLY(1) = '.'%THEN -> COMP MOVE

  if (REPLY[0] != 46) goto L_00C0;
  goto U_1003;
L_00C0:;

//   562        REPLY(I) = ' ' %AND I = I+1 %UNTIL I = 9

L_00C1:;
  REPLY[I - 1] = 32;
  I = I + 1;
  if (I == 9) goto L_00C2;
  goto L_00C1;
L_00C2:;

//   563        OLDPOS = POSITION OF(REPLY(1), REPLY(2))

  OLDPOS = POSITIONOF(REPLY[0], REPLY[1]);

  //   564        NEWPOS = POSITION OF(REPLY(4), REPLY(5))

  NEWPOS = POSITIONOF(REPLY[3], REPLY[4]);

  //   565        DIF = NEWPOS-OLDPOS

  DIF = NEWPOS - OLDPOS;

  //   566        DIF = MOD(DIF)

  DIF = MOD(DIF);

  //   567        %IF DIF > 11 %AND OLDPOS = LASTPOS %THEN -> TRANS

  if (DIF <= 11) goto L_00C3;
  if (OLDPOS != LASTPOS) goto L_00C3;
  goto U_1004;
L_00C3:;

//   568        PRINTSTRING("That's not part of a multiple jump

  _imp_PRINTSTRING(_imp_str_literal("That's not part of a multiple jump\nPlease re-type that part\n"));

  //   569+ Please re-type that part
  //   570+ ")
  //   571        -> READ AGAIN

  goto U_1006;

  //   572     %FINISH

L_00BB:;

//   573  COMP MOVE: ! COMPUTER MAKES MOVE.

U_1003:;

//   574     %IF COMPNUM = 0 %START

  if (*COMPNUM != 0) goto L_00C4;

    //   575        PRINTSTRING(" I have no pieces left so I suppose you have won

  _imp_PRINTSTRING(_imp_str_literal(" I have no pieces left so I suppose you have won\n"));

  //   576+ ")
  //   577        -> STOP

  goto U_1005;

  //   578     %FINISH

L_00C4:;

//   579     %IF PENDING MOVE(COMP, OPP) = -1 %START

  if (PENDINGMOVE(COMP, OPP) != -1) goto L_00C5;

    //   580        PRINTSTRING("I cannot move any of my pieces so you win

  _imp_PRINTSTRING(_imp_str_literal("I cannot move any of my pieces so you win\n"));

  //   581+ ")
  //   582         -> STOP

  goto U_1005;

  //   583     %FINISH

L_00C5:;

//   584     ! If in end game then increase search.
//   585     I = COMPNUM+OPPNUM

  I = *COMPNUM + *OPPNUM;

  //   586     %IF I <= 6 %THEN SEARCH LIMIT = 4

  if (I > 6) goto L_00C6;
  SEARCHLIMIT = 4;
L_00C6:;

//   587     ! FIND BEST MOVE.
//   588     NODES = 0;  SP = 0

  NODES = 0;
  SP = 0;

  //   589     VALUEB = TRY POSSIBLE MOVES(1, 1, COMP, OPP)

  VALUEB = TRYPOSSIBLEMOVES(1, 1, COMP, OPP);

  //   590     %IF VALUEB <= -99990 %START

  if (VALUEB > -99990) goto L_00C7;

    //   591         PRINTSTRING("I resign

  _imp_PRINTSTRING(_imp_str_literal("I resign\n"));

  //   592+ ")
  //   593         -> STOP

  goto U_1005;

  //   594     %FINISH

L_00C7:;

//   595     I = 0

  I = 0;

  //   596  ANOTHER TAKE:

U_1007:;

//   597     TROUT(COMP(BEST PIECE), COMP(BEST PIECE)+MOVE(BEST MOVE), I)

  TROUT(COMP[BESTPIECE + 1], COMP[BESTPIECE + 1] + MOVE[BESTMOVE], /*?*/ &I);

  //   598     MAKE MOVE(MOVE(BEST MOVE), BEST PIECE, BEST TAKE, COMP, OPP)

  MAKEMOVE(MOVE[BESTMOVE], BESTPIECE, /*?*/ &BESTTAKE, COMP, OPP);

  //   599     %IF BEST TAKE > 0 %START

  if (BESTTAKE <= 0) goto L_00C8;

    //   600        %CYCLE BEST MOVE = 1, 2, 7

  // %for BESTMOVE = 1, 2, 7 %cycle
  {
    BESTMOVE = -1;
  L_00C9:
    if (BESTMOVE == 7) goto L_00CA;
    BESTMOVE += 2;

    //   601           BEST TAKE = VALID MOVE(BEST MOVE, BEST PIECE, COMP, OPP)

    BESTTAKE = VALIDMOVE(BESTMOVE, BESTPIECE, COMP, OPP);

    //   602           -> ANOTHER TAKE %IF BEST TAKE>0

    if (BESTTAKE <= 0) goto L_00CB;
    goto U_1007;
  L_00CB:;

  //   603        %REPEAT

    goto L_00C9;
  }

L_00CA:;

//   604     %FINISH

L_00C8:;

//   605     NEWLINE

  _imp_NEWLINE();

  //   606     %IF MON = 'M' %START

  if (MON != 77) goto L_00CC;

    //   607        PRINTSTRING("Nodes considered =");  WRITE(NODES, 4)

  _imp_PRINTSTRING(_imp_str_literal("Nodes considered ="));
  _imp_WRITE(NODES, 4);

  //   608        PRINTSTRING("

  _imp_PRINTSTRING(_imp_str_literal("\nValue of board ="));

  //   609+ Value of board =");  WRITE(VALUEB, 4)

  _imp_WRITE(VALUEB, 4);

  //   610        NEWLINE

  _imp_NEWLINE();

  //   611     %FINISH

L_00CC:;

//   612     %IF OPPNUM = 0 %START

  if (*OPPNUM != 0) goto L_00CD;

    //   613         PRINTSTRING("You have no pieces left so I win

  _imp_PRINTSTRING(_imp_str_literal("You have no pieces left so I win\n"));

  //   614+ ")
  //   615        -> STOP

  goto U_1005;

  //   616     %FINISH

L_00CD:;

//   617     EXPECTED MOVE = PENDING MOVE(OPP, COMP)

  EXPECTEDMOVE = PENDINGMOVE(OPP, COMP);

  //   618     %IF EXPECTED MOVE = -1 %START

  if (EXPECTEDMOVE != -1) goto L_00CE;

    //   619        PRINTSTRING("You cannot move any of your pieces so I win

  _imp_PRINTSTRING(_imp_str_literal("You cannot move any of your pieces so I win\n"));

  //   620+ ")
  //   621        -> STOP

  goto U_1005;

  //   622     %FINISH

L_00CE:;

//   623     %IF VALUEB >= 99990  %AND AWIN = 0 %START

  if (VALUEB < 99990) goto L_00CF;
  if (AWIN != 0) goto L_00CF;

    //   624        PRINTSTRING("He-He!  I am going to win!!

  _imp_PRINTSTRING(_imp_str_literal("He-He!  I am going to win!!\n"));

  //   625+ ")
  //   626        AWIN = 1

  AWIN = 1;

  //   627     %FINISH

L_00CF:;

//   628     -> READ MOVE

  goto U_1002;

  //   629  STOP:

U_1005:;

//   630     PRINTSTRING("

  _imp_PRINTSTRING(_imp_str_literal("\nThe final board position is -\n"));

  //   631+ The final board position is -
  //   632+ ")
  //   633     PRINT BOARD

  PRINTBOARD();

  //   634  %END

  return;
} /* end of DRAUGHTS */

// ?RESTART unused
// ?THREE unused
// ?TWO unused
// ?ONE unused
// ?S unused
//   635  %ENDOFFILE