X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=hachu.c;h=aa37ab3f44b6648e853fe784e1e3426c0a784385;hb=c40c2b9d2eb9abc3cd530a1ff96aaf0e6fc91643;hp=ff5cc8f28dfc7d56817257ee7803dda00986cbb2;hpb=023af02b0b3c0643b612183f8670807b081125f4;p=hachu.git diff --git a/hachu.c b/hachu.c index ff5cc8f..aa37ab3 100644 --- a/hachu.c +++ b/hachu.c @@ -16,9 +16,9 @@ #define PATH level==0 || path[0] == 0xc4028 && (level==1 /*|| path[1] == 0x75967 && (level == 2 || path[2] == 0x3400b && (level == 3))*/) //define PATH 0 -#define HASH -#define KILLERS -#define NULLMOVE +#define XHASH +#define XKILLERS +#define XNULLMOVE #include #include @@ -1500,6 +1500,7 @@ GenCapts(int sqr, int victimValue) NewCapture(x, SPECIAL + 8*(i-1&7) + (i+1&7) + victimValue - SORTKEY(attacker), p[attacker].promoFlag); v = kStep[i+1]; if((board[x+v] & TYPE) == xstm && board[x+v] > board[sqr]) + NewCapture(x, SPECIAL + 8*(i+1&7) + (i-1&7) + victimValue - SORTKEY(attacker), p[attacker].promoFlag); } } else { // primary victim on first ring @@ -1640,8 +1641,8 @@ if(PATH) /*pboard(board),pmap(attacks, BLACK),*/printf("search(%d) {%d,%d} eval= } #endif - replyDep = (depth < 1 ? depth : iterDep < 1 ? 1 : iterDep); - while(++iterDep <= depth) { + replyDep = (depth < 1 ? depth-1 : iterDep); + while(++iterDep <= depth || iterDep == 1) { if(flag && depth>= 0) printf("iter %d:%d\n", depth,iterDep),fflush(stdout); iterAlpha = alpha; bestScore = -INF; bestMoveNr = 0; resDep = 60; for(curMove = firstMove; ; curMove++) { // loop over moves @@ -1853,7 +1854,8 @@ if(PATH) printf("%d:%2d:%d %3d %6x %-10s %6d %6d\n", level, depth, iterDep, curM printf("\n"); fflush(stdout); } - if(GetTickCount() - startTime > tlim1) break; // do not start iteration we can (most likely) not finish +printf("# s=%d t=%d 1=%d 3=%d f=%d\n",startTime,GetTickCount(),tlim1,tlim3,abortFlag); + if(!(abortFlag & 1) && GetTickCount() - startTime > tlim1) break; // do not start iteration we can (most likely) not finish } replyDep = iterDep; #ifdef HASH @@ -2261,6 +2263,9 @@ MapFromScratch(attacks); void PonderUntilInput (int stm) { +MapFromScratch(attacks); + repCnt = 0; abortFlag = -1; + Search(-INF-1, INF+1, rootEval, maxDepth, sup1, sup2); } int TakeBack(int n) @@ -2292,11 +2297,13 @@ printf("# setup done");fflush(stdout); // extract the first word sscanf(inBuf, "%s", command); +printf("# in (mode = %d,%d): %s\n", root, abortFlag, command); if(!strcmp(command, "otim")) { continue; } // do not start pondering after receiving time commands, as move will follow immediately if(!strcmp(command, "time")) { sscanf(inBuf, "time %d", &timeLeft); continue; } if(!strcmp(command, "put")) { ReadSquare(inBuf+4, &lastPut); continue; } // ditto if(!strcmp(command, ".")) { inBuf[0] = 0; return; } // ignore for now if(!strcmp(command, "lift")) { inBuf[0] = 0; Highlight(inBuf+5); return; } // treat here + abortFlag = 1; return; } } @@ -2304,7 +2311,11 @@ printf("# setup done");fflush(stdout); void TerminationCheck() { + if(abortFlag < 0) { // check for input + if(InputWaiting()) GetLine(0); // read & examine input command + } else { // check for time if(GetTickCount() - startTime > tlim3) abortFlag = 2; + } } main() @@ -2314,10 +2325,12 @@ printf("# setup done");fflush(stdout); int i, score, curVarNr; Init(V_CHU); // Chu + listEnd = 1; while(1) { // infinite loop fflush(stdout); // make sure everything is printed before we do something that might take time + *inBuf = 0; if(listEnd == 0) ListMoves(); // always maintain a list of legal moves in root position @@ -2325,6 +2338,7 @@ printf("# setup done");fflush(stdout); if(stm == engineSide) { // if it is the engine's turn to move, set it thinking, and let it move pboard(board); + SetSearchTimes(10*timeLeft); score = SearchBestMove(&move, &ponderMove); if(move == INVALID) { // game apparently ended @@ -2349,6 +2363,7 @@ pboard(board); gameMove[moveNr++] = move; // remember game printf("move %s\n", MoveToText(move, 1)); listEnd = 0; + continue; } }