char c, *q, name[3], prince = 0;\r
PieceDesc *p1, *p2;\r
last[WHITE] = 1; last[BLACK] = 0;\r
+ royal[WHITE] = royal[BLACK] = 0;\r
for(i=0; ; i++) {\r
//printf("next rank: %s\n", array);\r
for(j = BW*i; ; j++) {\r
}\r
}\r
eos:\r
+ // add dummy Kings if not yet added (needed to set royal[] to valid value!)\r
+ if(!royal[WHITE]) p[AddPiece(WHITE, LookUp("K", V_CHU))].pos = ABSENT;\r
+ if(!royal[BLACK]) p[AddPiece(BLACK, LookUp("K", V_CHU))].pos = ABSENT;\r
// add dummy Crown Princes if not yet added\r
if(!(prince & WHITE+1)) p[AddPiece(WHITE, LookUp("CP", V_CHU))].pos = ABSENT;\r
if(!(prince & BLACK+1)) p[AddPiece(BLACK, LookUp("CP", V_CHU))].pos = ABSENT;\r
if( k == ABSENT) {\r
if((k = p[king + 2].pos) == ABSENT && (!tsume || tsume & stm+1))\r
return -INF; // lose when no King (in tsume only for side to be mated)\r
- } else if(p[king + 2].pos != ABSENT) k = ABSENT; // two kings is no king...\r
+ } else if(p[king + 2].pos != ABSENT) {\r
+ if(tsume && tsume & stm+1) {\r
+ retDep = 60; return INF; // we win when not in check\r
+ }\r
+ k = ABSENT; // two kings is no king...\r
+ }\r
if( k != ABSENT) { // check is possible\r
if(!attacks[2*k + xstm]) {\r
if(tsume && tsume & stm+1) {\r
if(to == ABSENT) continue; // ignore if absent\r
if(!attacks[2*to + stm]) continue; // skip if not attacked\r
group = p[nextVictim].value; // remember value of this found victim\r
- if(iterDep <= QSdepth + 1 && 2*group + curEval + 30 < alpha) { resDep = QSdepth + 1; goto cutoff; }\r
+ if(iterDep <= QSdepth + 1 && 2*group + curEval + 30 < alpha) {\r
+ resDep = QSdepth + 1; nextVictim -= 2;\r
+ if(bestScore < 2*group + curEval + 30) bestScore = 2*group + curEval + 30;\r
+ goto cutoff;\r
+ }\r
if(PATH) printf("%d:%2d:%2d group=%d, to=%c%d\n",level,depth,iterDep,group,to%BW+'a',to/BW+ONE);\r
GenCapts(to, 0);\r
if(PATH) printf("%d:%2d:%2d first=%d msp=%d\n",level,depth,iterDep,firstMove,msp);\r
case 6: // non-captures\r
nonCapts = msp;\r
nullMove = GenNonCapts(oldPromo);\r
+ if(msp == nonCapts) goto cutoff;\r
#ifdef KILLERS\r
{ // swap killers to front\r
Move h = killer[level][0]; int j = curMove;\r
\r
if(flag & depth >= 0) printf("%2d:%d made %d/%d %s\n", depth, iterDep, curMove, msp, MoveToText(moveStack[curMove], 0));\r
for(i=2; i<=cnt50; i+=2) if(repStack[level-i+200] == hashKeyH) {\r
+ retDep = iterDep;\r
if(repDraws) { score = 0; goto repetition; }\r
if(!allowRep) {\r
moveStack[curMove] = 0; // erase forbidden move\r
#ifdef HASH\r
// hash store\r
hashTable[index].lock[hit] = hashKeyH;\r
- hashTable[index].depth[hit] = iterDep;\r
+ hashTable[index].depth[hit] = resDep;\r
hashTable[index].score[hit] = bestScore;\r
hashTable[index].flag[hit] = (bestScore < beta) * H_UPPER;\r
if(bestScore > alpha) {\r
*p++ = table[2* (*fen - 'A' - n)+1] + n;\r
}\r
} else *p++ = *fen;\r
+ if(!*fen) break;\r
fen++;\r
}\r
printf("# converted FEN '%s'\n", fenArray);\r