mirror of
https://github.com/sockspls/badfish
synced 2025-04-30 08:43:09 +00:00
Simplify color usage in search.
define Color us and use this instead of pos.side_to_move() and nmp_odd. The latter allows to clarify the nmp verification criterion. Tested for no regression: LLR: 2.95 (-2.94,2.94) [-3.00,1.00] Total: 76713 W: 15303 L: 15284 D: 46126 http://tests.stockfishchess.org/tests/view/5b046a0d0ebc5914abc12971 No functional change.
This commit is contained in:
parent
04407e35d6
commit
d702203113
3 changed files with 13 additions and 11 deletions
|
@ -547,6 +547,7 @@ namespace {
|
||||||
// Step 1. Initialize node
|
// Step 1. Initialize node
|
||||||
Thread* thisThread = pos.this_thread();
|
Thread* thisThread = pos.this_thread();
|
||||||
inCheck = pos.checkers();
|
inCheck = pos.checkers();
|
||||||
|
Color us = pos.side_to_move();
|
||||||
moveCount = captureCount = quietCount = ss->moveCount = 0;
|
moveCount = captureCount = quietCount = ss->moveCount = 0;
|
||||||
bestValue = -VALUE_INFINITE;
|
bestValue = -VALUE_INFINITE;
|
||||||
maxValue = VALUE_INFINITE;
|
maxValue = VALUE_INFINITE;
|
||||||
|
@ -639,7 +640,7 @@ namespace {
|
||||||
else if (!pos.capture_or_promotion(ttMove))
|
else if (!pos.capture_or_promotion(ttMove))
|
||||||
{
|
{
|
||||||
int penalty = -stat_bonus(depth);
|
int penalty = -stat_bonus(depth);
|
||||||
thisThread->mainHistory[pos.side_to_move()][from_to(ttMove)] << penalty;
|
thisThread->mainHistory[us][from_to(ttMove)] << penalty;
|
||||||
update_continuation_histories(ss, pos.moved_piece(ttMove), to_sq(ttMove), penalty);
|
update_continuation_histories(ss, pos.moved_piece(ttMove), to_sq(ttMove), penalty);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -749,8 +750,8 @@ namespace {
|
||||||
&& eval >= beta
|
&& eval >= beta
|
||||||
&& ss->staticEval >= beta - 36 * depth / ONE_PLY + 225
|
&& ss->staticEval >= beta - 36 * depth / ONE_PLY + 225
|
||||||
&& !excludedMove
|
&& !excludedMove
|
||||||
&& pos.non_pawn_material(pos.side_to_move())
|
&& pos.non_pawn_material(us)
|
||||||
&& (ss->ply >= thisThread->nmp_ply || ss->ply % 2 != thisThread->nmp_odd))
|
&& (ss->ply > thisThread->nmp_min_ply || us != thisThread->nmp_color))
|
||||||
{
|
{
|
||||||
assert(eval - beta >= 0);
|
assert(eval - beta >= 0);
|
||||||
|
|
||||||
|
@ -772,17 +773,17 @@ namespace {
|
||||||
if (nullValue >= VALUE_MATE_IN_MAX_PLY)
|
if (nullValue >= VALUE_MATE_IN_MAX_PLY)
|
||||||
nullValue = beta;
|
nullValue = beta;
|
||||||
|
|
||||||
if (abs(beta) < VALUE_KNOWN_WIN && (depth < 12 * ONE_PLY || thisThread->nmp_ply))
|
if (abs(beta) < VALUE_KNOWN_WIN && (depth < 12 * ONE_PLY || thisThread->nmp_min_ply))
|
||||||
return nullValue;
|
return nullValue;
|
||||||
|
|
||||||
// Do verification search at high depths. Disable null move pruning
|
// Do verification search at high depths. Disable null move pruning
|
||||||
// for side to move for the first part of the remaining search tree.
|
// for side to move for the first part of the remaining search tree.
|
||||||
thisThread->nmp_ply = ss->ply + 3 * (depth-R) / 4;
|
thisThread->nmp_min_ply = ss->ply + 3 * (depth-R) / 4 - 1;
|
||||||
thisThread->nmp_odd = ss->ply % 2;
|
thisThread->nmp_color = us;
|
||||||
|
|
||||||
Value v = search<NonPV>(pos, ss, beta-1, beta, depth-R, false);
|
Value v = search<NonPV>(pos, ss, beta-1, beta, depth-R, false);
|
||||||
|
|
||||||
thisThread->nmp_odd = thisThread->nmp_ply = 0;
|
thisThread->nmp_min_ply = 0;
|
||||||
|
|
||||||
if (v >= beta)
|
if (v >= beta)
|
||||||
return nullValue;
|
return nullValue;
|
||||||
|
@ -923,7 +924,7 @@ moves_loop: // When in check, search starts from here
|
||||||
|
|
||||||
// Step 14. Pruning at shallow depth (~170 Elo)
|
// Step 14. Pruning at shallow depth (~170 Elo)
|
||||||
if ( !rootNode
|
if ( !rootNode
|
||||||
&& pos.non_pawn_material(pos.side_to_move())
|
&& pos.non_pawn_material(us)
|
||||||
&& bestValue > VALUE_MATED_IN_MAX_PLY)
|
&& bestValue > VALUE_MATED_IN_MAX_PLY)
|
||||||
{
|
{
|
||||||
if ( !captureOrPromotion
|
if ( !captureOrPromotion
|
||||||
|
@ -1018,7 +1019,7 @@ moves_loop: // When in check, search starts from here
|
||||||
&& !pos.see_ge(make_move(to_sq(move), from_sq(move))))
|
&& !pos.see_ge(make_move(to_sq(move), from_sq(move))))
|
||||||
r -= 2 * ONE_PLY;
|
r -= 2 * ONE_PLY;
|
||||||
|
|
||||||
ss->statScore = thisThread->mainHistory[~pos.side_to_move()][from_to(move)]
|
ss->statScore = thisThread->mainHistory[us][from_to(move)]
|
||||||
+ (*contHist[0])[movedPiece][to_sq(move)]
|
+ (*contHist[0])[movedPiece][to_sq(move)]
|
||||||
+ (*contHist[1])[movedPiece][to_sq(move)]
|
+ (*contHist[1])[movedPiece][to_sq(move)]
|
||||||
+ (*contHist[3])[movedPiece][to_sq(move)]
|
+ (*contHist[3])[movedPiece][to_sq(move)]
|
||||||
|
|
|
@ -187,7 +187,7 @@ void ThreadPool::start_thinking(Position& pos, StateListPtr& states,
|
||||||
|
|
||||||
for (Thread* th : *this)
|
for (Thread* th : *this)
|
||||||
{
|
{
|
||||||
th->nodes = th->tbHits = th->nmp_ply = th->nmp_odd = 0;
|
th->nodes = th->tbHits = th->nmp_min_ply = 0;
|
||||||
th->rootDepth = th->completedDepth = DEPTH_ZERO;
|
th->rootDepth = th->completedDepth = DEPTH_ZERO;
|
||||||
th->rootMoves = rootMoves;
|
th->rootMoves = rootMoves;
|
||||||
th->rootPos.set(pos.fen(), pos.is_chess960(), &setupStates->back(), th);
|
th->rootPos.set(pos.fen(), pos.is_chess960(), &setupStates->back(), th);
|
||||||
|
|
|
@ -61,7 +61,8 @@ public:
|
||||||
Material::Table materialTable;
|
Material::Table materialTable;
|
||||||
Endgames endgames;
|
Endgames endgames;
|
||||||
size_t PVIdx, PVLast;
|
size_t PVIdx, PVLast;
|
||||||
int selDepth, nmp_ply, nmp_odd;
|
int selDepth, nmp_min_ply;
|
||||||
|
Color nmp_color;
|
||||||
std::atomic<uint64_t> nodes, tbHits;
|
std::atomic<uint64_t> nodes, tbHits;
|
||||||
|
|
||||||
Position rootPos;
|
Position rootPos;
|
||||||
|
|
Loading…
Add table
Reference in a new issue