DrawValue[ us] = VALUE_DRAW - Value(contempt);
DrawValue[~us] = VALUE_DRAW + Value(contempt);
- TB::Hits = 0;
- TB::RootInTB = false;
- TB::UseRule50 = Options["Syzygy50MoveRule"];
- TB::ProbeDepth = Options["SyzygyProbeDepth"] * ONE_PLY;
- TB::Cardinality = Options["SyzygyProbeLimit"];
-
- // Skip TB probing when no TB found: !TBLargest -> !TB::Cardinality
- if (TB::Cardinality > TB::MaxCardinality)
- {
- TB::Cardinality = TB::MaxCardinality;
- TB::ProbeDepth = DEPTH_ZERO;
- }
-
if (rootMoves.empty())
{
rootMoves.push_back(RootMove(MOVE_NONE));
}
else
{
- if ( TB::Cardinality >= rootPos.count<ALL_PIECES>(WHITE)
- + rootPos.count<ALL_PIECES>(BLACK)
- && !rootPos.can_castle(ANY_CASTLING))
- {
- // If the current root position is in the tablebases, then RootMoves
- // contains only moves that preserve the draw or the win.
- TB::RootInTB = Tablebases::root_probe(rootPos, rootMoves, TB::Score);
-
- if (TB::RootInTB)
- TB::Cardinality = 0; // Do not probe tablebases during the search
-
- else // If DTZ tables are missing, use WDL tables as a fallback
- {
- // Filter out moves that do not preserve the draw or the win.
- TB::RootInTB = Tablebases::root_probe_wdl(rootPos, rootMoves, TB::Score);
-
- // Only probe during search if winning
- if (TB::Score <= VALUE_DRAW)
- TB::Cardinality = 0;
- }
-
- if (TB::RootInTB)
- {
- TB::Hits = rootMoves.size();
-
- if (!TB::UseRule50)
- TB::Score = TB::Score > VALUE_DRAW ? VALUE_MATE - MAX_PLY - 1
- : TB::Score < VALUE_DRAW ? -VALUE_MATE + MAX_PLY + 1
- : VALUE_DRAW;
- }
- }
-
for (Thread* th : Threads)
if (th != this)
th->start_searching();
&& !pos.captured_piece_type()
&& is_ok((ss-1)->currentMove))
{
- Value bonus = Value((depth / ONE_PLY) * (depth / ONE_PLY) + depth / ONE_PLY - 1);
+ Value bonus = Value((depth / ONE_PLY) * (depth / ONE_PLY) + 2 * depth / ONE_PLY - 2);
if ((ss-2)->counterMoves)
(ss-2)->counterMoves->update(pos.piece_on(prevSq), prevSq, bonus);
ss->killers[0] = move;
}
- Value bonus = Value((depth / ONE_PLY) * (depth / ONE_PLY) + depth / ONE_PLY - 1);
+ Value bonus = Value((depth / ONE_PLY) * (depth / ONE_PLY) + 2 * depth / ONE_PLY - 2);
Square prevSq = to_sq((ss-1)->currentMove);
CounterMoveStats* cmh = (ss-1)->counterMoves;
if ((ss-1)->moveCount == 1 && !pos.captured_piece_type())
{
if ((ss-2)->counterMoves)
- (ss-2)->counterMoves->update(pos.piece_on(prevSq), prevSq, -bonus - 2 * (depth + 1) / ONE_PLY);
+ (ss-2)->counterMoves->update(pos.piece_on(prevSq), prevSq, -bonus - 2 * (depth + 1) / ONE_PLY - 1);
if ((ss-3)->counterMoves)
- (ss-3)->counterMoves->update(pos.piece_on(prevSq), prevSq, -bonus - 2 * (depth + 1) / ONE_PLY);
+ (ss-3)->counterMoves->update(pos.piece_on(prevSq), prevSq, -bonus - 2 * (depth + 1) / ONE_PLY - 1);
if ((ss-5)->counterMoves)
- (ss-5)->counterMoves->update(pos.piece_on(prevSq), prevSq, -bonus - 2 * (depth + 1) / ONE_PLY);
+ (ss-5)->counterMoves->update(pos.piece_on(prevSq), prevSq, -bonus - 2 * (depth + 1) / ONE_PLY - 1);
}
}
return false;
}
+
+void Tablebases::filter_root_moves(Position& pos, Search::RootMoves& rootMoves) {
+
+ Hits = 0;
+ RootInTB = false;
+ UseRule50 = Options["Syzygy50MoveRule"];
+ ProbeDepth = Options["SyzygyProbeDepth"] * ONE_PLY;
+ Cardinality = Options["SyzygyProbeLimit"];
+
+ // Skip TB probing when no TB found: !TBLargest -> !TB::Cardinality
+ if (Cardinality > MaxCardinality)
+ {
+ Cardinality = MaxCardinality;
+ ProbeDepth = DEPTH_ZERO;
+ }
+
+ if (Cardinality < popcount(pos.pieces()) || pos.can_castle(ANY_CASTLING))
+ return;
+
+ // If the current root position is in the tablebases, then RootMoves
+ // contains only moves that preserve the draw or the win.
+ RootInTB = root_probe(pos, rootMoves, TB::Score);
+
+ if (RootInTB)
+ Cardinality = 0; // Do not probe tablebases during the search
+
+ else // If DTZ tables are missing, use WDL tables as a fallback
+ {
+ // Filter out moves that do not preserve the draw or the win.
+ RootInTB = root_probe_wdl(pos, rootMoves, TB::Score);
+
+ // Only probe during search if winning
+ if (TB::Score <= VALUE_DRAW)
+ Cardinality = 0;
+ }
+
+ if (RootInTB)
+ {
+ Hits = rootMoves.size();
+
+ if (!UseRule50)
+ TB::Score = TB::Score > VALUE_DRAW ? VALUE_MATE - MAX_PLY - 1
+ : TB::Score < VALUE_DRAW ? -VALUE_MATE + MAX_PLY + 1
+ : VALUE_DRAW;
+ }
+}