mirror of
https://github.com/sockspls/badfish
synced 2025-04-30 16:53:09 +00:00
Revert "Extend full 3 fold detection to PvNodes"
This commit is contained in:
parent
483c98a69e
commit
58c9fbacc7
3 changed files with 18 additions and 14 deletions
|
@ -1363,31 +1363,36 @@ Value Position::compute_non_pawn_material(Color c) const {
|
||||||
/// Position::is_draw() tests whether the position is drawn by material,
|
/// Position::is_draw() tests whether the position is drawn by material,
|
||||||
/// repetition, or the 50 moves rule. It does not detect stalemates, this
|
/// repetition, or the 50 moves rule. It does not detect stalemates, this
|
||||||
/// must be done by the search.
|
/// must be done by the search.
|
||||||
template<bool CheckRepetition, bool CheckThreeFold>
|
template<bool SkipRepetition>
|
||||||
bool Position::is_draw() const {
|
bool Position::is_draw() const {
|
||||||
|
|
||||||
|
// Draw by material?
|
||||||
if ( !pieces(PAWN)
|
if ( !pieces(PAWN)
|
||||||
&& (non_pawn_material(WHITE) + non_pawn_material(BLACK) <= BishopValueMg))
|
&& (non_pawn_material(WHITE) + non_pawn_material(BLACK) <= BishopValueMg))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
// Draw by the 50 moves rule?
|
||||||
if (st->rule50 > 99 && (!checkers() || MoveList<LEGAL>(*this).size()))
|
if (st->rule50 > 99 && (!checkers() || MoveList<LEGAL>(*this).size()))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (CheckRepetition)
|
// Draw by repetition?
|
||||||
|
if (!SkipRepetition)
|
||||||
{
|
{
|
||||||
int i = 4, e = std::min(st->rule50, st->pliesFromNull), cnt;
|
int i = 4, e = std::min(st->rule50, st->pliesFromNull);
|
||||||
|
|
||||||
if (i <= e)
|
if (i <= e)
|
||||||
{
|
{
|
||||||
StateInfo* stp = st->previous->previous;
|
StateInfo* stp = st->previous->previous;
|
||||||
|
|
||||||
for (cnt = 0; i <= e; i += 2)
|
do {
|
||||||
{
|
|
||||||
stp = stp->previous->previous;
|
stp = stp->previous->previous;
|
||||||
|
|
||||||
if (stp->key == st->key && (!CheckThreeFold || ++cnt >= 2))
|
if (stp->key == st->key)
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
|
i += 2;
|
||||||
|
|
||||||
|
} while (i <= e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1395,9 +1400,8 @@ bool Position::is_draw() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Explicit template instantiations
|
// Explicit template instantiations
|
||||||
template bool Position::is_draw<true, true>() const;
|
template bool Position::is_draw<false>() const;
|
||||||
template bool Position::is_draw<true, false>() const;
|
template bool Position::is_draw<true>() const;
|
||||||
template bool Position::is_draw<false,false>() const;
|
|
||||||
|
|
||||||
|
|
||||||
/// Position::flip() flips position with the white and black sides reversed. This
|
/// Position::flip() flips position with the white and black sides reversed. This
|
||||||
|
|
|
@ -179,7 +179,7 @@ public:
|
||||||
Thread* this_thread() const;
|
Thread* this_thread() const;
|
||||||
int64_t nodes_searched() const;
|
int64_t nodes_searched() const;
|
||||||
void set_nodes_searched(int64_t n);
|
void set_nodes_searched(int64_t n);
|
||||||
template<bool CheckRepetition, bool CheckThreeFold> bool is_draw() const;
|
template<bool SkipRepetition> bool is_draw() const;
|
||||||
|
|
||||||
// Position consistency check, for debugging
|
// Position consistency check, for debugging
|
||||||
bool pos_is_ok(int* failedStep = NULL) const;
|
bool pos_is_ok(int* failedStep = NULL) const;
|
||||||
|
|
|
@ -534,7 +534,7 @@ namespace {
|
||||||
if (!RootNode)
|
if (!RootNode)
|
||||||
{
|
{
|
||||||
// Step 2. Check for aborted search and immediate draw
|
// Step 2. Check for aborted search and immediate draw
|
||||||
if (Signals.stop || pos.is_draw<true, PvNode>() || ss->ply > MAX_PLY)
|
if (Signals.stop || pos.is_draw<false>() || ss->ply > MAX_PLY)
|
||||||
return DrawValue[pos.side_to_move()];
|
return DrawValue[pos.side_to_move()];
|
||||||
|
|
||||||
// Step 3. Mate distance pruning. Even if we mate at the next move our score
|
// Step 3. Mate distance pruning. Even if we mate at the next move our score
|
||||||
|
@ -1109,7 +1109,7 @@ split_point_start: // At split points actual search starts from here
|
||||||
ss->ply = (ss-1)->ply + 1;
|
ss->ply = (ss-1)->ply + 1;
|
||||||
|
|
||||||
// Check for an instant draw or maximum ply reached
|
// Check for an instant draw or maximum ply reached
|
||||||
if (pos.is_draw<false, false>() || ss->ply > MAX_PLY)
|
if (pos.is_draw<true>() || ss->ply > MAX_PLY)
|
||||||
return DrawValue[pos.side_to_move()];
|
return DrawValue[pos.side_to_move()];
|
||||||
|
|
||||||
// Transposition table lookup. At PV nodes, we don't use the TT for
|
// Transposition table lookup. At PV nodes, we don't use the TT for
|
||||||
|
@ -1516,7 +1516,7 @@ void RootMove::extract_pv_from_tt(Position& pos) {
|
||||||
&& pos.is_pseudo_legal(m = tte->move()) // Local copy, TT could change
|
&& pos.is_pseudo_legal(m = tte->move()) // Local copy, TT could change
|
||||||
&& pos.pl_move_is_legal(m, pos.pinned_pieces())
|
&& pos.pl_move_is_legal(m, pos.pinned_pieces())
|
||||||
&& ply < MAX_PLY
|
&& ply < MAX_PLY
|
||||||
&& (!pos.is_draw<true, true>() || ply < 2));
|
&& (!pos.is_draw<false>() || ply < 2));
|
||||||
|
|
||||||
pv.push_back(MOVE_NONE); // Must be zero-terminating
|
pv.push_back(MOVE_NONE); // Must be zero-terminating
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue