mirror of
https://github.com/sockspls/badfish
synced 2025-04-29 16:23:09 +00:00
Avoid double function dispatch
In 44% of cases we call search() just to call qsearch() one moment later, avoid this double dispatch. No functional change. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
parent
9b17083912
commit
c0136fb728
1 changed files with 15 additions and 10 deletions
|
@ -1056,9 +1056,6 @@ namespace {
|
||||||
refinedValue = bestValue = value = -VALUE_INFINITE;
|
refinedValue = bestValue = value = -VALUE_INFINITE;
|
||||||
oldAlpha = alpha;
|
oldAlpha = alpha;
|
||||||
|
|
||||||
if (depth < OnePly)
|
|
||||||
return qsearch<PvNode>(pos, ss, alpha, beta, Depth(0), threadID);
|
|
||||||
|
|
||||||
// Step 1. Initialize node and poll. Polling can abort search
|
// Step 1. Initialize node and poll. Polling can abort search
|
||||||
TM.incrementNodeCounter(threadID);
|
TM.incrementNodeCounter(threadID);
|
||||||
ss->init(ply);
|
ss->init(ply);
|
||||||
|
@ -1067,7 +1064,7 @@ namespace {
|
||||||
if (threadID == 0 && ++NodesSincePoll > NodesBetweenPolls)
|
if (threadID == 0 && ++NodesSincePoll > NodesBetweenPolls)
|
||||||
{
|
{
|
||||||
NodesSincePoll = 0;
|
NodesSincePoll = 0;
|
||||||
poll();
|
poll();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 2. Check for aborted search and immediate draw
|
// Step 2. Check for aborted search and immediate draw
|
||||||
|
@ -1179,8 +1176,8 @@ namespace {
|
||||||
|
|
||||||
pos.do_null_move(st);
|
pos.do_null_move(st);
|
||||||
|
|
||||||
nullValue = -search<NonPV>(pos, ss+1, -beta, -alpha, depth-R*OnePly, false, threadID);
|
nullValue = depth-R*OnePly < OnePly ? -qsearch<NonPV>(pos, ss+1, -beta, -alpha, Depth(0), threadID)
|
||||||
|
: - search<NonPV>(pos, ss+1, -beta, -alpha, depth-R*OnePly, false, threadID);
|
||||||
pos.undo_null_move();
|
pos.undo_null_move();
|
||||||
|
|
||||||
if (nullValue >= beta)
|
if (nullValue >= beta)
|
||||||
|
@ -1314,7 +1311,8 @@ namespace {
|
||||||
// Step extra. pv search (only in PV nodes)
|
// Step extra. pv search (only in PV nodes)
|
||||||
// The first move in list is the expected PV
|
// The first move in list is the expected PV
|
||||||
if (PvNode && moveCount == 1)
|
if (PvNode && moveCount == 1)
|
||||||
value = -search<PV>(pos, ss+1, -beta, -alpha, newDepth, false, threadID);
|
value = newDepth < OnePly ? -qsearch<PV>(pos, ss+1, -beta, -alpha, Depth(0), threadID)
|
||||||
|
: - search<PV>(pos, ss+1, -beta, -alpha, newDepth, false, threadID);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Step 14. Reduced depth search
|
// Step 14. Reduced depth search
|
||||||
|
@ -1330,7 +1328,10 @@ namespace {
|
||||||
ss->reduction = reduction<PvNode>(depth, moveCount);
|
ss->reduction = reduction<PvNode>(depth, moveCount);
|
||||||
if (ss->reduction)
|
if (ss->reduction)
|
||||||
{
|
{
|
||||||
value = -search<NonPV>(pos, ss+1, -(alpha+1), -alpha, newDepth-ss->reduction, true, threadID);
|
Depth r = newDepth - ss->reduction;
|
||||||
|
value = r < OnePly ? -qsearch<NonPV>(pos, ss+1, -(alpha+1), -alpha, Depth(0), threadID)
|
||||||
|
: - search<NonPV>(pos, ss+1, -(alpha+1), -alpha, r, true, threadID);
|
||||||
|
|
||||||
doFullDepthSearch = (value > alpha);
|
doFullDepthSearch = (value > alpha);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1339,6 +1340,8 @@ namespace {
|
||||||
// if the move fails high again then go with full depth search.
|
// if the move fails high again then go with full depth search.
|
||||||
if (doFullDepthSearch && ss->reduction > 2 * OnePly)
|
if (doFullDepthSearch && ss->reduction > 2 * OnePly)
|
||||||
{
|
{
|
||||||
|
assert(newDepth - OnePly >= OnePly);
|
||||||
|
|
||||||
ss->reduction = OnePly;
|
ss->reduction = OnePly;
|
||||||
value = -search<NonPV>(pos, ss+1, -(alpha+1), -alpha, newDepth-ss->reduction, true, threadID);
|
value = -search<NonPV>(pos, ss+1, -(alpha+1), -alpha, newDepth-ss->reduction, true, threadID);
|
||||||
doFullDepthSearch = (value > alpha);
|
doFullDepthSearch = (value > alpha);
|
||||||
|
@ -1349,13 +1352,15 @@ namespace {
|
||||||
if (doFullDepthSearch)
|
if (doFullDepthSearch)
|
||||||
{
|
{
|
||||||
ss->reduction = Depth(0);
|
ss->reduction = Depth(0);
|
||||||
value = -search<NonPV>(pos, ss+1, -(alpha+1), -alpha, newDepth, true, threadID);
|
value = newDepth < OnePly ? -qsearch<NonPV>(pos, ss+1, -(alpha+1), -alpha, Depth(0), threadID)
|
||||||
|
: - search<NonPV>(pos, ss+1, -(alpha+1), -alpha, newDepth, true, threadID);
|
||||||
|
|
||||||
// Step extra. pv search (only in PV nodes)
|
// Step extra. pv search (only in PV nodes)
|
||||||
// Search only for possible new PV nodes, if instead value >= beta then
|
// Search only for possible new PV nodes, if instead value >= beta then
|
||||||
// parent node fails low with value <= alpha and tries another move.
|
// parent node fails low with value <= alpha and tries another move.
|
||||||
if (PvNode && value > alpha && value < beta)
|
if (PvNode && value > alpha && value < beta)
|
||||||
value = -search<PV>(pos, ss+1, -beta, -alpha, newDepth, false, threadID);
|
value = newDepth < OnePly ? -qsearch<PV>(pos, ss+1, -beta, -alpha, Depth(0), threadID)
|
||||||
|
: - search<PV>(pos, ss+1, -beta, -alpha, newDepth, false, threadID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue