/* Edinburgh IMP77 Compiler - Version 8.4 */ PUSHS "\n" const char [2] snl {ind obj} ; INIT 1 %prim int rem {ind obj} ; ( int p ; int q ; ) %prim void readsymbol ; ( int typecode, void *p ; ) %prim real float {ind obj} ; ( int n ; ) %prim char [2] tostring {ind obj} ; ( int p ; ) %prim char [256] substring {ind obj} ; ( char [256] s ; int f ; int t ; ) %prim int freespace {ind obj} ; () %prim void svc ; ( int n ; struct /*(null)*/ int typecode, void *r ; ) %prim int addr {ind obj} ; ( int typecode, void *p ; ) %prim int integer ; ( int n ; ) %prim short int shortinteger ; ( int n ; ) %prim char int byteinteger ; ( int n ; ) %prim char [1] string ; ( int n ; ) %prim struct /*(null)*/ record ; ( int n ; ) %prim real real ; ( int n ; ) %prim long real longreal ; ( int n ; ) %prim char int length ; ( char [256] s ; ) %prim char int charno ; ( char [256] s ; int n ; ) %prim int int {ind obj} ; ( real x ; ) %prim int intpt {ind obj} ; ( real x ; ) %prim void iocp ; ( int n ; ) %prim int typeof {ind obj} ; ( int typecode, void *n ; ) %prim int sizeof {ind obj} ; ( int typecode, void *n ; ) %prim real fracpt {ind obj} ; ( real x ; ) extern void prompt ; ( char [16] s ; ) extern int nextsymbol {ind obj} ; () extern void skipsymbol ; () extern void printsymbol ; ( int sym ; ) extern void printstring ; ( char [256] s ; ) extern void write ; ( int v ; int p ; ) extern void selectinput ; ( int n ; ) extern void selectoutput ; ( int n ; ) extern void openinput ; ( int n ; char [32] fd ; ) extern void openoutput ; ( int n ; char [32] fd ; ) extern void closeinput ; () extern void closeoutput ; () extern void resetinput ; () extern void resetoutput ; () extern char [9] time {ind obj} ; () extern char [10] date {ind obj} ; () extern int cputime {ind obj} ; () extern int comreg ; ( int n ; ) extern void read ; ( int typecode, void *x ; ) extern void print ; ( real val ; int before ; int after ; ) extern void printfl ; ( real val ; int places ; ) extern void space ; () extern void spaces ; ( int n ; ) extern void newline ; () extern void newlines ; ( int n ; ) struct /*FILEFM*/ %format filefm ; ( int unit ; int owner ; int n1 ; int n2 ; ) struct /*EVENTFM*/ %format eventfm ; ( int event ; int sub ; int extra ; char [64] message ; int pc ; int x ; ) extern struct /*EVENTFM*/ /*spec*/ event ; #line 2 // 1 %EXTERNALROUTINE DRAUGHTS(%STRING(12) S) // 2 %EXTERNALROUTINESPEC CPULIMIT (%STRING(255) S) void draughts ; ( char [13] s ; ) #line 3 // 3 %EXTERNALROUTINESPEC PROMPT(%STRING(15) S) extern void cpulimit ; ( char [256] s ; ) #line 4 // 4 %OWNINTEGER MOB WT = 6 extern void prompt ; ( char [16] s ; ) #line 5 // 5 %CONSTINTEGER TRUE =1, FALSE = 0 static int mobwt ; INIT 1 #line 6 // 6 #line 8 // 7 %OWNINTEGER BACK WT = 4 // 8 %OWNINTEGER CENT WT = 4 static int backwt ; INIT 1 #line 9 // 9 %OWNINTEGER ADV1 WT = 450 static int centwt ; INIT 1 #line 10 // 10 %OWNINTEGER ADV2 WT = 50 static int adv1wt ; INIT 1 #line 11 // 11 %OWNINTEGER CRAMP WT = 6 static int adv2wt ; INIT 1 #line 12 // 12 %OWNINTEGER MON = 'Q' static int crampwt ; INIT 1 #line 13 // 13 %OWNINTEGER A WIN = 0 static int mon ; INIT 1 #line 14 // 14 %OWNINTEGER SEARCH LIMIT = 3 static int awin ; INIT 1 #line 15 // 15 %OWNINTEGER CROWN = 1800 static int searchlimit ; INIT 1 #line 16 // 16 %OWNINTEGERARRAY BACK1(1:5) = 77, 75, 73, 71, 64 static int crown ; INIT 1 #line 17 // 17 %OWNINTEGERARRAY BACK2(1:5) = 0, 2, 4, 6, 13 BOUNDS {NOT IMPLEMENTED YET} static int *back1 ; INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 #line 18 // 18 %OWNINTEGERARRAY CENTSQ(0:7) = 51, 53, 42, 44, 33, 35, 24, 26 BOUNDS {NOT IMPLEMENTED YET} static int *back2 ; INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 #line 19 // 19 %OWNINTEGERARRAY MOVE(0:7) = 9, 18, 11, 22, -9,-18,-11,-22 BOUNDS {NOT IMPLEMENTED YET} static int *centsq ; INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 #line 20 // 20 %OWNINTEGERARRAY PLAYER1(-1:26) = 'W', 1, BOUNDS {NOT IMPLEMENTED YET} static int *move ; INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 #line 21 // 21 77, 75, 73, 71, 64, 66, 62, 60, 57, 55, 53, 51, BOUNDS {NOT IMPLEMENTED YET} static int *player1 ; INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 #line 25 // 22 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, // 23 12, 0 // 24 %OWNINTEGERARRAY PLAYER2(-1:26) = 'B', 2, // 25 0, 2, 4, 6, 13, 11, 15, 17, 20, 22, 24, 26, BOUNDS {NOT IMPLEMENTED YET} static int *player2 ; INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 #line 29 // 26 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, // 27 12, 0 // 28 %OWNINTEGERARRAY BOARD(-1:78) = %C // 29 ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', BOUNDS {NOT IMPLEMENTED YET} static int *board ; INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 INIT 1 #line 38 // 30 ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 31 ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 32 ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 33 ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 34 ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 35 ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 36 ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' // 37 %INTEGERARRAY MIN, MAX(1:12) // 38 %INTEGERARRAY REPLY(1:9) int *min ; int *max ; DIM 0x0001 0x0002 #line 39 // 39 %INTEGERARRAY COMP, OPP(-1:26) int *reply ; DIM 0x0001 0x0001 #line 40 // 40 %INTEGERNAME COMPNUM, OPPNUM int *comp ; int *opp ; DIM 0x0001 0x0002 #line 41 // 41 %INTEGERARRAY PSTACK(1:12); ! piece position take stack int int typecode, void *compnum ; int int typecode, void *oppnum ; #line 42 // 42 %INTEGERARRAY TSTACK(1:12); ! piece type stack int *pstack ; DIM 0x0001 0x0001 #line 43 // 43 %INTEGERARRAY NSTACK(1:12); ! piece number stack int *tstack ; DIM 0x0001 0x0001 #line 44 // 44 %OWNINTEGER SP; ! stack pointer int *nstack ; DIM 0x0001 0x0001 #line 45 // 45 %OWNINTEGER ME = 1 static int sp ; INIT 1 #line 46 // 46 %OWNINTEGER ONE = 1 static int me ; INIT 1 #line 47 // 47 %OWNINTEGER TWO = 2 static int one ; INIT 1 #line 48 // 48 %OWNINTEGER THREE = 3 static int two ; INIT 1 #line 49 // 49 %INTEGER BEST PIECE, BEST MOVE, BEST TAKE static int three ; INIT 1 #line 50 // 50 %INTEGER VALUEB, I, P, M, PIECE, JMAN, JUMP, DIF, MODIF, MORE int bestpiece ; int bestmove ; int besttake ; #line 51 // 51 %INTEGER OLDPOS, NEWPOS, LASTPOS, COMPOS int valueb ; int i ; int p ; int m ; int piece ; int jman ; int jump ; int dif ; int modif ; int more ; #line 52 // 52 %INTEGER NODES, PLY NUMBER, EXPECTED MOVE int oldpos ; int newpos ; int lastpos ; int compos ; #line 53 // 53 %INTEGER A,B,C,POS int nodes ; int plynumber ; int expectedmove ; #line 54 // 54 int a ; int b ; int c ; int pos ; #line 58 // 55 !* P L A Y I N G F U N C T I O N S // 56 // 57 %INTEGERFN VALID POS(%INTEGER POS) // 58 %INTEGER I goto L_0001 /* GOTO (is this always %continue or %exit?) */; int validpos {ind obj} ; ( int pos ; ) #line 59 // 59 ! on the board? int i ; #line 61 // 60 I = POS>>1 // 61 %RESULT = -1 %IF POS < 0 %OR POS > 77 %C i = (pos >> 1); #line 62 // 62 %OR I = 4 %OR I = 14 %OR I = 24 %OR I = 34 if (pos < 0) goto L_0002; if (pos > 77) goto L_0002; if (i == 4) goto L_0002; if (i == 14) goto L_0002; if (i == 24) goto L_0002; if (i != 34) goto L_0003; L_0002: return((-1)); L_0003: #line 65 // 63 ! square vacant? // 64 %CYCLE I = 1, 1, 12 // 65 %RESULT = 1 %IF (I <= COMPNUM %AND POS = COMP(I)) %C for (i = 1; i += 1; i != 12) { #line 66 // 66 %OR (I <= OPPNUM %AND POS = OPP(I)) if (i > *compnum ) goto L_0006; if (pos == comp [i ]) goto L_0007; L_0006: if (i > *oppnum ) goto L_0008; if (pos != opp [i ]) goto L_0008; L_0007: return(1); L_0008: #line 68 // 67 %REPEAT // 68 %RESULT = 0 L_0004: /* continue address */ } /* end loop */ L_0005: #line 69 // 69 %END return(0); #line 70 // 70 L_0001: #line 72 // 71 %INTEGERFN VALID MOVE(%INTEGER M, P, %INTEGERARRAYNAME COMP, OPP) // 72 %INTEGER CPOS, I, T goto L_0001 /* GOTO (is this always %continue or %exit?) */; int validmove {ind obj} ; ( int m ; int p ; int * /*12*/ comp ; int * /*12*/ opp ; ) #line 73 // 73 %UNLESS COMP(P+12) = CROWN %START int cpos ; int i ; int t ; #line 74 // 74 %IF COMP(0) = 1 %START; ! player 1 if (comp [(p + 12)] == crown ) goto L_0009; #line 75 // 75 %RESULT = -1 %IF M&4 = 0; ! backward move if (comp [0] != 1) goto L_000a; #line 76 // 76 %FINISH %ELSE %START; ! else player 2 if ((4 & m ) != 0) goto L_000b; return((-1)); L_000b: #line 77 // 77 %RESULT = -1 %IF M&4 # 0; ! backward move goto L_000c /* GOTO (is this always %continue or %exit?) */; L_000a: #line 78 // 78 %FINISH if ((4 & m ) == 0) goto L_000d; return((-1)); L_000d: #line 79 // 79 %FINISH L_000c: #line 80 // 80 CPOS = COMP(P) L_0009: #line 81 // 81 %RESULT = -1 %UNLESS VALID POS(CPOS+MOVE(M)) = 0 cpos = comp [p ]; #line 82 // 82 %RESULT = 0 %IF M&1 = 0; ! ordinary move if (validpos ((cpos + move [m ])) == 0) goto L_000e; return((-1)); L_000e: #line 83 // 83 %RESULT = -1 %IF OPP(25)=0 if ((1 & m ) != 0) goto L_000f; return(0); L_000f: #line 84 // 84 I = CPOS+MOVE(M-1); ! else take-move if (opp [25] != 0) goto L_0010; return((-1)); L_0010: #line 85 // 85 %CYCLE T = 1, 1, OPP(25) i = (cpos + move [(m - 1)]); #line 86 // 86 %RESULT = T %IF I = OPP(T); ! piece to take? for (t = 1; t += 1; t != opp [25]) { #line 87 // 87 %REPEAT if (i != opp [t ]) goto L_0013; return(t ); L_0013: #line 88 // 88 %RESULT = -1 L_0011: /* continue address */ } /* end loop */ L_0012: #line 89 // 89 %END return((-1)); #line 90 // 90 L_0001: #line 92 // 91 %INTEGERFN PENDING MOVE(%INTEGERARRAYNAME COMP, OPP) // 92 %INTEGER P, M, T, COMPNUM goto L_0001 /* GOTO (is this always %continue or %exit?) */; int pendingmove {ind obj} ; ( int * /*12*/ comp ; int * /*12*/ opp ; ) #line 93 // 93 COMPNUM = COMP(25) int p ; int m ; int t ; int compnum ; #line 94 // 94 %RESULT = -1 %IF COMPNUM = 0; ! no pieces left!! compnum = comp [25]; #line 95 // 95 %CYCLE P = 1, 1, COMPNUM if (compnum != 0) goto L_0014; return((-1)); L_0014: #line 96 // 96 %CYCLE M = 1, 2, 7 for (p = 1; p += 1; p != compnum ) { #line 97 // 97 T = VALID MOVE(M, P, COMP, OPP) for (m = 1; m += 2; m != 7) { #line 98 // 98 %RESULT = P %IF T > 0; ! return piece doing take t = validmove (m , p , comp , opp ); #line 99 // 99 %REPEAT if (t <= 0) goto L_0018; return(p ); L_0018: #line 100 // 100 %REPEAT L_000c: /* continue address */ } /* end loop */ L_0017: #line 101 // 101 ! ordinary moves L_0015: /* continue address */ } /* end loop */ L_0016: #line 103 // 102 %CYCLE P = 1, 1, COMPNUM // 103 %CYCLE M = 0, 2, 6 for (p = 1; p += 1; p != compnum ) { #line 104 // 104 T = VALID MOVE(M, P, COMP, OPP) for (m = 0; m += 2; m != 6) { #line 105 // 105 %RESULT = 0 %IF T = 0; ! move ok t = validmove (m , p , comp , opp ); #line 106 // 106 %REPEAT if (t != 0) goto L_001d; return(0); L_001d: #line 107 // 107 %REPEAT L_001b: /* continue address */ } /* end loop */ L_001c: #line 108 // 108 %RESULT = -1; ! no moves L_0019: /* continue address */ } /* end loop */ L_001a: #line 109 // 109 %END return((-1)); #line 110 // 110 L_0001: #line 112 // 111 %INTEGERFN CROWNING(%INTEGER POS, PLAYER) // 112 ! assumes valid pos goto L_0001 /* GOTO (is this always %continue or %exit?) */; int crowning {ind obj} ; ( int pos ; int player ; ) #line 114 // 113 %RESULT=TRUE %IF (PLAYER = 1 %AND POS < 7) %C // 114 %OR (PLAYER = 2 %AND POS > 70) if (player != 1) goto L_001e; if (pos < 7) goto L_001f; L_001e: if (player != 2) goto L_0020; if (pos <= 70) goto L_0020; L_001f: return(1); L_0020: #line 116 // 115 %RESULT=FALSE // 116 %END return(0); #line 117 // 117 L_0001: #line 119 // 118 %INTEGERFN MOD(%INTEGER N) // 119 goto L_0001 /* GOTO (is this always %continue or %exit?) */; int mod {ind obj} ; ( int n ; ) #line 121 // 120 %RESULT = -N %IF N<0 // 121 %RESULT = N if (n >= 0) goto L_0021; return((-n )); L_0021: #line 122 // 122 return(n ); #line 124 // 123 %END // 124 L_0001: #line 126 // 125 %INTEGERFN VALUE OF SIDE(%INTEGERARRAYNAME COMP, OPP) // 126 %INTEGER V1, V2, V3, V4, V5, V6, V7 goto L_0001 /* GOTO (is this always %continue or %exit?) */; int valueofside {ind obj} ; ( int * /*12*/ comp ; int * /*12*/ opp ; ) #line 127 // 127 %INTEGER P, PP, M, MM, MV, ADV1, VM, PLAYER int v1 ; int v2 ; int v3 ; int v4 ; int v5 ; int v6 ; int v7 ; #line 128 // 128 %INTEGERNAME CPOS, CTYPE int p ; int pp ; int m ; int mm ; int mv ; int adv1 ; int vm ; int player ; #line 129 // 129 PLAYER = COMP(0) int int typecode, void *cpos ; int int typecode, void *ctype ; #line 130 // 130 player = comp [0]; #line 133 // 131 ! back control // 132 V2 = 0 // 133 %IF OPP(26) = 0 %START; ! OPP has no crowns yet v2 = 0; #line 134 // 134 %IF PLAYER = 1 %START; ! player 1 if (opp [26] != 0) goto L_0022; #line 135 // 135 %CYCLE P = 1, 1, 5 if (player != 1) goto L_0023; #line 136 // 136 V2 = V2+BACK WT %IF COMP(P) = BACK1(P) for (p = 1; p += 1; p != 5) { #line 137 // 137 %REPEAT if (comp [p ] != back1 [p ]) goto L_0026; v2 = (v2 + backwt ); L_0026: #line 138 // 138 %FINISH %ELSE %START; ! player 2 L_0024: /* continue address */ } /* end loop */ L_0025: #line 139 // 139 %CYCLE P = 1, 1, 5 goto L_0027 /* GOTO (is this always %continue or %exit?) */; L_0023: #line 140 // 140 V2 = V2+BACK WT %IF COMP(P) = BACK2(P) for (p = 1; p += 1; p != 5) { #line 141 // 141 %REPEAT if (comp [p ] != back2 [p ]) goto L_002a; v2 = (v2 + backwt ); L_002a: #line 142 // 142 %FINISH L_0028: /* continue address */ } /* end loop */ L_0029: #line 143 // 143 %FINISH L_0027: #line 144 // 144 L_0022: #line 146 // 145 V1 = 0; V3 = 0; V4 = 0; V5 = 0; V6 = 0; V7 = 0 // 146 %CYCLE P = 1, 1, COMP(25) v1 = 0; #line 146 v3 = 0; #line 146 v4 = 0; #line 146 v5 = 0; #line 146 v6 = 0; #line 146 v7 = 0; #line 147 // 147 CPOS ==COMP(P); CTYPE == COMP(P+12) for (p = 1; p += 1; p != comp [25]) { #line 148 // 148 ADV1 = 0 /*%name*/ cpos = &comp [p ]; #line 148 /*%name*/ ctype = &comp [(p + 12)]; #line 149 // 149 adv1 = 0; #line 152 // 150 ! add up piece values // 151 V1 = V1+CTYPE // 152 v1 = (v1 + *ctype ); #line 154 // 153 %CYCLE M = 0, 1, 7 // 154 VM = VALID MOVE(M, P, COMP, OPP) for (m = 0; m += 1; m != 7) { #line 155 // 155 MV = MOVE(M) vm = validmove (m , p , comp , opp ); #line 156 // 156 mv = move [m ]; #line 159 // 157 ! centre control // 158 %IF CPOS = CENTSQ(M) %START // 159 V4 = V4+CENT WT if (*cpos != centsq [m ]) goto L_002e; #line 160 // 160 V4 = V4+CENT WT+1 %IF CTYPE = CROWN v4 = (v4 + centwt ); #line 161 // 161 %FINISH if (*ctype != crown ) goto L_002f; v4 = ((v4 + centwt ) + 1); L_002f: #line 162 // 162 L_002e: #line 164 // 163 %IF VM >= 0 %START // 164 if (vm < 0) goto L_0030; #line 167 // 165 ! mobility // 166 V3 = V3+MOB WT // 167 V3 = V3+MOB WT %IF VM > 0 v3 = (v3 + mobwt ); #line 168 // 168 if (vm <= 0) goto L_0031; v3 = (v3 + mobwt ); L_0031: #line 170 // 169 %IF CTYPE # CROWN %START // 170 if (*ctype == crown ) goto L_0032; #line 173 // 171 ! advancement 1 // 172 %IF ADV1 = 0 %AND TRUE=CROWNING(CPOS+MV, PLAYER) %THEN %C // 173 V5 = V5+ADV1 WT %AND ADV1 = 1 if (adv1 != 0) goto L_0033; if (1 != crowning ((*cpos + mv ), player )) goto L_0033; v5 = (v5 + adv1wt ); adv1 = 1; L_0033: #line 177 // 174 // 175 ! advancement 2 // 176 %IF VM = 0 %START; ! ignore jumps to crown // 177 CPOS = CPOS+MV if (vm != 0) goto L_0034; #line 178 // 178 %CYCLE MM = 0, 2, 6 *cpos = (*cpos + mv ); #line 179 // 179 %IF TRUE=CROWNING(CPOS+MOVE(MM), PLAYER) %C for (mm = 0; mm += 2; mm != 6) { #line 180 // 180 %AND VALID MOVE(MM, P, COMP, OPP) >= 0 %START if (1 != crowning ((*cpos + move [mm ]), player )) goto L_0037; if (validmove (mm , p , comp , opp ) < 0) goto L_0037; #line 182 // 181 V6 = V6+ADV2 WT; %EXIT // 182 %FINISH v6 = (v6 + adv2wt ); #line 182 goto L_0036 /* GOTO (is this always %continue or %exit?) */; #line 183 // 183 %REPEAT L_0037: #line 184 // 184 CPOS = CPOS-MV L_0035: /* continue address */ } /* end loop */ L_0036: #line 185 // 185 %FINISH *cpos = (*cpos - mv ); #line 186 // 186 %FINISH L_0034: #line 187 // 187 L_0032: #line 190 // 188 ! cramp // 189 %IF VM = 0 %AND CTYPE = CROWN %AND OPP(25) > 0 %START // 190 CPOS = CPOS+MV if (vm != 0) goto L_0038; if (*ctype != crown ) goto L_0038; if (opp [25] <= 0) goto L_0038; #line 191 // 191 %CYCLE PP = 1, 1, OPP(25) *cpos = (*cpos + mv ); #line 192 // 192 %CYCLE MM = 1, 2, 7 for (pp = 1; pp += 1; pp != opp [25]) { #line 193 // 193 %IF VALID MOVE(MM, PP, OPP, COMP) >= 0 %START for (mm = 1; mm += 2; mm != 7) { #line 194 // 194 V5 = V5-CRAMP WT; %EXIT if (validmove (mm , pp , opp , comp ) < 0) goto L_003d; #line 195 // 195 %FINISH v5 = (v5 - crampwt ); #line 195 goto L_003c /* GOTO (is this always %continue or %exit?) */; #line 196 // 196 %REPEAT L_003d: #line 197 // 197 %REPEAT L_003b: /* continue address */ } /* end loop */ L_003c: #line 198 // 198 CPOS = CPOS-MV L_0039: /* continue address */ } /* end loop */ L_003a: #line 199 // 199 %FINISH *cpos = (*cpos - mv ); #line 200 // 200 %FINISH L_0038: #line 201 // 201 %REPEAT L_0030: #line 202 // 202 %REPEAT L_0027: /* continue address */ } /* end loop */ L_002d: #line 203 // 203 %RESULT = V1+V2+V3+V4+V5+V6+V7 L_002b: /* continue address */ } /* end loop */ L_002c: #line 204 // 204 %END return(((((((v1 + v2 ) + v3 ) + v4 ) + v5 ) + v6 ) + v7 )); #line 205 // 205 L_0001: #line 207 // 206 %INTEGERFN VALUE OF POS(%INTEGERARRAYNAME COMP, OPP) // 207 %INTEGER VALUE goto L_0001 /* GOTO (is this always %continue or %exit?) */; int valueofpos {ind obj} ; ( int * /*12*/ comp ; int * /*12*/ opp ; ) #line 208 // 208 %IF PENDING MOVE(COMP, OPP) >= 0 %START int value ; #line 209 // 209 VALUE = VALUE OF SIDE(COMP, OPP)-VALUE OF SIDE(OPP, COMP)-PLY NUMBER if (pendingmove (comp , opp ) < 0) goto L_003e; #line 210 // 210 %FINISH %ELSE VALUE = -100000+PLYNUMBER; ! no mobility!! value = ((valueofside (comp , opp ) - valueofside (opp , comp )) - plynumber ); #line 211 // 211 %RESULT = VALUE %IF COMP(0) = ME goto L_003f /* GOTO (is this always %continue or %exit?) */; L_003e: value = ((-100000) + plynumber ); L_003f: #line 212 // 212 %RESULT = -VALUE if (comp [0] != me ) goto L_0040; return(value ); L_0040: #line 213 // 213 %END return((-value )); #line 214 // 214 L_0001: #line 216 // 215 %ROUTINE MAKE MOVE(%INTEGER MV, P, %INTEGERNAME T, %C // 216 %INTEGERARRAYNAME COMP, OPP) goto L_0001 /* GOTO (is this always %continue or %exit?) */; void makemove ; ( int mv ; int p ; int int typecode, void *t ; int * /*12*/ comp ; int * /*12*/ opp ; ) #line 218 // 217 %INTEGERNAME CPOS, CTYPE, OPOS, OTYPE, ONUM, ONUMC // 218 CPOS == COMP(P); CTYPE == COMP(P+12) int int typecode, void *cpos ; int int typecode, void *ctype ; int int typecode, void *opos ; int int typecode, void *otype ; int int typecode, void *onum ; int int typecode, void *onumc ; #line 219 // 219 CPOS = CPOS+MV /*%name*/ cpos = &comp [p ]; #line 219 /*%name*/ ctype = &comp [(p + 12)]; #line 220 // 220 %IF T # 0 %START; ! a take *cpos = (*cpos + mv ); #line 221 // 221 OPOS == OPP(T); OTYPE == OPP(T+12) if (*t == 0) goto L_0041; #line 222 // 222 ONUM == OPP(25); ONUMC == OPP(26) /*%name*/ opos = &opp [*t ]; #line 222 /*%name*/ otype = &opp [(*t + 12)]; #line 223 // 223 SP = SP+1 /*%name*/ onum = &opp [25]; #line 223 /*%name*/ onumc = &opp [26]; #line 224 // 224 PSTACK(SP) = OPOS; ! save position of taken piece /*%own*/ sp = (sp + 1); #line 225 // 225 TSTACK(SP) = OTYPE; ! save piece type pstack [sp ] = *opos ; #line 226 // 226 NSTACK(SP) = T; ! save piece number tstack [sp ] = *otype ; #line 227 // 227 OPOS = OPP(ONUM); ! remove piece from board nstack [sp ] = *t ; #line 228 // 228 ONUM = ONUM-1; ! reduce piece count for opp *opos = opp [*onum ]; #line 229 // 229 ONUMC = ONUMC-1 %IF OTYPE = CROWN *onum = (*onum - 1); #line 230 // 230 OTYPE = OPP(ONUM+13) if (*otype != crown ) goto L_0042; *onumc = (*onumc - 1); L_0042: #line 231 // 231 %FINISH *otype = opp [(*onum + 13)]; #line 232 // 232 %IF CTYPE # CROWN %AND TRUE=CROWNING(CPOS, COMP(0)) %START L_0041: #line 233 // 233 CTYPE = CROWN; ! crown piece if (*ctype == crown ) goto L_0043; if (1 != crowning (*cpos , comp [0])) goto L_0043; #line 234 // 234 COMP(26) = COMP(26)+1; ! increase crown count *ctype = crown ; #line 235 // 235 T = 0; ! no more takes comp [26] = (comp [26] + 1); #line 236 // 236 %FINISH *t = 0; #line 237 // 237 %END L_0043: #line 238 // 238 L_0001: #line 240 // 239 %INTEGERFN TRY POSSIBLE MOVES(%INTEGER PLY, DEPTH, %C // 240 %INTEGERARRAYNAME COMP, OPP) goto L_0001 /* GOTO (is this always %continue or %exit?) */; int trypossiblemoves {ind obj} ; ( int ply ; int depth ; int * /*12*/ comp ; int * /*12*/ opp ; ) #line 242 // 241 %INTEGER M,MM,MMM,MMF,P,T,TT,APT,VALUE,TAKES,OLDPOS,OLDTYPE // 242 %INTEGERNAME MAXPLY, MINPLY int m ; int mm ; int mmm ; int mmf ; int p ; int t ; int tt ; int apt ; int value ; int takes ; int oldpos ; int oldtype ; #line 243 // 243 int int typecode, void *maxply ; int int typecode, void *minply ; #line 245 // 244 %INTEGERFN PURSUIT // 245 %RESULT = 1 %IF PLY = 1 goto L_0001 /* GOTO (is this always %continue or %exit?) */; int pursuit {ind obj} ; () #line 246 // 246 %RESULT = \M&1 if (ply != 1) goto L_0044; return(1); L_0044: #line 247 // 247 %END return((1 & (\m ))); #line 248 // 248 L_0001: #line 250 // 249 NODES = NODES+1 // 250 APT = PENDING MOVE(COMP, OPP) nodes = (nodes + 1); #line 251 // 251 PLY NUMBER = PLY-1 %AND %RESULT = VALUE OF POS(COMP, OPP) %C apt = pendingmove (comp , opp ); #line 252 // 252 %IF (DEPTH >= SEARCH LIMIT %AND APT <=0) %OR PLY > 12 if (depth < searchlimit ) goto L_0045; if (apt <= 0) goto L_0046; L_0045: if (ply <= 12) goto L_0047; L_0046: plynumber = (ply - 1); return(valueofpos (comp , opp )); L_0047: #line 254 // 253 MINPLY == MIN(PLY); MINPLY = 100000 // 254 MAXPLY == MAX(PLY); MAXPLY =-100000 /*%name*/ minply = &min [ply ]; #line 254 *minply = 100000; #line 255 // 255 %IF APT >= 0 %START; ! COMP able to move /*%name*/ maxply = &max [ply ]; #line 255 *maxply = (-100000); #line 256 // 256 %IF APT > 0 %START; ! take priority if (apt < 0) goto L_0048; #line 257 // 257 P = APT; APT = 2; MMM = 1 ; MMF = 7 if (apt <= 0) goto L_0049; #line 258 // 258 SEARCH LIMIT = 2 %IF PLY = 1 p = apt ; #line 258 apt = 2; #line 258 mmm = 1; #line 258 mmf = 7; #line 259 // 259 %FINISH %ELSE %START if (ply != 1) goto L_004a; /*%own*/ searchlimit = 2; L_004a: #line 260 // 260 P = 1; APT = 2; MMM = 0; MMF=6 goto L_004b /* GOTO (is this always %continue or %exit?) */; L_0049: #line 261 // 261 %FINISH p = 1; #line 261 apt = 2; #line 261 mmm = 0; #line 261 mmf = 6; #line 262 // 262 %CYCLE P = P, 1, COMP(25) L_004b: #line 263 // 263 OLDPOS = COMP(P); OLDTYPE = COMP(P+12) for (p = p ; p += 1; p != comp [25]) { #line 264 // 264 %CYCLE M = MMM, APT, MMF oldpos = comp [p ]; #line 264 oldtype = comp [(p + 12)]; #line 265 // 265 TAKES = 0 for (m = mmm ; m += apt ; m != mmf ) { #line 266 // 266 T = VALID MOVE(M, P, COMP, OPP) takes = 0; #line 267 // 267 %IF T >= 0 %START; ! valid move t = validmove (m , p , comp , opp ); #line 268 // 268 MM = M; TT = T if (t < 0) goto L_004f; #line 269 // 269 ANOTHER TAKE: TAKES = TAKES+1 %IF TT > 0 mm = m ; #line 269 tt = t ; #line 270 // 270 MAKE MOVE(MOVE(MM), P, TT, COMP, OPP);! try this move L_0050: #line 270 if (tt <= 0) goto L_0051; takes = (takes + 1); L_0051: #line 271 // 271 %IF TT > 0 %START; ! another take #line 272 // 272 %CYCLE MM = 1, 2, 7 if (tt <= 0) goto L_0052; #line 273 // 273 TT = VALID MOVE(MM, P, COMP, OPP) for (mm = 1; mm += 2; mm != 7) { #line 274 // 274 -> ANOTHER TAKE %IF TT > 0 tt = validmove (mm , p , comp , opp ); #line 275 // 275 %REPEAT if (tt <= 0) goto L_0055; goto L_0050 /* JUMP */; L_0055: #line 276 // 276 %FINISH L_0053: /* continue address */ } /* end loop */ L_0054: #line 277 // 277 VALUE = TRY POSSIBLE MOVES(PLY+1, DEPTH+PURSUIT, OPP, COMP) L_0052: #line 278 // 278 COMP(P) = OLDPOS; COMP(P+12) = OLDTYPE pursuit (); makemove (move [mm ], p , tt , comp , opp ) = value ((trypossiblemoves ((ply + 1)) + depth ), opp , comp ); #line 279 // 279 OPP(25) = OPP(25)+TAKES comp [p ] = oldpos ; #line 279 comp [(p + 12)] = oldtype ; #line 280 // 280 %WHILE TAKES > 0 %CYCLE opp [25] = (opp [25] + takes ); #line 281 // 281 TT = NSTACK(SP) L_0056: if (takes <= 0) goto L_0057; #line 282 // 282 OPP(TT) = PSTACK(SP) tt = nstack [sp ]; #line 283 // 283 OPP(TT+12) = TSTACK(SP) opp [tt ] = pstack [sp ]; #line 284 // 284 TAKES = TAKES-1 opp [(tt + 12)] = tstack [sp ]; #line 285 // 285 SP = SP-1 takes = (takes - 1); #line 286 // 286 %REPEAT /*%own*/ sp = (sp - 1); #line 287 // 287 %IF COMP(0) = ME %START L_0056: /* continue address */ } /* end loop */ L_0057: #line 288 // 288 %IF VALUE > MAXPLY %START if (comp [0] != me ) goto L_0058; #line 289 // 289 MAXPLY = VALUE if (value <= *maxply ) goto L_0059; #line 290 // 290 %IF PLY = 1 %START *maxply = value ; #line 291 // 291 BEST MOVE = M if (ply != 1) goto L_005a; #line 292 // 292 BEST TAKE = T bestmove = m ; #line 293 // 293 BEST PIECE = P besttake = t ; #line 294 // 294 %FINISH bestpiece = p ; #line 295 // 295 %FINISH L_005a: #line 296 // 296 %RESULT = MAXPLY %IF PLY # 1 %AND MAXPLY >= MIN(PLY-1) L_0059: #line 297 // 297 %FINISH %ELSE %START if (ply == 1) goto L_005b; if (*maxply < min [(ply - 1)]) goto L_005b; return(*maxply ); L_005b: #line 298 // 298 MINPLY = VALUE %IF VALUE < MINPLY goto L_005c /* GOTO (is this always %continue or %exit?) */; L_0058: #line 299 // 299 %RESULT = MINPLY %IF MINPLY <= MAX(PLY-1) if (value >= *minply ) goto L_005d; *minply = value ; L_005d: #line 300 // 300 %FINISH if (*minply > max [(ply - 1)]) goto L_005e; return(*minply ); L_005e: #line 301 // 301 %FINISH L_005c: #line 302 // 302 %REPEAT L_004f: #line 303 // 303 %REPEAT L_004d: /* continue address */ } /* end loop */ L_004e: #line 304 // 304 %FINISH L_004b: /* continue address */ } /* end loop */ L_004c: #line 305 // 305 %RESULT = MAXPLY %IF COMP(0) = ME L_0048: #line 306 // 306 %RESULT = MINPLY if (comp [0] != me ) goto L_005f; return(*maxply ); L_005f: #line 307 // 307 %END return(*minply ); #line 308 // 308 L_0001: #line 310 // 309 %ROUTINE SAY PLEASE // 310 PRINTSTRING("Please re-type your move goto L_0001 /* GOTO (is this always %continue or %exit?) */; void sayplease ; () #line 311 // 311 ") PUSHS "Please re-type your move\n" #line 313 // 312 %END // 313 L_0001: #line 315 // 314 %ROUTINE PRINT BOARD // 315 %INTEGER I, J, POS goto L_0001 /* GOTO (is this always %continue or %exit?) */; void printboard ; () #line 316 // 316 %CYCLE I = 0, 1, 7 int i ; int j ; int pos ; #line 317 // 317 %CYCLE J = 0, 2, 6 for (i = 0; i += 1; i != 7) { #line 318 // 318 BOARD(10*I+J+I&1) = '#' for (j = 0; j += 2; j != 6) { #line 319 // 319 %REPEAT board [(((i * 10) + j ) + (1 & i ))] = 35; #line 320 // 320 %REPEAT L_0061: /* continue address */ } /* end loop */ L_0062: #line 321 // 321 %CYCLE I = 1, 1, 12 L_003f: /* continue address */ } /* end loop */ L_0060: #line 322 // 322 %IF I <= COMP(25) %START for (i = 1; i += 1; i != 12) { #line 323 // 323 POS = COMP(I) if (i > comp [25]) goto L_0065; #line 324 // 324 %IF COMP(I+12) = CROWN %THEN BOARD(POS) = 'X' %C pos = comp [i ]; #line 325 // 325 %ELSE BOARD(POS) = 'x' if (comp [(i + 12)] != crown ) goto L_0066; board [pos ] = 88; goto L_0067 /* GOTO (is this always %continue or %exit?) */; L_0066: board [pos ] = 120; L_0067: #line 327 // 326 %FINISH // 327 %IF I <= OPP(25) %START L_0065: #line 328 // 328 POS = OPP(I) if (i > opp [25]) goto L_0068; #line 329 // 329 %IF OPP(I+12) = CROWN %THEN BOARD(POS) = 'O' %C pos = opp [i ]; #line 330 // 330 %ELSE BOARD(POS) = 'o' if (opp [(i + 12)] != crown ) goto L_0069; board [pos ] = 79; goto L_0067 /* GOTO (is this always %continue or %exit?) */; L_0069: board [pos ] = 111; L_0067: #line 332 // 331 %FINISH // 332 %REPEAT L_0068: #line 333 // 333 PRINTSTRING(" L_0063: /* continue address */ } /* end loop */ L_0064: #line 334 // 334 A B C D E F G H") PUSHS "\n A B C D E F G H" #line 336 // 335 %CYCLE I = 70, -10, 0 // 336 NEWLINE for (i = 70; i += (-10); i != 0) { #line 337 // 337 PRINTSYMBOL(I//10+'1') /*%external*/ %spec newline (); #line 338 // 338 %CYCLE J = 0, 1, 7 #line 339 // 339 SPACE for (j = 0; j += 1; j != 7) { #line 340 // 340 PRINTSYMBOL(BOARD(J+I)) /*%external*/ %spec space (); #line 341 // 341 %REPEAT #line 342 // 342 SPACE L_006c: /* continue address */ } /* end loop */ L_006d: #line 343 // 343 PRINTSYMBOL(I//10+'1') /*%external*/ %spec space (); #line 344 // 344 %REPEAT #line 345 // 345 PRINTSTRING(" L_006a: /* continue address */ } /* end loop */ L_006b: #line 346 // 346 A B C D E F G H PUSHS "\n A B C D E F G H\n" #line 349 // 347 ") // 348 %END // 349 L_0001: #line 351 // 350 %ROUTINE TROUT(%INTEGER OLDPOS, NEWPOS, %INTEGERNAME MODE) // 351 %INTEGER OLDX, OLDY, NEWX, NEWY goto L_0001 /* GOTO (is this always %continue or %exit?) */; void trout ; ( int oldpos ; int newpos ; int int typecode, void *mode ; ) #line 352 // 352 OLDY = OLDPOS//10; OLDX = OLDPOS-10*OLDY int oldx ; int oldy ; int newx ; int newy ; #line 353 // 353 NEWY = NEWPOS//10; NEWX = NEWPOS-10*NEWY oldy = (oldpos / 10); #line 353 oldx = (oldpos - (oldy * 10)); #line 354 // 354 %IF MODE = 0 %THEN PRINTSTRING("DRAFT4's move is ") %AND MODE = 1 %C newy = (newpos / 10); #line 354 newx = (newpos - (newy * 10)); #line 355 // 355 %ELSE PRINTSTRING(" , ") if (*mode != 0) goto L_006e; PUSHS "DRAFT4's move is " *mode = 1; goto L_006f /* GOTO (is this always %continue or %exit?) */; L_006e: PUSHS " , " L_006f: #line 357 // 356 PRINTSYMBOL(OLDX+'A') // 357 PRINTSYMBOL(OLDY+'1') #line 358 // 358 PRINTSYMBOL('-') #line 359 // 359 PRINTSYMBOL(NEWX+'A') #line 360 // 360 PRINTSYMBOL(NEWY+'1') #line 361 // 361 %END #line 362 // 362 L_0001: #line 364 // 363 %INTEGERFN POSITION OF(%INTEGER S1, S2) // 364 %RESULT = (S1-'A')+10*(S2-'1') goto L_0001 /* GOTO (is this always %continue or %exit?) */; int positionof {ind obj} ; ( int s1 ; int s2 ; ) #line 365 // 365 %END return(((s1 - 65) + ((s2 - 49) * 10))); #line 366 // 366 L_0001: #line 368 // 367 %ROUTINE SKIP SPACES AND NLS // 368 SKIP SYMBOL %WHILE NEXT SYMBOL=' ' %OR NEXT SYMBOL=NL goto L_0001 /* GOTO (is this always %continue or %exit?) */; void skipspacesandnls ; () #line 369 // 369 %END L_006f: /*%external*/ %spec nextsymbol (); if (/*%external*/ %spec printsymbol ((newy + 49)) == 32) goto L_0070; /*%external*/ %spec nextsymbol (); if (/*%external*/ %spec printsymbol ((newx + 65)) != 10) goto L_0071; L_0070: /*%external*/ %spec skipsymbol (); L_006f: /* continue address */ } /* end loop */ L_0071: #line 370 // 370 L_0001: #line 372 // 371 COMPNUM == COMP(25); OPPNUM == OPP(25) // 372 CPULIMIT ("12"); ! FOR EMAS - JGH MOD, AS CS1 WERE RUNNING OUT /*%name*/ compnum = &comp [25]; #line 372 /*%name*/ oppnum = &opp [25]; #line 373 // 373 PRINTSTRING("The Draughts programme DRAFT4.4 PUSHS "12" #line 374 // 374 PUSHS "The Draughts programme DRAFT4.4\n\n" #line 377 // 375 ") // 376 PRINT STRING("Do you want some help?"); NEWLINE // 377 PROMPT(":") PUSHS "Do you want some help?" #line 377 /*%external*/ %spec newline (); #line 378 // 378 READ SYMBOL(REPLY(1)); SKIP SYMBOL %WHILE NEXT SYMBOL#NL; SKIP SYMBOL PUSHS ":" #line 379 // 379 REPLY(1) = REPLY(1)-32 %IF REPLY(1)>='a' #line 379 L_0072: /*%external*/ %spec nextsymbol (); if (/*%prim*/ %spec readsymbol (reply [1]) == 10) goto L_0073; /*%external*/ %spec skipsymbol (); L_0072: /* continue address */ } /* end loop */ L_0073: #line 379 /*%external*/ %spec skipsymbol (); #line 380 // 380 %IF REPLY(1)='Y' %START if (reply [1] < 97) goto L_0074; reply [1] = (reply [1] - 32); L_0074: #line 381 // 381 PRINTSTRING(" if (reply [1] != 89) goto L_0075; #line 382 // 382 PUSHS "\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." #line 387 // 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(" // 387 C3-E5 move C3 to E5, taking the piece on D4 PUSHS "\n C3-E5 move C3 to E5, taking the piece on D4\n" #line 389 // 388 "); PRINTSTRING(" C3-E5, // 389 E5-C7 an example of a multiple jump PUSHS " C3-E5,\n E5-C7 an example of a multiple jump\n\n e.t.c." #line 393 // 390 // 391 e.t.c.") // 392 %FINISH // 393 RESTART: L_0075: #line 394 // 394 EXPECTED MOVE = 0 L_0076: #line 395 // 395 ! setting up the pieces expectedmove = 0; #line 397 // 396 %CYCLE P = -1, 1, 26 // 397 COMP(P) = PLAYER1(P) for (p = (-1); p += 1; p != 26) { #line 398 // 398 OPP(P) = PLAYER2(P) comp [p ] = player1 [p ]; #line 399 // 399 %REPEAT opp [p ] = player2 [p ]; #line 400 // 400 NEWLINE L_0077: /* continue address */ } /* end loop */ L_0078: #line 401 // 401 PRINT STRING("Do you want to start?") /*%external*/ %spec newline (); #line 402 // 402 NEWLINE PUSHS "Do you want to start?" #line 403 // 403 PROMPT(":") /*%external*/ %spec newline (); #line 404 // 404 READ SYMBOL(REPLY(1)) PUSHS ":" #line 405 // 405 REPLY(1) = REPLY(1)-32 %IF REPLY(1)>='a' #line 406 // 406 SKIP SYMBOL %WHILE NEXT SYMBOL#NL; SKIP SYMBOL if (reply [1] < 97) goto L_0079; reply [1] = (reply [1] - 32); L_0079: #line 407 // 407 %IF REPLY(1)='R' %START L_007a: /*%external*/ %spec nextsymbol (); if (/*%prim*/ %spec readsymbol (reply [1]) == 10) goto L_007b; /*%external*/ %spec skipsymbol (); L_007a: /* continue address */ } /* end loop */ L_007b: #line 407 /*%external*/ %spec skipsymbol (); #line 408 // 408 ! Read board position if (reply [1] != 82) goto L_007c; #line 410 // 409 %CYCLE P = -1,1,26 // 410 COMP(P) = 0 for (p = (-1); p += 1; p != 26) { #line 411 // 411 OPP(P) = 0 comp [p ] = 0; #line 412 // 412 %REPEAT opp [p ] = 0; #line 413 // 413 PRINT STRING("Where are your pieces?"); NEWLINE L_007d: /* continue address */ } /* end loop */ L_007e: #line 414 // 414 PROMPT(":") PUSHS "Where are your pieces?" #line 414 /*%external*/ %spec newline (); #line 415 // 415 %CYCLE P = 1,1,12 PUSHS ":" #line 416 // 416 SKIP SPACES AND NLS for (p = 1; p += 1; p != 12) { #line 417 // 417 READ SYMBOL(A); %IF A='.' %THEN %EXIT skipspacesandnls (); #line 418 // 418 READ SYMBOL(B); READ SYMBOL(C) #line 418 if (a != 46) goto L_0081; goto L_0080 /* GOTO (is this always %continue or %exit?) */; L_0081: #line 419 // 419 A = A-32 %IF A>='a' #line 419 #line 420 // 420 B = B-32 %IF A>='a' if (a < 97) goto L_0082; a = (a - 32); L_0082: #line 421 // 421 POS = POSITION OF(A,B) if (a < 97) goto L_0083; b = (b - 32); L_0083: #line 422 // 422 OPP(P) = POS pos = positionof (a , b ); #line 423 // 423 %IF C=' ' %THEN OPP(P+12) = 1000 %ELSE OPP(P+12) = CROWN opp [p ] = pos ; #line 424 // 424 %REPEAT if (c != 32) goto L_0084; opp [(p + 12)] = 1000; goto L_0067 /* GOTO (is this always %continue or %exit?) */; L_0084: opp [(p + 12)] = crown ; L_0067: #line 425 // 425 OPP(0) = 2 L_007f: /* continue address */ } /* end loop */ L_0080: #line 426 // 426 OPP(25) = P; ! no of pieces. opp [0] = 2; #line 427 // 427 PRINT STRING("Where are my pieces?"); NEWLINE opp [25] = p ; #line 428 // 428 %CYCLE P = 1,1,12 PUSHS "Where are my pieces?" #line 428 /*%external*/ %spec newline (); #line 429 // 429 SKIP SPACES AND NLS for (p = 1; p += 1; p != 12) { #line 430 // 430 READ SYMBOL(A); %IF A='.' %THEN %EXIT skipspacesandnls (); #line 431 // 431 READ SYMBOL(B); READ SYMBOL(C) #line 431 if (a != 46) goto L_0087; goto L_0086 /* GOTO (is this always %continue or %exit?) */; L_0087: #line 432 // 432 A = A-32 %IF A>='a' #line 432 #line 433 // 433 B = B-32 %IF B>='a' if (a < 97) goto L_0088; a = (a - 32); L_0088: #line 434 // 434 POS = POSITION OF(A,B) if (b < 97) goto L_0089; b = (b - 32); L_0089: #line 435 // 435 COMP(P) = POS pos = positionof (a , b ); #line 436 // 436 %IF C=' ' %THEN COMP(P+12) = 1000 %ELSE COMP(P+12) = CROWN comp [p ] = pos ; #line 437 // 437 %REPEAT if (c != 32) goto L_008a; comp [(p + 12)] = 1000; goto L_0067 /* GOTO (is this always %continue or %exit?) */; L_008a: comp [(p + 12)] = crown ; L_0067: #line 438 // 438 COMP(0) = ME L_0085: /* continue address */ } /* end loop */ L_0086: #line 439 // 439 COMP(25) = P; ! NO OF PIECES comp [0] = me ; #line 440 // 440 SKIP SYMBOL; ! NL comp [25] = p ; #line 441 // 441 PROMPT("Your move?") /*%external*/ %spec skipsymbol (); #line 442 // 442 READ SYMBOL(A) PUSHS "Your move?" #line 443 // 443 SKIP SYMBOL %WHILE NEXT SYMBOL#NL; SKIP SYMBOL #line 444 // 444 A = A-32 %IF A>='a' L_008b: /*%external*/ %spec nextsymbol (); if (/*%prim*/ %spec readsymbol (a ) == 10) goto L_008c; /*%external*/ %spec skipsymbol (); L_008b: /* continue address */ } /* end loop */ L_008c: #line 444 /*%external*/ %spec skipsymbol (); #line 445 // 445 %IF A='Y' %THEN -> READ MOVE %ELSE -> COMP MOVE if (a < 97) goto L_008d; a = (a - 32); L_008d: #line 446 // 446 %FINISH if (a != 89) goto L_008e; goto L_008f /* JUMP */; L_008e: goto L_0090 /* JUMP */; #line 447 // 447 %IF REPLY(1) = 'N' %START L_007c: #line 448 // 448 PRINT STRING("Think of a number please"); NEWLINE if (reply [1] != 78) goto L_0091; #line 449 // 449 READ SYMBOL(I); SKIP SYMBOL PUSHS "Think of a number please" #line 449 /*%external*/ %spec newline (); #line 450 // 450 I = (I-'0')&3 #line 450 /*%external*/ %spec skipsymbol (); #line 451 // 451 COMP(-1) = 'B'; OPP(-1) = 'W' i = (3 & (i - 48)); #line 452 // 452 PRINTSTRING("DRAFT4's opening move is ") comp [(-1)] = 66; #line 452 opp [(-1)] = 87; #line 453 // 453 %IF I = 1 %THEN PRINTSTRING("D6-C5") %AND COMP(11) = 42 PUSHS "DRAFT4's opening move is " #line 454 // 454 %IF I = 2 %THEN PRINTSTRING("D6-E5") %AND COMP(11) = 44 if (i != 1) goto L_0092; PUSHS "D6-C5" comp [11] = 42; L_0092: #line 455 // 455 %IF I = 3 %THEN PRINTSTRING("F6-E5") %AND COMP(10) = 44 if (i != 2) goto L_0093; PUSHS "D6-E5" comp [11] = 44; L_0093: #line 456 // 456 NEWLINE if (i != 3) goto L_0094; PUSHS "F6-E5" comp [10] = 44; L_0094: #line 457 // 457 %FINISH /*%external*/ %spec newline (); #line 458 // 458 READ MOVE: L_0091: #line 459 // 459 PRINT BOARD L_008f: #line 460 // 460 PROMPT("Your move:") printboard (); #line 461 // 461 SKIP SYMBOL %WHILE NEXT SYMBOL <= ' ' PUSHS "Your move:" #line 462 // 462 %CYCLE I = 1, 1, 8 L_0095: /*%external*/ %spec nextsymbol (); if (/*%prim*/ %spec readsymbol (i , /*%external*/ %spec printstring , /*%external*/ %spec printstring , /*%external*/ %spec printstring , /*%external*/ %spec printstring , /*%external*/ %spec prompt ) > 32) goto L_0096; /*%external*/ %spec skipsymbol (); L_0095: /* continue address */ } /* end loop */ L_0096: #line 463 // 463 READ SYMBOL(REPLY(I)) for (i = 1; i += 1; i != 8) { #line 464 // 464 REPLY(I) = REPLY(I)-32 %IF REPLY(I)>='a' #line 465 // 465 %EXIT %IF REPLY(I) = NL if (reply [i ] < 97) goto L_0099; reply [i ] = (reply [i ] - 32); L_0099: #line 466 // 466 %REPEAT if (reply [i ] != 10) goto L_009a; goto L_0098 /* GOTO (is this always %continue or %exit?) */; L_009a: #line 467 // 467 REPLY(I) = ' ' %AND I = I+1 %UNTIL I = 9 L_0097: /* continue address */ } /* end loop */ L_0098: #line 468 // 468 %IF REPLY(1) = 'M' %THEN MON = 'M' %AND -> READ MOVE L_009b: reply [i ] = 32; i = (i + 1); if (i == 9) goto L_009c; L_009b: /* continue address */ } /* end loop */ L_009c: #line 469 // 469 %IF REPLY(1) = 'Q' %THEN MON = 'Q' %AND -> READ MOVE if (reply [1] != 77) goto L_009d; /*%own*/ mon = 77; goto L_008f /* JUMP */; L_009d: #line 470 // 470 TRANS: if (reply [1] != 81) goto L_009e; /*%own*/ mon = 81; goto L_008f /* JUMP */; L_009e: #line 471 // 471 %IF REPLY(1) = 'I' %THEN -> STOP L_009f: #line 472 // 472 %IF REPLY(6) = ','%THEN MORE = 'M' %ELSE MORE = ' ' if (reply [1] != 73) goto L_00a0; goto L_00a1 /* JUMP */; L_00a0: #line 473 // 473 OLDPOS = POSITION OF(REPLY(1), REPLY(2)) if (reply [6] != 44) goto L_00a2; more = 77; goto L_00a3 /* GOTO (is this always %continue or %exit?) */; L_00a2: more = 32; L_00a3: #line 474 // 474 NEWPOS = POSITION OF(REPLY(4), REPLY(5)) oldpos = positionof (reply [1], reply [2]); #line 475 // 475 %IF VALID POS(OLDPOS) = -1 %START newpos = positionof (reply [4], reply [5]); #line 476 // 476 PRINTSTRING("The square ") if (validpos (oldpos ) != (-1)) goto L_00a4; #line 477 // 477 PRINT SYMBOL(REPLY(1)); PRINT SYMBOL(REPLY(2)) PUSHS "The square " #line 478 // 478 PRINTSTRING(" does not exist! #line 478 #line 479 // 479 ") PUSHS " does not exist!\n" #line 481 // 480 SAY PLEASE // 481 -> READ MOVE sayplease (); #line 482 // 482 %FINISH goto L_008f /* JUMP */; #line 483 // 483 M = VALID POS(NEWPOS) L_00a4: #line 484 // 484 %IF M = -1 %START m = validpos (newpos ); #line 485 // 485 PRINTSTRING("You cannot move to square ") if (m != (-1)) goto L_00a5; #line 486 // 486 PRINTSYMBOL(REPLY(4)); PRINTSYMBOL(REPLY(5)) PUSHS "You cannot move to square " #line 487 // 487 PRINTSTRING("; it does not exist! #line 487 #line 488 // 488 ") PUSHS "; it does not exist!\n" #line 490 // 489 SAY PLEASE // 490 -> READ MOVE sayplease (); #line 491 // 491 %FINISH goto L_008f /* JUMP */; #line 492 // 492 %IF M = 1 %START L_00a5: #line 493 // 493 PRINTSTRING("You cannot move to square ") if (m != 1) goto L_00a6; #line 494 // 494 PRINT SYMBOL(REPLY(4)); PRINT SYMBOL(REPLY(5)) PUSHS "You cannot move to square " #line 495 // 495 PRINTSTRING("; it is already occupied! #line 495 #line 496 // 496 ") PUSHS "; it is already occupied!\n" #line 498 // 497 SAY PLEASE // 498 -> READ MOVE sayplease (); #line 499 // 499 %FINISH goto L_008f /* JUMP */; #line 500 // 500 %CYCLE P = 1, 1, OPP(25) L_00a6: #line 501 // 501 %IF OLDPOS = OPP(P) %THENEXIT for (p = 1; p += 1; p != opp [25]) { #line 502 // 502 %REPEAT if (oldpos != opp [p ]) goto L_00a8; goto L_00a7 /* GOTO (is this always %continue or %exit?) */; L_00a8: #line 503 // 503 %UNLESS OLDPOS = OPP(P) %START L_00a3: /* continue address */ } /* end loop */ L_00a7: #line 504 // 504 PRINTSTRING("You do not have a piece on square ") if (oldpos == opp [p ]) goto L_00a9; #line 505 // 505 PRINT SYMBOL(REPLY(1)); PRINT SYMBOL(REPLY(2)) PUSHS "You do not have a piece on square " #line 506 // 506 NEWLINE #line 506 #line 507 // 507 SAY PLEASE /*%external*/ %spec newline (); #line 508 // 508 -> READ MOVE sayplease (); #line 509 // 509 %FINISH goto L_008f /* JUMP */; #line 510 // 510 PIECE = P L_00a9: #line 511 // 511 DIF = NEWPOS-OLDPOS piece = p ; #line 512 // 512 MODIF = MOD(DIF) dif = (newpos - oldpos ); #line 513 // 513 %IF MODIF < 12 %AND EXPECTED MOVE > 0 %START modif = mod (dif ); #line 514 // 514 PRINTSTRING("You MUST take the piece that I am offering you if (modif >= 12) goto L_00aa; if (expectedmove <= 0) goto L_00aa; #line 515 // 515 ") PUSHS "You MUST take the piece that I am offering you\n" #line 517 // 516 SAY PLEASE // 517 -> READ MOVE sayplease (); #line 518 // 518 %FINISH goto L_008f /* JUMP */; #line 519 // 519 %IF MODIF < 12 %AND MORE = 'M' %START L_00aa: #line 520 // 520 PRINTSTRING("That's not part of a multiple jump move if (modif >= 12) goto L_00ab; if (more != 77) goto L_00ab; #line 521 // 521 ") PUSHS "That's not part of a multiple jump move\n" #line 523 // 522 SAY PLEASE // 523 -> READ MOVE sayplease (); #line 524 // 524 %FINISH goto L_008f /* JUMP */; #line 525 // 525 %IF DIF < 0 %AND OPP(PIECE+12) # CROWN %START L_00ab: #line 526 // 526 PRINTSTRING("You cannot move that piece backwards! if (dif >= 0) goto L_00ac; if (opp [(piece + 12)] == crown ) goto L_00ac; #line 527 // 527 ") PUSHS "You cannot move that piece backwards!\n" #line 529 // 528 SAY PLEASE // 529 -> READ MOVE sayplease (); #line 530 // 530 %FINISH goto L_008f /* JUMP */; #line 531 // 531 %UNLESS MODIF = 11 %OR MODIF = 9 %OR MODIF = 22 %OR MODIF = 18 %START L_00ac: #line 532 // 532 PRINTSTRING("That move does not exist in my rule book! if (modif == 11) goto L_00ad; if (modif == 9) goto L_00ad; if (modif == 22) goto L_00ad; if (modif == 18) goto L_00ad; #line 533 // 533 ") PUSHS "That move does not exist in my rule book!\n" #line 535 // 534 SAY PLEASE // 535 -> READ MOVE sayplease (); #line 536 // 536 %FINISH goto L_008f /* JUMP */; #line 537 // 537 %IF MODIF > 11 %START L_00ad: #line 538 // 538 JUMP = DIF//2 if (modif <= 11) goto L_00ae; #line 539 // 539 COMPOS = OLDPOS+JUMP jump = (dif / 2); #line 540 // 540 %CYCLE I = 1, 1, COMP(25) compos = (oldpos + jump ); #line 541 // 541 %EXIT %IF COMPOS = COMP(I) for (i = 1; i += 1; i != comp [25]) { #line 542 // 542 %REPEAT if (compos != comp [i ]) goto L_00b1; goto L_00b0 /* GOTO (is this always %continue or %exit?) */; L_00b1: #line 543 // 543 %UNLESS COMPOS = COMP(I) %START L_00af: /* continue address */ } /* end loop */ L_00b0: #line 544 // 544 PRINTSTRING("You cannot do that. You are not jumping one of my pieces if (compos == comp [i ]) goto L_00b2; #line 545 // 545 ") PUSHS "You cannot do that. You are not jumping one of my pieces\n" #line 547 // 546 SAY PLEASE // 547 -> READ MOVE sayplease (); #line 548 // 548 %FINISH goto L_008f /* JUMP */; #line 549 // 549 JMAN = I L_00b2: #line 550 // 550 %FINISH %ELSE JMAN = 0 jman = i ; #line 551 // 551 MAKE MOVE(DIF, PIECE, JMAN, OPP, COMP) goto L_00b3 /* GOTO (is this always %continue or %exit?) */; L_00ae: jman = 0; L_00b3: #line 552 // 552 %IF MORE = 'M' %START #line 553 // 553 LASTPOS = NEWPOS if (more != 77) goto L_00b4; #line 554 // 554 READ AGAIN: lastpos = newpos ; #line 555 // 555 PROMPT("and:") L_00b5: #line 556 // 556 %CYCLE I = 1, 1, 8 PUSHS "and:" #line 557 // 557 READ SYMBOL(REPLY(I)) for (i = 1; i += 1; i != 8) { #line 558 // 558 REPLY(I) = REPLY(I)-32 %IF REPLY(I)>='a' #line 559 // 559 %EXIT %IF REPLY(I) = NL if (reply [i ] < 97) goto L_00b8; reply [i ] = (reply [i ] - 32); L_00b8: #line 560 // 560 %REPEAT if (reply [i ] != 10) goto L_00b9; goto L_00b7 /* GOTO (is this always %continue or %exit?) */; L_00b9: #line 561 // 561 %IF REPLY(1) = '.'%THEN -> COMP MOVE L_00b6: /* continue address */ } /* end loop */ L_00b7: #line 562 // 562 REPLY(I) = ' ' %AND I = I+1 %UNTIL I = 9 if (reply [1] != 46) goto L_00ba; goto L_0090 /* JUMP */; L_00ba: #line 563 // 563 OLDPOS = POSITION OF(REPLY(1), REPLY(2)) L_00bb: reply [i ] = 32; i = (i + 1); if (i == 9) goto L_00bc; L_00bb: /* continue address */ } /* end loop */ L_00bc: #line 564 // 564 NEWPOS = POSITION OF(REPLY(4), REPLY(5)) oldpos = positionof (reply [1], reply [2]); #line 565 // 565 DIF = NEWPOS-OLDPOS newpos = positionof (reply [4], reply [5]); #line 566 // 566 DIF = MOD(DIF) dif = (newpos - oldpos ); #line 567 // 567 %IF DIF > 11 %AND OLDPOS = LASTPOS %THEN -> TRANS dif = mod (dif ); #line 568 // 568 PRINTSTRING("That's not part of a multiple jump if (dif <= 11) goto L_00bd; if (oldpos != lastpos ) goto L_00bd; goto L_009f /* JUMP */; L_00bd: #line 569 // 569 Please re-type that part PUSHS "That's not part of a multiple jump\nPlease re-type that part\n" #line 572 // 570 ") // 571 -> READ AGAIN // 572 %FINISH goto L_00b5 /* JUMP */; #line 573 // 573 COMP MOVE: ! COMPUTER MAKES MOVE. L_00b4: #line 574 // 574 %IF COMPNUM = 0 %START L_0090: #line 575 // 575 PRINTSTRING(" I have no pieces left so I suppose you have won if (*compnum != 0) goto L_00be; #line 576 // 576 ") PUSHS " I have no pieces left so I suppose you have won\n" #line 578 // 577 -> STOP // 578 %FINISH goto L_00a1 /* JUMP */; #line 579 // 579 %IF PENDING MOVE(COMP, OPP) = -1 %START L_00be: #line 580 // 580 PRINTSTRING("I cannot move any of my pieces so you win if (pendingmove (comp , opp ) != (-1)) goto L_00bf; #line 581 // 581 ") PUSHS "I cannot move any of my pieces so you win\n" #line 583 // 582 -> STOP // 583 %FINISH goto L_00a1 /* JUMP */; #line 584 // 584 ! If in end game then increase search. L_00bf: #line 586 // 585 I = COMPNUM+OPPNUM // 586 %IF I <= 6 %THEN SEARCH LIMIT = 4 i = (*compnum + *oppnum ); #line 587 // 587 ! FIND BEST MOVE. if (i > 6) goto L_00c0; /*%own*/ searchlimit = 4; L_00c0: #line 589 // 588 NODES = 0; SP = 0 // 589 VALUEB = TRY POSSIBLE MOVES(1, 1, COMP, OPP) nodes = 0; #line 589 /*%own*/ sp = 0; #line 590 // 590 %IF VALUEB <= -99990 %START valueb = trypossiblemoves (1, 1, comp , opp ); #line 591 // 591 PRINTSTRING("I resign if (valueb > (-99990)) goto L_00c1; #line 592 // 592 ") PUSHS "I resign\n" #line 594 // 593 -> STOP // 594 %FINISH goto L_00a1 /* JUMP */; #line 595 // 595 I = 0 L_00c1: #line 596 // 596 ANOTHER TAKE: i = 0; #line 597 // 597 TROUT(COMP(BEST PIECE), COMP(BEST PIECE)+MOVE(BEST MOVE), I) L_00c2: #line 598 // 598 MAKE MOVE(MOVE(BEST MOVE), BEST PIECE, BEST TAKE, COMP, OPP) #line 599 // 599 %IF BEST TAKE > 0 %START #line 600 // 600 %CYCLE BEST MOVE = 1, 2, 7 if (besttake <= 0) goto L_00c3; #line 601 // 601 BEST TAKE = VALID MOVE(BEST MOVE, BEST PIECE, COMP, OPP) for (bestmove = 1; bestmove += 2; bestmove != 7) { #line 602 // 602 -> ANOTHER TAKE %IF BEST TAKE>0 besttake = validmove (bestmove , bestpiece , comp , opp ); #line 603 // 603 %REPEAT if (besttake <= 0) goto L_00c6; goto L_00c2 /* JUMP */; L_00c6: #line 604 // 604 %FINISH L_00c4: /* continue address */ } /* end loop */ L_00c5: #line 605 // 605 NEWLINE L_00c3: #line 606 // 606 %IF MON = 'M' %START /*%external*/ %spec newline (); #line 607 // 607 PRINTSTRING("Nodes considered ="); WRITE(NODES, 4) if (mon != 77) goto L_00c7; #line 608 // 608 PRINTSTRING(" PUSHS "Nodes considered =" #line 608 #line 609 // 609 Value of board ="); WRITE(VALUEB, 4) PUSHS "\nValue of board =" #line 610 // 610 NEWLINE #line 611 // 611 %FINISH /*%external*/ %spec newline (); #line 612 // 612 %IF OPPNUM = 0 %START L_00c7: #line 613 // 613 PRINTSTRING("You have no pieces left so I win if (*oppnum != 0) goto L_00c8; #line 614 // 614 ") PUSHS "You have no pieces left so I win\n" #line 616 // 615 -> STOP // 616 %FINISH goto L_00a1 /* JUMP */; #line 617 // 617 EXPECTED MOVE = PENDING MOVE(OPP, COMP) L_00c8: #line 618 // 618 %IF EXPECTED MOVE = -1 %START expectedmove = pendingmove (opp , comp ); #line 619 // 619 PRINTSTRING("You cannot move any of your pieces so I win if (expectedmove != (-1)) goto L_00c9; #line 620 // 620 ") PUSHS "You cannot move any of your pieces so I win\n" #line 622 // 621 -> STOP // 622 %FINISH goto L_00a1 /* JUMP */; #line 623 // 623 %IF VALUEB >= 99990 %AND AWIN = 0 %START L_00c9: #line 624 // 624 PRINTSTRING("He-He! I am going to win!! if (valueb < 99990) goto L_00ca; if (awin != 0) goto L_00ca; #line 625 // 625 ") PUSHS "He-He! I am going to win!!\n" #line 627 // 626 AWIN = 1 // 627 %FINISH /*%own*/ awin = 1; #line 628 // 628 -> READ MOVE L_00ca: #line 629 // 629 STOP: goto L_008f /* JUMP */; #line 630 // 630 PRINTSTRING(" L_00a1: #line 631 // 631 The final board position is - PUSHS "\nThe final board position is -\n" #line 634 // 632 ") // 633 PRINT BOARD // 634 %END printboard (); #line 635 // 635 %ENDOFFILE #line 636 // 636