X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=hachu.c;h=a81f25fcca8a9494ed18ffaaad11a49b7cf1f0c8;hb=0eecd39628e105c45f9baf11bcb785315517404b;hp=c9350aedce27fa4cb77c48c14c52820f0f440bd7;hpb=79c2db473050b802ced129d39a557e47053a2f71;p=hachu.git diff --git a/hachu.c b/hachu.c index c9350ae..a81f25f 100644 --- a/hachu.c +++ b/hachu.c @@ -18,6 +18,7 @@ #define HASH #define KILLERS +#define NULLMOVE #include #include @@ -1633,10 +1634,10 @@ if(flag && depth>= 0) printf("phase=%d: first/curr/last = %d / %d / %d\n", phase bestScore = curEval; resDep = QSdepth; if(bestScore >= beta || depth < -1) goto cutoff; } -#if 0 - if(curEval >= beta) { +#ifdef NULLMOVE + else if(curEval >= beta) { stm ^= WHITE; - score = -Search(-beta, -iterAlpha, -difEval, depth-3, promoSuppress & SQUARE, ABSENT); + score = -Search(-beta, 1-beta, -difEval, depth > 3 ? depth-3 : 0, promoSuppress & SQUARE, ABSENT); stm ^= WHITE; if(score >= beta) { msp = oldMSP; retDep += 3; return score + (score < curEval); } } @@ -2078,6 +2079,21 @@ ReadSquare (char *p, int *sqr) return 2 + (r + ONE > 9); } +int listStart, listEnd; +char boardCopy[BSIZE]; + +void +ListMoves () +{ // create move list on move stack + int i; + for(i=0; i< BSIZE; i++) boardCopy[i] = !!board[i]; +MapFromScratch(attacks); + postThinking--; repCnt = 0; tlim1 = tlim2 = 1e8; msp = 0; + Search(-INF-1, INF+1, 0, 1, sup1 & ~PROMOTE, sup2); + postThinking++; + listStart = retFirst; listEnd = retMSP; +} + MOVE ParseMove (char *moveText) { @@ -2100,18 +2116,15 @@ ParseMove (char *moveText) ret = f<> SQLEN & SQUARE)) break; // any null move matches @@@@ if((moveStack[i] & (PROMOTE | DEFER-1)) == ret) break; if((moveStack[i] & DEFER-1) == ret) deferred = i; // promoted version of entered non-promotion is legal } -printf("# moveNr = %d in {%d,%d}\n", i, retFirst, retMSP); - if(i>=retMSP) { // no exact match +printf("# moveNr = %d in {%d,%d}\n", i, listStart, listEnd); + if(i>=listEnd) { // no exact match if(deferred) { // but maybe non-sensical deferral int flags = p[board[f]].promoFlag; printf("# deferral of %d\n", deferred); @@ -2122,8 +2135,8 @@ printf("# deferral of %d\n", deferred); if(!(flags & promoBoard[f])) moveStack[i] |= DEFER; // came from outside zone, so essential deferral } } - if(i >= retMSP) { - for(i=retFirst; i= listEnd) { + for(i=listStart; i= retMSP ? INVALID : moveStack[i]); + return (i >= listEnd ? INVALID : moveStack[i]); } void @@ -2144,32 +2157,25 @@ Highlight(char *coords) char b[BSIZE], buf[2000], *q; for(i=0; i>SQLEN & SQUARE)) { int t = moveStack[i] & SQUARE; if(t >= SPECIAL) continue; - b[t] = (board[t] == EMPTY ? 'Y' : 'R'); cnt++; + b[t] = (!boardCopy[t] ? 'Y' : 'R'); cnt++; } } if(!cnt) { // no moves from given square if(sqr != lastPut) return; // refrain from sending empty FEN // we lifted a piece for second leg of move - for(i=retFirst; i>SQLEN & SQUARE)) { int e, t = moveStack[i] & SQUARE; if(t < SPECIAL) continue; // only special moves e = lastLift + epList[t - SPECIAL]; // decode t = lastLift + toList[t - SPECIAL]; if(e != sqr) continue; - b[t] = (board[t] == EMPTY ? 'Y' : 'R'); cnt++; + b[t] = (!boardCopy[t] ? 'Y' : 'R'); cnt++; } } if(!cnt) return; @@ -2335,29 +2341,13 @@ printf("in: %s\n", command); if(sscanf(inBuf+7, "Contempt=%d", &contemptFactor) == 1) continue; continue; } - if(!strcmp(command, "variant")) { - for(i=0; i<7; i++) { - sscanf(inBuf+8, "%s", command); - if(!strcmp(variants[i].name, command)) { - Init(curVarNr = i); stm = Setup2(NULL); break; - } - } - continue; - } if(!strcmp(command, "sd")) { sscanf(inBuf, "sd %d", &maxDepth); continue; } if(!strcmp(command, "st")) { sscanf(inBuf, "st %d", &timePerMove); continue; } if(!strcmp(command, "memory")) { SetMemorySize(atoi(inBuf+7)); continue; } if(!strcmp(command, "ping")) { printf("pong%s", inBuf+4); continue; } // if(!strcmp(command, "")) { sscanf(inBuf, " %d", &); continue; } - if(!strcmp(command, "new")) { - engineSide = BLACK; Init(V_CHESS); stm = Setup2(NULL); maxDepth = MAXPLY; randomize = OFF; curVarNr = comp = 0; - continue; - } - if(!strcmp(command, "setboard")){ engineSide = NONE; Init(curVarNr); stm = Setup2(inBuf+9); continue; } if(!strcmp(command, "easy")) { ponder = OFF; continue; } if(!strcmp(command, "hard")) { ponder = ON; continue; } - if(!strcmp(command, "undo")) { stm = TakeBack(1); continue; } - if(!strcmp(command, "remove")) { stm = TakeBack(2); continue; } if(!strcmp(command, "go")) { engineSide = stm; continue; } if(!strcmp(command, "post")) { postThinking = ON; continue; } if(!strcmp(command, "nopost")) { postThinking = OFF;continue; } @@ -2380,7 +2370,7 @@ printf("in: %s\n", command); if(!strcmp(command, "accepted")){ continue; } if(!strcmp(command, "rejected")){ continue; } if(!strcmp(command, "result")) { continue; } - if(!strcmp(command, "hover")) { continue; } + if(!strcmp(command, "hover")) { continue; } if(!strcmp(command, "")) { continue; } if(!strcmp(command, "usermove")){ int move = ParseMove(inBuf+9); @@ -2395,6 +2385,22 @@ pboard(board); } continue; } + if(!strcmp(command, "new")) { + engineSide = BLACK; Init(V_CHESS); stm = Setup2(NULL); maxDepth = MAXPLY; randomize = OFF; curVarNr = comp = 0; + continue; + } + if(!strcmp(command, "variant")) { + for(i=0; i<7; i++) { + sscanf(inBuf+8, "%s", command); + if(!strcmp(variants[i].name, command)) { + Init(curVarNr = i); stm = Setup2(NULL); break; + } + } + continue; + } + if(!strcmp(command, "setboard")){ engineSide = NONE; Init(curVarNr); stm = Setup2(inBuf+9); continue; } + if(!strcmp(command, "undo")) { stm = TakeBack(1); continue; } + if(!strcmp(command, "remove")) { stm = TakeBack(2); continue; } printf("Error: unknown command\n"); } }