diff --git a/src/evaluate.c b/src/evaluate.c index e2360d1b..68bf1734 100644 --- a/src/evaluate.c +++ b/src/evaluate.c @@ -51,7 +51,7 @@ const int PieceValue[2][PIECE_NB] = { }; // Bonus for being the side to move -const int Tempo = 18; +extern int Tempo; // Misc bonuses and maluses const int PawnDoubled = S(-11,-48); @@ -136,11 +136,49 @@ const int Mobility[4][28] = { S(122,221), S(135,193), S(146,166), S(125,162) } }; -// KingSafety [pt-2] -const int AttackPower[4] = { 36, 22, 23, 78 }; -const int CheckPower[4] = { 68, 44, 88, 92 }; -const int CountModifier[8] = { 0, 0, 63, 126, 96, 124, 124, 128 }; +extern int BasePower; +extern int NPower; +extern int BPower; +extern int RPower; +extern int QPower; +extern int NCPower; +extern int BCPower; +extern int RCPower; +extern int QCPower; +extern int Modifier1; +extern int Modifier2; +extern int Modifier3; +extern int Modifier4; +extern int Modifier5; +extern int Modifier6; +extern int Modifier7; +extern int Modifier8; +// KingSafety [pt-2] +int AttackPower[4] = { 0 }; +int CheckPower[4] = { 0 }; +int CountModifier[8] = { 0 }; + +void InitSafety() { + AttackPower[KNIGHT-2] = NPower; + AttackPower[BISHOP-2] = BPower; + AttackPower[ROOK -2] = RPower; + AttackPower[QUEEN -2] = QPower; + + CheckPower[KNIGHT-2] = NCPower; + CheckPower[BISHOP-2] = BCPower; + CheckPower[ROOK -2] = RCPower; + CheckPower[QUEEN -2] = QCPower; + + CountModifier[0] = Modifier1; + CountModifier[1] = Modifier2; + CountModifier[2] = Modifier3; + CountModifier[3] = Modifier4; + CountModifier[4] = Modifier5; + CountModifier[5] = Modifier6; + CountModifier[6] = Modifier7; + CountModifier[7] = Modifier8; +} // Evaluates pawns INLINE int EvalPawns(const Position *pos, EvalInfo *ei, const Color color) { @@ -484,7 +522,7 @@ INLINE void InitEvalInfo(const Position *pos, EvalInfo *ei, const Color color) { // King Safety ei->kingZone[color] = AttackBB(KING, kingSq(color), 0); - ei->attackPower[color] = -30; + ei->attackPower[color] = BasePower; ei->attackCount[color] = 0; // Clear passed pawns, filled in during pawn eval @@ -510,6 +548,8 @@ static int ScaleFactor(const Position *pos, const int eval) { if (!(strongPawns & QueenSideBB) || !(strongPawns & KingSideBB)) pawnScale -= 20; + pawnScale = MIN(pawnScale, 128); + // Opposite-colored bishop if ( pos->nonPawnCount[WHITE] <= 2 && pos->nonPawnCount[BLACK] <= 2 diff --git a/src/evaluate.h b/src/evaluate.h index 9d49bb19..d05575e4 100644 --- a/src/evaluate.h +++ b/src/evaluate.h @@ -33,7 +33,7 @@ typedef struct PawnEntry { typedef PawnEntry PawnCache[PAWN_CACHE_SIZE]; -extern const int Tempo; +extern int Tempo; extern const int PieceValue[COLOR_NB][PIECE_NB]; @@ -60,3 +60,4 @@ INLINE int EvalPositionWhitePov(const Position *pos, PawnCache pc) { int score = EvalPosition(pos, pc); return sideToMove == WHITE ? score : -score; } +void InitSafety(); diff --git a/src/history.h b/src/history.h index 2173ab60..77d49aa7 100644 --- a/src/history.h +++ b/src/history.h @@ -36,15 +36,45 @@ #define ContCorrEntry(offset) (&(*(ss-offset)->contCorr)[piece((ss-1)->move)][toSq((ss-1)->move)]) #define NonPawnCorrEntry(color) (&thread->nonPawnCorrHistory[color][thread->pos.stm][NonPawnCorrIndex(&thread->pos, color)]) -#define QuietHistoryUpdate(move, bonus) (HistoryBonus(QuietEntry(move), bonus, 5280)) -#define PawnHistoryUpdate(move, bonus) (HistoryBonus(PawnEntry(move), bonus, 9275)) -#define NoisyHistoryUpdate(move, bonus) (HistoryBonus(NoisyEntry(move), bonus, 16000)) -#define ContHistoryUpdate(offset, move, bonus) (HistoryBonus(ContEntry(offset, move), bonus, 21250)) -#define PawnCorrHistoryUpdate(bonus) (HistoryBonus(PawnCorrEntry(), bonus, 1662)) -#define MinorCorrHistoryUpdate(bonus) (HistoryBonus(MinorCorrEntry(), bonus, 1024)) -#define MajorCorrHistoryUpdate(bonus) (HistoryBonus(MajorCorrEntry(), bonus, 1024)) -#define ContCorrHistoryUpdate(offset, bonus) (HistoryBonus(ContCorrEntry(offset), bonus, 1220)) -#define NonPawnCorrHistoryUpdate(bonus, color) (HistoryBonus(NonPawnCorrEntry(color), bonus, 1024)) +#define QuietHistoryUpdate(move, bonus) (HistoryBonus(QuietEntry(move), bonus, HistQDiv)) +#define PawnHistoryUpdate(move, bonus) (HistoryBonus(PawnEntry(move), bonus, HistPDiv)) +#define NoisyHistoryUpdate(move, bonus) (HistoryBonus(NoisyEntry(move), bonus, HistNDiv)) +#define ContHistoryUpdate(offset, move, bonus) (HistoryBonus(ContEntry(offset, move), bonus, HistCDiv)) +#define PawnCorrHistoryUpdate(bonus) (HistoryBonus(PawnCorrEntry(), bonus, HistPCDiv)) +#define MinorCorrHistoryUpdate(bonus) (HistoryBonus(MinorCorrEntry(), bonus, HistMiCDiv)) +#define MajorCorrHistoryUpdate(bonus) (HistoryBonus(MajorCorrEntry(), bonus, HistMaCDiv)) +#define ContCorrHistoryUpdate(offset, bonus) (HistoryBonus(ContCorrEntry(offset), bonus, HistCCDiv)) +#define NonPawnCorrHistoryUpdate(bonus, color) (HistoryBonus(NonPawnCorrEntry(color), bonus, HistNPCHDiv)) + + +extern int HistQDiv; +extern int HistPDiv; +extern int HistCDiv; +extern int HistNDiv; +extern int HistPCDiv; +extern int HistMiCDiv; +extern int HistMaCDiv; +extern int HistCCDiv; +extern int HistNPCHDiv; +extern int HistBonusMax; +extern int HistBonusBase; +extern int HistBonusDepth; +extern int HistMalusMax; +extern int HistMalusBase; +extern int HistMalusDepth; +extern int HistCBonusDepthDiv; +extern int HistCBonusMin; +extern int HistCBonusMax; +extern int HistGetPCDiv; +extern int HistGetMiCDiv; +extern int HistGetMaCDiv; +extern int HistGetCC2Div; +extern int HistGetCC3Div; +extern int HistGetCC4Div; +extern int HistGetCC5Div; +extern int HistGetCC6Div; +extern int HistGetCC7Div; +extern int HistGetNPCDiv; INLINE int PawnStructure(const Position *pos) { return pos->pawnKey & (PAWN_HISTORY_SIZE - 1); } @@ -61,15 +91,15 @@ INLINE void HistoryBonus(int16_t *entry, int bonus, int div) { } INLINE int Bonus(Depth depth) { - return MIN(2410, 268 * depth - 310); + return MIN(HistBonusMax, HistBonusDepth * depth - HistBonusBase); } INLINE int Malus(Depth depth) { - return -MIN(834, 531 * depth - 148); + return -MIN(HistMalusMax, HistMalusDepth * depth - HistMalusBase); } INLINE int CorrectionBonus(int score, int eval, Depth depth) { - return CLAMP((score - eval) * depth / 4, -212, 254); + return CLAMP((score - eval) * depth / HistCBonusDepthDiv, -HistCBonusMin, HistCBonusMax); } INLINE void UpdateContHistories(Stack *ss, Move move, int bonus) { @@ -153,16 +183,16 @@ INLINE int GetHistory(const Thread *thread, Stack *ss, Move move) { } INLINE int GetCorrectionHistory(const Thread *thread, const Stack *ss) { - int c = 6554 * *PawnCorrEntry() - + 6800 * *MinorCorrEntry() - + 3700 * *MajorCorrEntry() - + 7000 * (*NonPawnCorrEntry(WHITE) + *NonPawnCorrEntry(BLACK)) - + 3121 * *ContCorrEntry(2) - + 2979 * *ContCorrEntry(3) - + 2849 * *ContCorrEntry(4) - + 3121 * *ContCorrEntry(5) - + 2789 * *ContCorrEntry(6) - + 2979 * *ContCorrEntry(7); + int c = HistGetPCDiv * *PawnCorrEntry() + + HistGetMiCDiv * *MinorCorrEntry() + + HistGetMaCDiv * *MajorCorrEntry() + + HistGetNPCDiv * (*NonPawnCorrEntry(WHITE) + *NonPawnCorrEntry(BLACK)) + + HistGetCC2Div * *ContCorrEntry(2) + + HistGetCC3Div * *ContCorrEntry(3) + + HistGetCC4Div * *ContCorrEntry(4) + + HistGetCC5Div * *ContCorrEntry(5) + + HistGetCC6Div * *ContCorrEntry(6) + + HistGetCC7Div * *ContCorrEntry(7); return c / 131072; } diff --git a/src/movepicker.c b/src/movepicker.c index dc7a0dcb..6bca2ce0 100644 --- a/src/movepicker.c +++ b/src/movepicker.c @@ -22,6 +22,13 @@ #include "movepicker.h" +extern int ScoreMovesLimit; +extern int MPGood; +extern int MPGoodDepth; +extern int MPBad; +extern int MPBadDepth; + + // Return the next best move static Move PickNextMove(MovePicker *mp) { @@ -69,7 +76,7 @@ static void ScoreMoves(MovePicker *mp, const int stage) { : GetCaptureHistory(thread, move) + PieceValue[MG][capturing(move)]; } - SortMoves(list, -1000 * mp->depth); + SortMoves(list, -ScoreMovesLimit * mp->depth); } // Returns the next move to try in a position @@ -96,8 +103,8 @@ Move NextMove(MovePicker *mp) { case NOISY_GOOD: // Save seemingly bad noisy moves for later while ((move = PickNextMove(mp))) - if ( mp->list.moves[mp->list.next-1].score > 11300 - || (mp->list.moves[mp->list.next-1].score > -11100 && SEE(pos, move, mp->threshold))) + if ( mp->list.moves[mp->list.next-1].score > MPGood + || (mp->list.moves[mp->list.next-1].score > -MPBad && SEE(pos, move, mp->threshold))) return move; else mp->list.moves[mp->bads++].move = move; diff --git a/src/search.c b/src/search.c index 89bd461d..bffa74d4 100644 --- a/src/search.c +++ b/src/search.c @@ -44,12 +44,118 @@ atomic_bool Minimal = false; static int Reductions[2][32][32]; +float LMRNoisyBase = 0.48; +float LMRNoisyDiv = 3.43; +float LMRQuietBase = 1.92; +float LMRQuietDiv = 2.46; + +int CorrRule50 = 7; +int CorrBase = 256; + +int QSFutility = 132; + +int IIRDepth = 3; +int IIRCutDepth = 8; +int RFPDepth = 7; +int RFPBase = 76; +int RFPHistScore = 119; +int RFPHistory = 7600; +int NMPFlat = 158; +int NMPDepth = 19; +int NMPHist = 26300; +int NMPRBase = 4; +int NMPRDepth = 4; +int NMPREvalDiv = 224; +int NMPREvalMin = 3; +int ProbCut = 200; +int ProbCutDepth = 5; +int ProbCutReturn = 160; +int LMRPruneHist = 9050; +int LMPImp = 1; +int LMPNonImp = 0; +int HistPruneDepth = 3; +int HistPrune = 1024; +int SEEPruneDepth = 7; +int SEEPrune = 63; +int SingExtDepth = 4; +int SingExtTTDepth = 3; +int SingExtDouble = 1; +int LMRHist = 10135; +int DeeperBase = 1; +int DeeperDepth = 7; + +int Aspi = 9; +int AspiScoreDiv = 16384; +int Trend = 32; +float TrendDiv = 0.50; +int PruneDiv = 64; +int PruneDepthDiv = 270; +float NodeRatioBase = 55; +float NodeRatioMult = 301; + +int HistQDiv = 5280; +int HistPDiv = 9275; +int HistNDiv = 16000; +int HistCDiv = 21250; +int HistPCDiv = 1662; +int HistMiCDiv = 1024; +int HistMaCDiv = 1024; +int HistCCDiv = 1220; +int HistNPCHDiv = 1024; +int HistBonusMax = 2410; +int HistBonusBase = 310; +int HistBonusDepth = 268; +int HistMalusMax = 834; +int HistMalusBase = 148; +int HistMalusDepth = 531; +int HistCBonusDepthDiv = 4; +int HistCBonusMax = 254; +int HistCBonusMin = 212; +int HistGetPCDiv = 6554; +int HistGetMiCDiv = 6800; +int HistGetMaCDiv = 3700; +int HistGetCC2Div = 7000; +int HistGetCC3Div = 3121; +int HistGetCC4Div = 2979; +int HistGetCC5Div = 2849; +int HistGetCC6Div = 3121; +int HistGetCC7Div = 2789; +int HistGetNPCDiv = 2979; + +int Tempo = 18; +int BasePower = -30; +int NPower = 36; +int BPower = 22; +int RPower = 23; +int QPower = 78; +int NCPower = 68; +int BCPower = 44; +int RCPower = 88; +int QCPower = 92; +int Modifier1 = 0; +int Modifier2 = 0; +int Modifier3 = 63; +int Modifier4 = 126; +int Modifier5 = 96; +int Modifier6 = 124; +int Modifier7 = 124; +int Modifier8 = 128; + +int ScoreMovesLimit = 1000; +int MPGood = 11300; +int MPBad = 11100; + // Initializes the late move reduction array CONSTR(1) InitReductions() { for (int depth = 1; depth < 32; ++depth) for (int moves = 1; moves < 32; ++moves) - Reductions[0][depth][moves] = 0.48 + log(depth) * log(moves) / 3.43, // capture - Reductions[1][depth][moves] = 1.92 + log(depth) * log(moves) / 2.46; // quiet + Reductions[0][depth][moves] = LMRNoisyBase + log(depth) * log(moves) / LMRNoisyDiv, // capture + Reductions[1][depth][moves] = LMRQuietBase + log(depth) * log(moves) / LMRQuietDiv; // quiet +} + +void Reinit() { + InitReductions(); + InitSafety(); } // Checks whether a move was already searched in multi-pv mode @@ -63,8 +169,8 @@ static bool AlreadySearchedMultiPV(Thread *thread, Move move) { // Correct the evaluation based on historic differences between eval and final score static int CorrectEval(Thread *thread, Stack *ss, int eval, int rule50) { int correctedEval = eval + GetCorrectionHistory(thread, ss); - if (rule50 > 7) - correctedEval *= (256 - rule50) / 256.0; + if (rule50 > CorrRule50) + correctedEval *= (double)(CorrBase - rule50) / CorrBase; return CLAMP(correctedEval, -TBWIN_IN_MAX + 1, TBWIN_IN_MAX - 1); } @@ -163,7 +269,7 @@ static int Quiescence(Thread *thread, Stack *ss, int alpha, int beta) { if (eval > alpha) alpha = eval; - futility = eval + 132; + futility = eval + QSFutility; bestScore = eval; moveloop: @@ -354,10 +460,10 @@ static int AlphaBeta(Thread *thread, Stack *ss, int alpha, int beta, Depth depth bool improving = !inCheck && eval > (ss-2)->staticEval; // Internal iterative reduction based on Rebel's idea - if (pvNode && depth >= 3 && !ttMove) + if (pvNode && depth >= IIRDepth && !ttMove) depth--; - if (cutnode && depth >= 8 && !ttMove) + if (cutnode && depth >= IIRCutDepth && !ttMove) depth--; // Skip pruning in check, pv nodes, early iterations, when proving singularity, looking for terminal scores, or after a null move @@ -365,20 +471,20 @@ static int AlphaBeta(Thread *thread, Stack *ss, int alpha, int beta, Depth depth goto move_loop; // Reverse Futility Pruning - if ( depth < 7 + if ( depth < RFPDepth && eval >= beta - && eval - 76 * (depth - improving) - (ss-1)->histScore / 119 >= beta - && (!ttMove || GetHistory(thread, ss, ttMove) > 7600)) + && eval - RFPBase * (depth - improving) - (ss-1)->histScore / RFPHistScore >= beta + && (!ttMove || GetHistory(thread, ss, ttMove) > RFPHistory)) return eval; // Null Move Pruning if ( eval >= beta && eval >= ss->staticEval - && ss->staticEval >= beta + 158 - 19 * depth - && (ss-1)->histScore < 26300 + && ss->staticEval >= beta + NMPFlat - NMPDepth * depth + && (ss-1)->histScore < NMPHist && pos->nonPawnCount[sideToMove] > (depth > 8)) { - Depth reduction = 4 + depth / 4 + MIN(3, (eval - beta) / 224); + Depth reduction = NMPRBase + depth / NMPRDepth + MIN(NMPREvalMin, (eval - beta) / NMPREvalDiv); ss->move = NOMOVE; ss->continuation = &thread->continuation[0][0][EMPTY][0]; @@ -394,10 +500,10 @@ static int AlphaBeta(Thread *thread, Stack *ss, int alpha, int beta, Depth depth return isWin(score) ? beta : score; } - int probCutBeta = beta + 200; + int probCutBeta = beta + ProbCut; // ProbCut - if ( depth >= 5 + if ( depth >= ProbCutDepth && (!ttHit || ttBound == BOUND_LOWER || ttScore >= probCutBeta)) { InitProbcutMP(&mp, thread, ss, probCutBeta - ss->staticEval); @@ -425,7 +531,7 @@ static int AlphaBeta(Thread *thread, Stack *ss, int alpha, int beta, Depth depth // Cut if the reduced depth search beats the threshold, terminal scores are exact if (score >= probCutBeta) - return isWin(score) ? score : score - 160; + return isWin(score) ? score : MAX(beta, score - ProbCutReturn); } } @@ -463,19 +569,19 @@ static int AlphaBeta(Thread *thread, Stack *ss, int alpha, int beta, Depth depth && thread->doPruning && !isLoss(bestScore)) { - int R = Reductions[quiet][MIN(31, depth)][MIN(31, moveCount)] - ss->histScore / 9050; + int R = Reductions[quiet][MIN(31, depth)][MIN(31, moveCount)] - ss->histScore / LMRPruneHist; Depth lmrDepth = depth - 1 - R; // Quiet late move pruning - if (moveCount > (improving ? 1 + depth * depth : depth * depth / 2)) + if (moveCount > (improving ? LMPImp + depth * depth : LMPNonImp + depth * depth / 2)) mp.onlyNoisy = true; // History pruning - if (lmrDepth < 3 && ss->histScore < -1024 * depth) + if (lmrDepth < HistPruneDepth && ss->histScore < -HistPrune * depth) continue; // SEE pruning - if (lmrDepth < 7 && !SEE(pos, move, -63 * depth)) + if (lmrDepth < SEEPruneDepth && !SEE(pos, move, -SEEPrune * depth)) continue; } @@ -487,10 +593,10 @@ static int AlphaBeta(Thread *thread, Stack *ss, int alpha, int beta, Depth depth goto skip_extensions; // Singular extension - if ( depth > 4 + if ( depth > SingExtDepth && move == ttMove && !ss->excluded - && ttDepth > depth - 3 + && ttDepth > depth - SingExtTTDepth && ttBound != BOUND_UPPER && !isTerminal(ttScore)) { @@ -503,7 +609,7 @@ static int AlphaBeta(Thread *thread, Stack *ss, int alpha, int beta, Depth depth // Singular - extend by 1 or 2 ply if (score < singularBeta) { extension = 1; - if (!pvNode && score < singularBeta - 1 && ss->doubleExtensions <= 5) + if (!pvNode && score < singularBeta - SingExtDouble && ss->doubleExtensions <= 5) extension = 2; // MultiCut - ttMove as well as at least one other move seem good enough to beat beta } else if (singularBeta >= beta) @@ -536,7 +642,7 @@ static int AlphaBeta(Thread *thread, Stack *ss, int alpha, int beta, Depth depth // Base reduction int r = Reductions[quiet][MIN(31, depth)][MIN(31, moveCount)]; // Adjust reduction by move history - r -= ss->histScore / 10135; + r -= ss->histScore / LMRHist; // Reduce less in pv nodes r -= pvNode; // Reduce less when improving @@ -555,7 +661,7 @@ static int AlphaBeta(Thread *thread, Stack *ss, int alpha, int beta, Depth depth // Re-search with the same window at full depth if the reduced search failed high if (score > alpha && lmrDepth < newDepth) { - bool deeper = score > bestScore + 1 + 7 * (newDepth - lmrDepth); + bool deeper = score > bestScore + DeeperBase + DeeperDepth * (newDepth - lmrDepth); newDepth += deeper; @@ -661,12 +767,12 @@ static void AspirationWindow(Thread *thread, Stack *ss) { int prevScore = thread->rootMoves[multiPV].score; - int delta = 9 + prevScore * prevScore / 16384; + int delta = Aspi + prevScore * prevScore / AspiScoreDiv; int alpha = MAX(prevScore - delta, -INFINITE); int beta = MIN(prevScore + delta, INFINITE); - int x = CLAMP(prevScore / 2, -32, 32); + int x = CLAMP(prevScore * TrendDiv, -Trend, Trend); pos->trend = sideToMove == WHITE ? S(x, x/2) : -S(x, x/2); // Repeatedly search and adjust the window until the score is inside the window @@ -674,8 +780,8 @@ static void AspirationWindow(Thread *thread, Stack *ss) { thread->doPruning = Limits.infinite ? TimeSince(Limits.start) > 1000 - : TimeSince(Limits.start) >= Limits.optimalUsage / 64 - || depth > 2 + Limits.optimalUsage / 270 + : TimeSince(Limits.start) >= Limits.optimalUsage / PruneDiv + || depth > 2 + Limits.optimalUsage / PruneDepthDiv || Limits.nodeTime; int score = AlphaBeta(thread, ss, alpha, beta, depth, false); @@ -750,7 +856,7 @@ static void *IterativeDeepening(void *voidThread) { Limits.optimalUsage = MIN(500, Limits.optimalUsage); double nodeRatio = 1.0 - (double)thread->rootMoves[0].nodes / (MAX(1, pos->nodes)); - double timeRatio = 0.55 + 3.01 * nodeRatio; + double timeRatio = NodeRatioBase + NodeRatioMult * nodeRatio; // If an iteration finishes after optimal time usage, stop the search if ( Limits.timelimit diff --git a/src/search.h b/src/search.h index a0fd89b6..e6ce983f 100644 --- a/src/search.h +++ b/src/search.h @@ -41,3 +41,5 @@ extern atomic_bool Minimal; void *SearchPosition(void *pos); + +void Reinit(); diff --git a/src/tests.c b/src/tests.c index 601bf062..eee95be3 100644 --- a/src/tests.c +++ b/src/tests.c @@ -94,7 +94,7 @@ typedef struct BenchResult { } BenchResult; void Benchmark(int argc, char **argv) { - + Reinit(); // Default depth 16, 1 thread, and 32MB hash Limits.depth = argc > 2 ? atoi(argv[2]) : 16; int threadCount = argc > 3 ? atoi(argv[3]) : 1; diff --git a/src/uci.c b/src/uci.c index 8651d09e..fb881ac2 100644 --- a/src/uci.c +++ b/src/uci.c @@ -34,6 +34,107 @@ #include "uci.h" +extern float LMRNoisyBase; +extern float LMRNoisyDiv; +extern float LMRQuietBase; +extern float LMRQuietDiv; + +extern int CorrRule50; +extern int CorrBase; + +extern int IIRDepth; +extern int IIRCutDepth; +extern int RFPDepth; +extern int RFPBase; +extern int RFPHistScore; +extern int RFPHistory; +extern int NMPFlat; +extern int NMPDepth; +extern int NMPHist; +extern int NMPRBase; +extern int NMPRDepth; +extern int NMPREvalDiv; +extern int NMPREvalMin; +extern int ProbCut; +extern int ProbCutDepth; +extern int ProbCutReturn; +extern int LMPImp; +extern int LMPNonImp; +extern int LMRPruneHist; +extern int HistPruneDepth; +extern int HistPrune; +extern int SEEPruneDepth; +extern int SEEPrune; +extern int SingExtDepth; +extern int SingExtTTDepth; +extern int SingExtDouble; +extern int LMRHist; +extern int DeeperBase; +extern int DeeperDepth; + +extern int QSFutility; + +extern int Aspi; +extern int AspiScoreDiv; +extern int Trend; +extern float TrendDiv; +extern int PruneDiv; +extern int PruneDepthDiv; +extern float NodeRatioBase; +extern float NodeRatioMult; + +extern int HistQDiv; +extern int HistPDiv; +extern int HistCDiv; +extern int HistNDiv; +extern int HistPCDiv; +extern int HistMiCDiv; +extern int HistMaCDiv; +extern int HistCCDiv; +extern int HistNPCHDiv; +extern int HistBonusMax; +extern int HistBonusBase; +extern int HistBonusDepth; +extern int HistMalusMax; +extern int HistMalusBase; +extern int HistMalusDepth; +extern int HistCBonusDepthDiv; +extern int HistCBonusMin; +extern int HistCBonusMax; +extern int HistGetPCDiv; +extern int HistGetMiCDiv; +extern int HistGetMaCDiv; +extern int HistGetCC2Div; +extern int HistGetCC3Div; +extern int HistGetCC4Div; +extern int HistGetCC5Div; +extern int HistGetCC6Div; +extern int HistGetCC7Div; +extern int HistGetNPCDiv; + +extern int Tempo; +extern int BasePower; +extern int NPower; +extern int BPower; +extern int RPower; +extern int QPower; +extern int NCPower; +extern int BCPower; +extern int RCPower; +extern int QCPower; +extern int Modifier1; +extern int Modifier2; +extern int Modifier3; +extern int Modifier4; +extern int Modifier5; +extern int Modifier6; +extern int Modifier7; +extern int Modifier8; + +extern int ScoreMovesLimit; +extern int MPGood; +extern int MPBad; + // Parses the time controls static void ParseTimeControl(const char *str, const Position *pos) { @@ -121,6 +222,108 @@ static void SetOption(char *str) { else if (OptionNameIs("NoobBook" )) NoobBook = BooleanValue; else if (OptionNameIs("UCI_Chess960" )) Chess960 = BooleanValue; else if (OptionNameIs("OnlineSyzygy" )) OnlineSyzygy = BooleanValue; + + else if (OptionNameIs("LMRNoisyBase" )) LMRNoisyBase = IntValue / 100.0; + else if (OptionNameIs("LMRNoisyDiv" )) LMRNoisyDiv = IntValue / 100.0; + else if (OptionNameIs("LMRQuietBase" )) LMRQuietBase = IntValue / 100.0; + else if (OptionNameIs("LMRQuietDiv" )) LMRQuietDiv = IntValue / 100.0; + + else if (OptionNameIs("CorrRule50" )) CorrRule50 = IntValue; + else if (OptionNameIs("CorrBase" )) CorrBase = IntValue; + + else if (OptionNameIs("IIRDepth" )) IIRDepth = IntValue; + else if (OptionNameIs("IIRCutDepth" )) IIRCutDepth= IntValue; + else if (OptionNameIs("RFPDepth" )) RFPDepth = IntValue; + else if (OptionNameIs("RFPBase" )) RFPBase = IntValue; + else if (OptionNameIs("RFPHistScore" )) RFPHistScore = IntValue; + else if (OptionNameIs("RFPHistory" )) RFPHistory = IntValue; + else if (OptionNameIs("NMPFlat" )) NMPFlat = IntValue; + else if (OptionNameIs("NMPDepth" )) NMPDepth = IntValue; + else if (OptionNameIs("NMPHist" )) NMPHist = IntValue; + else if (OptionNameIs("NMPRBase" )) NMPRBase = IntValue; + else if (OptionNameIs("NMPRDepth" )) NMPRDepth = IntValue; + else if (OptionNameIs("NMPREvalDiv" )) NMPREvalDiv= IntValue; + else if (OptionNameIs("NMPREvalMin" )) NMPREvalMin= IntValue; + else if (OptionNameIs("ProbCut" )) ProbCut = IntValue; + else if (OptionNameIs("ProbCutDepth" )) ProbCutDepth = IntValue; + else if (OptionNameIs("ProbCutReturn" )) ProbCutReturn = IntValue; + else if (OptionNameIs("LMPImp" )) LMPImp = IntValue; + else if (OptionNameIs("LMPNonImp" )) LMPNonImp = IntValue; + else if (OptionNameIs("LMRPruneHist" )) LMRPruneHist = IntValue; + else if (OptionNameIs("HistPruneDepth")) HistPruneDepth = IntValue; + else if (OptionNameIs("HistPrune" )) HistPrune = IntValue; + else if (OptionNameIs("SEEPruneDepth")) SEEPruneDepth = IntValue; + else if (OptionNameIs("SEEPrune" )) SEEPrune = IntValue; + else if (OptionNameIs("SingExtDepth" )) SingExtDepth = IntValue; + else if (OptionNameIs("SingExtTTDepth")) SingExtTTDepth = IntValue; + else if (OptionNameIs("SingExtDouble")) SingExtDouble = IntValue; + else if (OptionNameIs("LMRHist" )) LMRHist = IntValue; + else if (OptionNameIs("DeeperBase" )) DeeperBase = IntValue; + else if (OptionNameIs("DeeperDepth" )) DeeperDepth= IntValue; + + else if (OptionNameIs("QSFutility" )) QSFutility = IntValue; + + else if (OptionNameIs("Aspi" )) Aspi = IntValue; + else if (OptionNameIs("AspiScoreDiv" )) AspiScoreDiv = IntValue; + else if (OptionNameIs("Trend" )) Trend = IntValue; + else if (OptionNameIs("TrendDiv" )) TrendDiv = IntValue / 100.0; + else if (OptionNameIs("PruneDiv" )) PruneDiv = IntValue; + else if (OptionNameIs("PruneDepthDiv")) PruneDepthDiv = IntValue; + else if (OptionNameIs("NodeRatioBase")) NodeRatioBase = IntValue / 100.0; + else if (OptionNameIs("NodeRatioMult")) NodeRatioMult = IntValue / 100.0; + + else if (OptionNameIs("HistQDiv" )) HistQDiv = IntValue; + else if (OptionNameIs("HistPDiv" )) HistPDiv = IntValue; + else if (OptionNameIs("HistCDiv" )) HistCDiv = IntValue; + else if (OptionNameIs("HistNDiv" )) HistNDiv = IntValue; + else if (OptionNameIs("HistPCDiv" )) HistPCDiv = IntValue; + else if (OptionNameIs("HistMiCDiv" )) HistMiCDiv = IntValue; + else if (OptionNameIs("HistMaCDiv" )) HistMaCDiv = IntValue; + else if (OptionNameIs("HistCCDiv" )) HistCCDiv = IntValue; + else if (OptionNameIs("HistNPCHDiv" )) HistNPCHDiv= IntValue; + else if (OptionNameIs("HistBonusMax" )) HistBonusMax = IntValue; + else if (OptionNameIs("HistBonusBase")) HistBonusBase = IntValue; + else if (OptionNameIs("HistBonusDepth")) HistBonusDepth = IntValue; + else if (OptionNameIs("HistMalusMax" )) HistMalusMax = IntValue; + else if (OptionNameIs("HistMalusBase")) HistMalusBase = IntValue; + else if (OptionNameIs("HistMalusDepth")) HistMalusDepth = IntValue; + else if (OptionNameIs("HistCBonusDepthDiv")) HistCBonusDepthDiv = IntValue; + else if (OptionNameIs("HistCBonusMin")) HistCBonusMin = IntValue; + else if (OptionNameIs("HistCBonusMax")) HistCBonusMax = IntValue; + else if (OptionNameIs("HistGetPCDiv" )) HistGetPCDiv = IntValue; + else if (OptionNameIs("HistGetMiCDiv")) HistGetMiCDiv = IntValue; + else if (OptionNameIs("HistGetMaCDiv")) HistGetMaCDiv = IntValue; + else if (OptionNameIs("HistGetCC2Div")) HistGetCC2Div = IntValue; + else if (OptionNameIs("HistGetCC3Div")) HistGetCC3Div = IntValue; + else if (OptionNameIs("HistGetCC4Div")) HistGetCC4Div = IntValue; + else if (OptionNameIs("HistGetCC5Div")) HistGetCC5Div = IntValue; + else if (OptionNameIs("HistGetCC6Div")) HistGetCC6Div = IntValue; + else if (OptionNameIs("HistGetCC7Div")) HistGetCC7Div = IntValue; + else if (OptionNameIs("HistGetNPCDiv")) HistGetNPCDiv = IntValue; + + else if (OptionNameIs("Tempo" )) Tempo = IntValue; + else if (OptionNameIs("BasePower" )) BasePower = IntValue; + else if (OptionNameIs("NPower" )) NPower = IntValue; + else if (OptionNameIs("BPower" )) BPower = IntValue; + else if (OptionNameIs("RPower" )) RPower = IntValue; + else if (OptionNameIs("QPower" )) QPower = IntValue; + else if (OptionNameIs("NCPower" )) NCPower = IntValue; + else if (OptionNameIs("BCPower" )) BCPower = IntValue; + else if (OptionNameIs("RCPower" )) RCPower = IntValue; + else if (OptionNameIs("QCPower" )) QCPower = IntValue; + else if (OptionNameIs("Modifier1" )) Modifier1 = IntValue; + else if (OptionNameIs("Modifier2" )) Modifier2 = IntValue; + else if (OptionNameIs("Modifier3" )) Modifier3 = IntValue; + else if (OptionNameIs("Modifier4" )) Modifier4 = IntValue; + else if (OptionNameIs("Modifier5" )) Modifier5 = IntValue; + else if (OptionNameIs("Modifier6" )) Modifier6 = IntValue; + else if (OptionNameIs("Modifier7" )) Modifier7 = IntValue; + else if (OptionNameIs("Modifier8" )) Modifier8 = IntValue; + + else if (OptionNameIs("ScoreMovesLimit")) ScoreMovesLimit = IntValue; + else if (OptionNameIs("MPGood" )) MPGood = IntValue; + else if (OptionNameIs("MPBad" )) MPBad = IntValue; + else puts("info string No such option."); fflush(stdout); @@ -140,6 +343,108 @@ static void Info() { printf("option name NoobBookMode type string default \n"); printf("option name NoobBookLimit type spin default 0 min 0 max 1000\n"); printf("option name OnlineSyzygy type check default false\n"); + + printf("option name LMRNoisyBase type spin default %d min %d max %d\n", (int)(LMRNoisyBase * 100), -100000, 100000); + printf("option name LMRNoisyDiv type spin default %d min %d max %d\n", (int)(LMRNoisyDiv * 100), -100000, 100000); + printf("option name LMRQuietBase type spin default %d min %d max %d\n", (int)(LMRQuietBase * 100), -100000, 100000); + printf("option name LMRQuietDiv type spin default %d min %d max %d\n", (int)(LMRQuietDiv * 100), -100000, 100000); + + printf("option name CorrRule50 type spin default %d min %d max %d\n", CorrRule50, -100000, 100000); + printf("option name CorrBase type spin default %d min %d max %d\n", CorrBase, -100000, 100000); + + printf("option name IIRDepth type spin default %d min %d max %d\n", IIRDepth, -100000, 100000); + printf("option name IIRCutDepth type spin default %d min %d max %d\n", IIRCutDepth, -100000, 100000); + printf("option name RFPDepth type spin default %d min %d max %d\n", RFPDepth, -100000, 100000); + printf("option name RFPBase type spin default %d min %d max %d\n", RFPBase, -100000, 100000); + printf("option name RFPHistScore type spin default %d min %d max %d\n", RFPHistScore, -100000, 100000); + printf("option name RFPHistory type spin default %d min %d max %d\n", RFPHistory, -100000, 100000); + printf("option name NMPFlat type spin default %d min %d max %d\n", NMPFlat, -100000, 100000); + printf("option name NMPDepth type spin default %d min %d max %d\n", NMPDepth, -100000, 100000); + printf("option name NMPHist type spin default %d min %d max %d\n", NMPHist, -100000, 100000); + printf("option name NMPRBase type spin default %d min %d max %d\n", NMPRBase, -100000, 100000); + printf("option name NMPRDepth type spin default %d min %d max %d\n", NMPRDepth, -100000, 100000); + printf("option name NMPREvalDiv type spin default %d min %d max %d\n", NMPREvalDiv, -100000, 100000); + printf("option name NMPREvalMin type spin default %d min %d max %d\n", NMPREvalMin, -100000, 100000); + printf("option name ProbCut type spin default %d min %d max %d\n", ProbCut, -100000, 100000); + printf("option name ProbCutDepth type spin default %d min %d max %d\n", ProbCutDepth, -100000, 100000); + printf("option name ProbCutReturn type spin default %d min %d max %d\n", ProbCutReturn, -100000, 100000); + printf("option name LMPImp type spin default %d min %d max %d\n", LMPImp, -100000, 100000); + printf("option name LMPNonImp type spin default %d min %d max %d\n", LMPNonImp, -100000, 100000); + printf("option name LMRPruneHist type spin default %d min %d max %d\n", LMRPruneHist, -100000, 100000); + printf("option name HistPruneDepth type spin default %d min %d max %d\n", HistPruneDepth, -100000, 100000); + printf("option name HistPrune type spin default %d min %d max %d\n", HistPrune, -100000, 100000); + printf("option name SEEPruneDepth type spin default %d min %d max %d\n", SEEPruneDepth, -100000, 100000); + printf("option name SEEPrune type spin default %d min %d max %d\n", SEEPrune, -100000, 100000); + printf("option name SingExtDepth type spin default %d min %d max %d\n", SingExtDepth, -100000, 100000); + printf("option name SingExtTTDepth type spin default %d min %d max %d\n", SingExtTTDepth, -100000, 100000); + printf("option name SingExtDouble type spin default %d min %d max %d\n", SingExtDouble, -100000, 100000); + printf("option name LMRHist type spin default %d min %d max %d\n", LMRHist, -100000, 100000); + printf("option name DeeperBase type spin default %d min %d max %d\n", DeeperBase, -100000, 100000); + printf("option name DeeperDepth type spin default %d min %d max %d\n", DeeperDepth, -100000, 100000); + + printf("option name QSFutility type spin default %d min %d max %d\n", QSFutility, -100000, 100000); + + printf("option name Aspi type spin default %d min %d max %d\n", Aspi, -100000, 100000); + printf("option name AspiScoreDiv type spin default %d min %d max %d\n", AspiScoreDiv, -100000, 100000); + printf("option name Trend type spin default %d min %d max %d\n", Trend, -100000, 100000); + printf("option name TrendDiv type spin default %d min %d max %d\n", (int)(TrendDiv * 100), -100000, 100000); + printf("option name PruneDiv type spin default %d min %d max %d\n", PruneDiv, -100000, 100000); + printf("option name PruneDepthDiv type spin default %d min %d max %d\n", PruneDepthDiv, -100000, 100000); + printf("option name NodeRatioBase type spin default %d min %d max %d\n", (int)(NodeRatioBase * 100), -100000, 100000); + printf("option name NodeRatioMult type spin default %d min %d max %d\n", (int)(NodeRatioMult * 100), -100000, 100000); + + printf("option name HistQDiv type spin default %d min %d max %d\n", HistQDiv, -100000, 100000); + printf("option name HistPDiv type spin default %d min %d max %d\n", HistPDiv, -100000, 100000); + printf("option name HistCDiv type spin default %d min %d max %d\n", HistCDiv, -100000, 100000); + printf("option name HistNDiv type spin default %d min %d max %d\n", HistNDiv, -100000, 100000); + printf("option name HistPCDiv type spin default %d min %d max %d\n", HistPCDiv, -100000, 100000); + printf("option name HistMiCDiv type spin default %d min %d max %d\n", HistMiCDiv, -100000, 100000); + printf("option name HistMaCDiv type spin default %d min %d max %d\n", HistMaCDiv, -100000, 100000); + printf("option name HistCCDiv type spin default %d min %d max %d\n", HistCCDiv, -100000, 100000); + printf("option name HistNPCHDiv type spin default %d min %d max %d\n", HistNPCHDiv, -100000, 100000); + printf("option name HistBonusMax type spin default %d min %d max %d\n", HistBonusMax, -100000, 100000); + printf("option name HistBonusBase type spin default %d min %d max %d\n", HistBonusBase, -100000, 100000); + printf("option name HistBonusDepth type spin default %d min %d max %d\n", HistBonusDepth, -100000, 100000); + printf("option name HistMalusMax type spin default %d min %d max %d\n", HistMalusMax, -100000, 100000); + printf("option name HistMalusBase type spin default %d min %d max %d\n", HistMalusBase, -100000, 100000); + printf("option name HistMalusDepth type spin default %d min %d max %d\n", HistMalusDepth, -100000, 100000); + printf("option name HistCBonusDepthDiv type spin default %d min %d max %d\n", HistCBonusDepthDiv, -100000, 100000); + printf("option name HistCBonusMin type spin default %d min %d max %d\n", HistCBonusMin, -100000, 100000); + printf("option name HistCBonusMax type spin default %d min %d max %d\n", HistCBonusMax, -100000, 100000); + printf("option name HistGetPCDiv type spin default %d min %d max %d\n", HistGetPCDiv, -100000, 100000); + printf("option name HistGetMiCDiv type spin default %d min %d max %d\n", HistGetMiCDiv, -100000, 100000); + printf("option name HistGetMaCDiv type spin default %d min %d max %d\n", HistGetMiCDiv, -100000, 100000); + printf("option name HistGetCC2Div type spin default %d min %d max %d\n", HistGetCC2Div, -100000, 100000); + printf("option name HistGetCC3Div type spin default %d min %d max %d\n", HistGetCC3Div, -100000, 100000); + printf("option name HistGetCC4Div type spin default %d min %d max %d\n", HistGetCC4Div, -100000, 100000); + printf("option name HistGetCC5Div type spin default %d min %d max %d\n", HistGetCC5Div, -100000, 100000); + printf("option name HistGetCC6Div type spin default %d min %d max %d\n", HistGetCC6Div, -100000, 100000); + printf("option name HistGetCC7Div type spin default %d min %d max %d\n", HistGetCC7Div, -100000, 100000); + printf("option name HistGetNPCDiv type spin default %d min %d max %d\n", HistGetNPCDiv, -100000, 100000); + + printf("option name Tempo type spin default %d min %d max %d\n", Tempo, -100000, 100000); + printf("option name BasePower type spin default %d min %d max %d\n", BasePower, -100000, 100000); + printf("option name NPower type spin default %d min %d max %d\n", NPower, -100000, 100000); + printf("option name BPower type spin default %d min %d max %d\n", BPower, -100000, 100000); + printf("option name RPower type spin default %d min %d max %d\n", RPower, -100000, 100000); + printf("option name QPower type spin default %d min %d max %d\n", QPower, -100000, 100000); + printf("option name NCPower type spin default %d min %d max %d\n", NCPower, -100000, 100000); + printf("option name BCPower type spin default %d min %d max %d\n", BCPower, -100000, 100000); + printf("option name RCPower type spin default %d min %d max %d\n", RCPower, -100000, 100000); + printf("option name QCPower type spin default %d min %d max %d\n", QCPower, -100000, 100000); + printf("option name Modifier1 type spin default %d min %d max %d\n", Modifier1, -100000, 100000); + printf("option name Modifier2 type spin default %d min %d max %d\n", Modifier2, -100000, 100000); + printf("option name Modifier3 type spin default %d min %d max %d\n", Modifier3, -100000, 100000); + printf("option name Modifier4 type spin default %d min %d max %d\n", Modifier4, -100000, 100000); + printf("option name Modifier5 type spin default %d min %d max %d\n", Modifier5, -100000, 100000); + printf("option name Modifier6 type spin default %d min %d max %d\n", Modifier6, -100000, 100000); + printf("option name Modifier7 type spin default %d min %d max %d\n", Modifier7, -100000, 100000); + printf("option name Modifier8 type spin default %d min %d max %d\n", Modifier8, -100000, 100000); + + printf("option name ScoreMovesLimit type spin default %d min %d max %d\n", ScoreMovesLimit, -100000, 100000); + printf("option name MPGood type spin default %d min %d max %d\n", MPGood, -100000, 100000); + printf("option name MPBad type spin default %d min %d max %d\n", MPBad, -100000, 100000); + printf("uciok\n"); fflush(stdout); } @@ -152,6 +457,7 @@ static void Stop() { // Signals the engine is ready static void IsReady() { + Reinit(); InitTT(); puts("readyok"); fflush(stdout);