}\r
\r
int\r
-Surround (int stm, int king, int start)\r
+Surround (int stm, int king, int start, int max)\r
{\r
int i, s=0;\r
for(i=start; i<9; i++) {\r
v = p[piece].value;\r
s += -(v > 70) & v;\r
}\r
- return (s > 512 ? 512 : s);\r
+ return (s > max ? max : s);\r
}\r
\r
int\r
int\r
Evaluate (int difEval)\r
{\r
- int wLion = ABSENT, bLion = ABSENT, wKing, bKing, score=mobilityScore, f, i, j;\r
+ int wLion = ABSENT, bLion = ABSENT, wKing, bKing, score=mobilityScore, f, i, j, max=512;\r
\r
if(p[WHITE+2].value == LVAL) wLion = p[WHITE+2].pos;\r
if(p[BLACK+2].value == LVAL) bLion = p[BLACK+2].pos;\r
score += (PST[PST_CENTER+wKing] - PST[PST_CENTER+bKing])*(32 - filling) >> 7;\r
if(lead > 100) score -= PST[PST_CENTER+bKing]*(32 - filling) >> 3; // white leads, drive black K to corner\r
if(lead < -100) score += PST[PST_CENTER+wKing]*(32 - filling) >> 3; // black leads, drive white K to corner\r
+ max = 16*filling;\r
}\r
\r
# ifdef FORTRESS\r
# endif\r
\r
# ifdef KSHIELD\r
- score += Surround(WHITE, wKing, 1) - Surround(BLACK, bKing, 1) >> 3;\r
+ score += Surround(WHITE, wKing, 1, max) - Surround(BLACK, bKing, 1, max) >> 3;\r
# endif\r
\r
#endif\r
int sq;\r
if((wLion = kylin[WHITE]) && (sq = p[wLion].pos) != ABSENT) {\r
int anchor = sq - PST[5*BW*BH - 1 - sq]; // FIXME: PST_ZONDIST indexed backwards\r
- score += (512 - Surround(BLACK, anchor, 0))*(128 - filling)*PST[p[wLion].pst + sq] >> 15;\r
+ score += (512 - Surround(BLACK, anchor, 0, 512))*(128 - filling)*PST[p[wLion].pst + sq] >> 15;\r
}\r
if((bLion = kylin[BLACK]) && (sq = p[bLion].pos) != ABSENT) {\r
int anchor = sq + PST[PST_ZONDIST + sq];\r
- score -= (512 - Surround(WHITE, anchor, 0))*(128 - filling)*PST[p[bLion].pst + sq] >> 15;\r
+ score -= (512 - Surround(WHITE, anchor, 0, 512))*(128 - filling)*PST[p[bLion].pst + sq] >> 15;\r
}\r
}\r
#endif\r