X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=hachu.c;h=5b6f69c5e2cd13ca09b9250280e67aa398d652cd;hb=5f73c57bc970dac79e86a73a37ea8e37caadb7dc;hp=40c31e5a285e23a41593ad89444f2c68a3417b02;hpb=5c1fa8b0d0076c229f483e7c868bdaa6f1103389;p=hachu.git diff --git a/hachu.c b/hachu.c index 40c31e5..5b6f69c 100644 --- a/hachu.c +++ b/hachu.c @@ -87,7 +87,7 @@ typedef struct { } UndoInfo; int bWidth, bHeight, bsize, zone, currentVariant; -int stm, xstm, hashKeyH, hashKeyL, framePtr, msp, nonCapts, rootEval, retMSP, retFirst, pvPtr, level, cnt50, chuFlag=1; +int stm, xstm, hashKeyH, hashKeyL, framePtr, msp, nonCapts, rootEval, retMSP, retFirst, pvPtr, level, cnt50, chuFlag=1, mobilityScore; int nodes, startTime, tlim1, tlim2; Move retMove, moveStack[10000], path[100], repStack[300], pv[1000]; @@ -533,13 +533,13 @@ Compactify (int stm) int AddPiece (int stm, PieceDesc *list) { - int i, j, *key; + int i, j, *key, v; for(i=stm+2; i<=last[stm]; i += 2) { if(p[i].value < 10*list->value || p[i].value == 10*list->value && (p[i].promo < 0)) break; } last[stm] += 2; for(j=last[stm]; j>i; j-= 2) p[j] = p[j-2]; - p[i].value = 10*list->value; + p[i].value = v = 10*list->value; for(j=0; j<8; j++) p[i].range[j] = list->range[j^4*(WHITE-stm)]; switch(Range(p[i].range)) { case 1: p[i].pst = BH; break; @@ -550,6 +550,7 @@ AddPiece (int stm, PieceDesc *list) if(!*key) *key = ~(myRandom()*myRandom()); p[i].pieceKey = *key; p[i].promoFlag = 0; + p[i].mobWeight = v > 600 ? 0 : v >= 400 ? 1 : v >= 300 ? 2 : v > 150 ? 3 : v >= 100 ? 2 : 0; for(j=stm+2; j<= last[stm]; j+=2) { if(p[j].promo >= i) p[j].promo += 2; } @@ -676,39 +677,6 @@ Init (int var) } } -#if 0 -inline int -AddMove (int i, int x, int y) -{ - if(board[y] == EDGE) return 1; - if(board[y] == EMPTY) { // non-capt - if((flagBoard[x] | flagBoard[y]) & p[i].flags) { // promotion possible - moveStack[msp++] = moveStack[nonCapts]; - moveStack[nonCapts++] |= PROMOTE | p[i].flags << 24; - if(!(p[i].flags & ALWAYS_PROMOTE)) - moveStack[msp++] = x << SQLEN | y; // push deferral as well - else moveStack[msp++] = x << SQLEN | y; // normal move - } - } else { // capture - if(((board[y] ^ i) & 1) return 1; // own - moveStack[msp++] = moveStack[nonCapts]; - moveStack[nonCapts++] = moveStack[promotions]; - moveStack[promotions++] = x << SQLEN | y; - if((flagBoard[x] | flagBoard[y]) & p[i].flags) { // promotion possible - int p = promotions; - if(!(p[i].flags & ALWAYS_PROMOTE)) { - moveStack[msp++] = moveStack[nonCapts]; - moveStack[nonCapts++] = moveStack[promotions]; - moveStack[promotions++] = moveStack[p-1]; - } - moveStack[p-1] += PROMOTE | p[i].flags<<24; - } - return 1; // capture ends ray scan - } - return 0; -} -#endif - int flag; inline int @@ -747,42 +715,6 @@ NewCapture (int x, int y, int promoFlags) return 0; } -#if 0 -void -GenAllMoves () -{ - int i, j, k; - promotions = nonCapts = msp; - for(i=stm+2; i<=last[stm]; i+=2) { - int x = p[i].pos; - if(x == ABSENT) continue; - for(j=0; j<8; j++) { - int y, v = kStep[j], r = p[i].range[j]; - if(r < 0) { // jumping piece, special treatment - if(r >= -3) { // in any case, do a jump of 2 - if(board[x + 2*v] == EMPTY) - ADDMOVE(x, x+2*v); - if(r < -1) { // Lion power, also single step - if(board[x + v] == EMPTY) - ADDMOVE(x, x+v); - if(r == -3) { // true Lion, also Knight jump - v = nStep[j]; - if(board[x + v] == EMPTY) - ADDMOVE(x, x+v); - } - } - } - continue; - } - y = x; - while(r-- > 0) { - if(board[y+=v] == GUARD) break; // off board - if((board[y] + i & 1) == 0) break; // same color - } - } -} -#endif - int GenNonCapts (int promoSuppress) { @@ -822,11 +754,12 @@ report (int x, int y, int i) { } -void +int MapOneColor (int start, int last, int *map) { - int i, j, k; + int i, j, k, totMob = 0; for(i=start+2; i<=last; i+=2) { + int mob = 0; if(p[i].pos == ABSENT) continue; for(j=0; j<8; j++) { int x = p[i].pos, v = kStep[j], r = p[i].range[j]; @@ -838,7 +771,7 @@ MapOneColor (int start, int last, int *map) } else if(r >= S) { // in any case, do a jump of 2 if(board[x + 2*v] != EMPTY && board[x + 2*v] != EDGE) - map[2*(x + 2*v) + start] += one[j]; + map[2*(x + 2*v) + start] += one[j], mob += (board[x + 2*v] ^ start) & 1; if(r < J) { // Lion power, also single step if(board[x + v] != EMPTY && board[x + v] != EDGE) map[2*(x + v) + start] += one[j]; @@ -868,12 +801,16 @@ MapOneColor (int start, int last, int *map) } while(r-- > 0) { if(board[x+=v] != EMPTY) { - if(board[x] != EDGE) map[2*x + start] += one[j]; + mob += dist[x-v-p[i].pos]; + if(board[x] != EDGE) map[2*x + start] += one[j], mob += (board[x] ^ start) & 1; break; } } } + totMob += mob * p[i].mobWeight; } +if(!level) printf("# mobility %d = %d\n", start, totMob); + return totMob; } void @@ -881,8 +818,8 @@ MapFromScratch (int *map) { int i; for(i=0; i<2*bsize; i++) map[i] = 0; - MapOneColor(0, last[BLACK], map); - MapOneColor(1, last[WHITE], map); + mobilityScore = MapOneColor(1, last[WHITE], map); + mobilityScore -= MapOneColor(0, last[BLACK], map); } void @@ -1271,7 +1208,7 @@ GenCapts(int sqr, int victimValue) int Evaluate () { - return 0; + return (stm ? mobilityScore : -mobilityScore); } int @@ -1761,10 +1698,10 @@ SearchBestMove (int stm, int timeLeft, int mps, int timeControl, int inc, int ti { int score, targetTime, movesLeft = 50; if(mps) movesLeft = mps - (moveNr>>1)%mps; - targetTime = timeLeft*10 / (movesLeft + 1) + 1000 * inc; + targetTime = timeLeft*10 / (movesLeft + 2) + 1000 * inc; if(timePerMove > 0) targetTime = timeLeft * 5; startTime = GetTickCount(); - tlim1 = 0.3*targetTime; + tlim1 = 0.2*targetTime; tlim2 = 1.9*targetTime; nodes = 0; MapFromScratch(attacks);