// promotions by pieces with Lion power stepping in & out the zone in same turn\r
// promotion on capture\r
\r
-#define VERSION "0.12n"\r
+#define VERSION "0.13"\r
\r
#define PATH level==0 || path[0] == 0x848f1 && (level==1 /*|| path[1] == 0x3f081 && (level == 2 || path[2] == 0x6f0ac && (level == 3 || path[3] == 0x3e865 && (level == 4 || path[4] == 0x4b865 && (level == 5))))*/)\r
//define PATH 0\r
#define HASH\r
#define KILLERS\r
#define NULLMOVE\r
+#define CHECKEXT\r
#define LIONTRAP\r
#define XKINGSAFETY\r
\r
int\r
Search (int alpha, int beta, int difEval, int depth, int oldPromo, int promoSuppress, int threshold)\r
{\r
- int i, j, k, phase, king, nextVictim, to, defer, autoFail=0;\r
+ int i, j, k, phase, king, nextVictim, to, defer, autoFail=0, inCheck = 0, late=INF;\r
int firstMove, oldMSP = msp, curMove, sorted, bad, dubious, bestMoveNr;\r
int resDep, iterDep, ext;\r
int myPV = pvPtr;\r
xstm = stm ^ WHITE;\r
//printf("map made\n");fflush(stdout);\r
\r
- // TSUME filter\r
- if(tsume && tsume & stm+1) {\r
+ // in-check test and TSUME filter\r
+ {\r
k = p[king=royal[stm]].pos;\r
-// if( k == ABSENT) k = p[king + 2].pos;\r
- if( k != ABSENT && !attacks[2*k + xstm]) {\r
- retDep = 60; return INF; // we win when not in check\r
+ if( k == ABSENT) k = p[king + 2].pos;\r
+ else if(p[king + 2].pos != ABSENT) k = ABSENT; // two kings is no king...\r
+ if( k != ABSENT) { // check is possible\r
+ if(!attacks[2*k + xstm]) {\r
+ if(tsume && tsume & stm+1) {\r
+ retDep = 60; return INF; // we win when not in check\r
+ }\r
+ }\r
+#ifdef CHECKEXT\r
+ else if(depth >= QSdepth) inCheck = 1, depth++;\r
+#endif\r
}\r
}\r
\r
switch(phase) {\r
case 0: // null move\r
#ifdef NULLMOVE\r
- if(depth > QSdepth && curEval >= beta) {\r
+ if(depth > QSdepth && curEval >= beta && !inCheck) {\r
int nullDep = depth - 3;\r
stm ^= WHITE;\r
score = -Search(-beta, 1-beta, -difEval, nullDep<QSdepth ? QSdepth : nullDep, promoSuppress & SQUARE, ABSENT, INF);\r
xstm = stm; stm ^= WHITE;\r
- if(score >= beta) { msp = oldMSP; retDep += 3; return score + (score < curEval); }\r
+ if(score >= beta) { msp = oldMSP; retDep += 3; pvPtr = myPV; return score + (score < curEval); }\r
}\r
#endif\r
if(tenFlag) FireSet(&tb); // in tenjiku we must identify opposing Fire Demons to perform any moves\r
for(i=curMove; i<msp; i++) if(moveStack[i] == h) { moveStack[i] = moveStack[j]; moveStack[j++] = h; break; }\r
h = killer[level][1];\r
for(i=curMove; i<msp; i++) if(moveStack[i] == h) { moveStack[i] = moveStack[j]; moveStack[j++] = h; break; }\r
+ late = j;\r
}\r
+#else\r
+ late = j;\r
#endif\r
phase = 7;\r
sorted = msp; // do not sort noncapts\r
msp = oldMSP; // pop move list\r
pvPtr = myPV; // pop PV\r
retMove = bestMoveNr ? moveStack[bestMoveNr] : 0;\r
- retDep = resDep;\r
+ retDep = resDep - inCheck;\r
if(PATH) printf("return %d: %d %d (t=%d s=%d lim=%d)\n", depth, bestScore, curEval, GetTickCount(), startTime, tlim1),fflush(stdout);\r
return bestScore + (bestScore < curEval);\r
}\r