From: H.G.Muller Date: Fri, 21 Oct 2016 12:57:36 +0000 (+0200) Subject: Implement randomizing X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=7e038f3f6429a8006f64f6cc52af8f6eb5c74403;p=crazywa.git Implement randomizing The first 10 half-moves are now randomized by adding a small random bonus to each move in the root. --- diff --git a/dropper.c b/dropper.c index 2c5fbae..f0975d5 100644 --- a/dropper.c +++ b/dropper.c @@ -40,6 +40,8 @@ int ReadClock (int start); char *MoveToText (int move); int TimeIsUp (int mode); +int randomize, ranKey; +int moveNr; // part of game state; incremented by MakeMove #define captCode (rawInts + 22*10 + 10) #define deltaVec (rawChar + 22*10 + 10) @@ -894,7 +896,7 @@ Search (int stm, int alpha, int beta, StackFrame *ff, int depth, int reduction, int oldSP = moveSP, *pvStart = pvPtr; int killer1 = killers[ply][0], killer2 = killers[ply][1], hashMove; int bestNr, bestScore, startAlpha, startScore, resultDepth, iterDepth=0; - int hit, hashKeyH; + int hit, hashKeyH, ran=0; int curEval, score; // legality @@ -1092,10 +1094,11 @@ if(PATH)printf("%d:%d:%d new iter moveStack[%d..%d]\n",ply,depth,iterDepth,m.fir int lmr; search: lmr = (curMove >= m.late) + (curMove >= m.drops); + if(ply==0 && randomize && moveNr < 10) ran = (alpha > INF-100 || alpha <-INF+100 ? 0 : (f.newKey*ranKey>>24 & 31)- 16); repKey[index] = (int)f.newKey & 0x1FFFFF | f.newEval << 21; // remember position // recursion deprec[ply] = (f.checker != CK_NONE ? f.checker : 0)<<24 | maxDepth<<16 | depth<< 8 | iterDepth; path[ply++] = moveStack[curMove]; - score = -Search(stm, -beta, -alpha, &f, iterDepth-1, lmr, highDepth); + score = ran - Search(stm, -beta, -alpha+ran, &f, iterDepth-1, lmr, highDepth); ply--; repKey[index] = 0; @@ -1185,7 +1188,6 @@ if(PATH || f.hashKey == 0x1348708590)printf("%d:%d Hash store %16llx, d=%d, ch return bestScore; } -int moveNr; // part of game state; incremented by MakeMove int gameMove[MAXMOVES]; // holds the game history int stm = WHITE; @@ -1331,7 +1333,6 @@ printf("# move = %08x\n", m); // Some global variables that control your engine's behavior int ponder; -int randomize; int resign; // engine-defined option int contemptFactor; // likewise @@ -1385,7 +1386,7 @@ RootMakeMove(int move) index = (unsigned int)undoInfo.newKey >> 24 ^ stm << 2; // uses high byte of low (= hands-free) key while(repKey[index] && (repKey[index] ^ (int)undoInfo.newKey) & 0x1FFFFF) index += 2; // find empty slot repKey[index] = (int)undoInfo.newKey & 0x1FFFFF | undoInfo.newEval << 21; // remember position - stm ^= COLOR; + stm ^= COLOR; moveNr++; return 1; } @@ -1477,7 +1478,7 @@ printf("# command: %s\n", inBuf); if(!strcmp(command, "memory")) { if(SetMemorySize(atoi(inBuf+7))) printf("tellusererror Not enough memory\n"), exit(-1); return 1; } if(!strcmp(command, "ping")) { printf("pong%s", inBuf+4); return 1; } // if(!strcmp(command, "")) { sscanf(inBuf, " %d", &); return 1; } - if(!strcmp(command, "new")) { engineSide = BLACK; stm = WHITE; maxDepth = MAXPLY; randomize = OFF; return 1; } + if(!strcmp(command, "new")) { engineSide = BLACK; stm = WHITE; maxDepth = MAXPLY; randomize = OFF; moveNr = 0; ranKey = GetTickCount() | 0x1001; return 1; } if(!strcmp(command, "variant")) { GameInit(inBuf + 8); Setup(startPos); return 1; } if(!strcmp(command, "setboard")){ engineSide = NONE; stm = Setup(inBuf+9); return 1; } if(!strcmp(command, "undo")) { TakeBack(1); return 1; }