1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-04-30 00:33:09 +00:00

Standardize root_search() signature

Now pass alpha and beta by copy as in serach()

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
Marco Costalba 2010-12-30 10:38:02 +01:00
parent b01e5fc612
commit afe0203f98

View file

@ -275,7 +275,7 @@ namespace {
/// Local functions /// Local functions
Value id_loop(Position& pos, Move searchMoves[]); Value id_loop(Position& pos, Move searchMoves[]);
Value root_search(Position& pos, SearchStack* ss, Value* alphaPtr, Value* betaPtr, Depth depth, RootMoveList& rml); Value root_search(Position& pos, SearchStack* ss, Value alpha, Value beta, Depth depth, RootMoveList& rml);
template <NodeType PvNode, bool SpNode> template <NodeType PvNode, bool SpNode>
Value search(Position& pos, SearchStack* ss, Value alpha, Value beta, Depth depth, int ply); Value search(Position& pos, SearchStack* ss, Value alpha, Value beta, Depth depth, int ply);
@ -574,11 +574,10 @@ namespace {
beta = Min(ValueByIteration[Iteration - 1] + AspirationDelta, VALUE_INFINITE); beta = Min(ValueByIteration[Iteration - 1] + AspirationDelta, VALUE_INFINITE);
} }
// Search to the current depth, rml is updated and sorted,
// alpha and beta could change.
depth = (Iteration - 2) * ONE_PLY + InitialDepth; depth = (Iteration - 2) * ONE_PLY + InitialDepth;
value = root_search(pos, ss, &alpha, &beta, depth, rml); // Search to the current depth, rml is updated and sorted
value = root_search(pos, ss, alpha, beta, depth, rml);
if (AbortSearch) if (AbortSearch)
break; // Value cannot be trusted. Break out immediately! break; // Value cannot be trusted. Break out immediately!
@ -680,24 +679,22 @@ namespace {
// root_search() is the function which searches the root node. It is // root_search() is the function which searches the root node. It is
// similar to search_pv except that it uses a different move ordering // similar to search_pv except that it prints some information to the
// scheme, prints some information to the standard output and handles // standard output and handles the fail low/high loops.
// the fail low/high loops.
Value root_search(Position& pos, SearchStack* ss, Value* alphaPtr, Value root_search(Position& pos, SearchStack* ss, Value alpha,
Value* betaPtr, Depth depth, RootMoveList& rml) { Value beta, Depth depth, RootMoveList& rml) {
StateInfo st; StateInfo st;
CheckInfo ci(pos); CheckInfo ci(pos);
int64_t nodes; int64_t nodes;
Move move; Move move;
Depth ext, newDepth; Depth ext, newDepth;
Value value, alpha, beta; Value value, oldAlpha;
bool isCheck, moveIsCheck, captureOrPromotion, dangerous; bool isCheck, moveIsCheck, captureOrPromotion, dangerous;
int researchCountFH, researchCountFL; int researchCountFH, researchCountFL;
researchCountFH = researchCountFL = 0; researchCountFH = researchCountFL = 0;
alpha = *alphaPtr; oldAlpha = alpha;
beta = *betaPtr;
isCheck = pos.is_check(); isCheck = pos.is_check();
// Step 1. Initialize node (polling is omitted at root) // Step 1. Initialize node (polling is omitted at root)
@ -827,7 +824,7 @@ namespace {
print_pv_info(pos, rml[i].pv, alpha, beta, value); print_pv_info(pos, rml[i].pv, alpha, beta, value);
// Prepare for a research after a fail high, each time with a wider window // Prepare for a research after a fail high, each time with a wider window
*betaPtr = beta = Min(beta + AspirationDelta * (1 << researchCountFH), VALUE_INFINITE); beta = Min(beta + AspirationDelta * (1 << researchCountFH), VALUE_INFINITE);
researchCountFH++; researchCountFH++;
} // End of fail high loop } // End of fail high loop
@ -895,9 +892,9 @@ namespace {
} }
} // PV move or new best move } // PV move or new best move
assert(alpha >= *alphaPtr); assert(alpha >= oldAlpha);
AspirationFailLow = (alpha == *alphaPtr); AspirationFailLow = (alpha == oldAlpha);
if (AspirationFailLow && StopOnPonderhit) if (AspirationFailLow && StopOnPonderhit)
StopOnPonderhit = false; StopOnPonderhit = false;
@ -908,7 +905,7 @@ namespace {
break; break;
// Prepare for a research after a fail low, each time with a wider window // Prepare for a research after a fail low, each time with a wider window
*alphaPtr = alpha = Max(alpha - AspirationDelta * (1 << researchCountFL), -VALUE_INFINITE); oldAlpha = alpha = Max(alpha - AspirationDelta * (1 << researchCountFL), -VALUE_INFINITE);
researchCountFL++; researchCountFL++;
} // Fail low loop } // Fail low loop