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

Retire can_return_tt() and rewirte TT-hit code

Simplify the code and doing this introduce a couple
of (very small) functional changes:

- Always compare to depth even in "mate value" condition
- TT cut-off in qsearch also in case of PvNode, as in search

Verified against regression with 2500 games at 30"+0.05
on 2 threads: 451 - 444 - 1602

Functional changed: new bench is 5544977
This commit is contained in:
Marco Costalba 2012-10-13 11:32:31 +02:00
parent 6c8663341e
commit 189b6fc270

View file

@ -104,7 +104,6 @@ namespace {
bool connected_moves(const Position& pos, Move m1, Move m2);
Value value_to_tt(Value v, int ply);
Value value_from_tt(Value v, int ply);
bool can_return_tt(const TTEntry* tte, Depth depth, Value ttValue, Value beta);
bool connected_threat(const Position& pos, Move m, Move threat);
Value refine_eval(const TTEntry* tte, Value ttValue, Value defaultEval);
Move do_skill_level();
@ -544,8 +543,11 @@ namespace {
// a fail high/low. Biggest advantage at probing at PV nodes is to have a
// smooth experience in analysis mode. We don't probe at Root nodes otherwise
// we should also update RootMoveList to avoid bogus output.
if (!RootNode && tte && (PvNode ? tte->depth() >= depth && tte->type() == BOUND_EXACT
: can_return_tt(tte, depth, ttValue, beta)))
if ( !RootNode
&& tte && tte->depth() >= depth
&& ( PvNode ? tte->type() == BOUND_EXACT
: ttValue >= beta ? (tte->type() & BOUND_LOWER)
: (tte->type() & BOUND_UPPER)))
{
TT.refresh(tte);
ss->currentMove = ttMove; // Can be MOVE_NONE
@ -1095,7 +1097,10 @@ split_point_start: // At split points actual search starts from here
// only two types of depth in TT: DEPTH_QS_CHECKS or DEPTH_QS_NO_CHECKS.
ttDepth = inCheck || depth >= DEPTH_QS_CHECKS ? DEPTH_QS_CHECKS : DEPTH_QS_NO_CHECKS;
if (!PvNode && tte && can_return_tt(tte, ttDepth, ttValue, beta))
if ( tte && tte->depth() >= ttDepth
&& ( PvNode ? tte->type() == BOUND_EXACT
: ttValue >= beta ? (tte->type() & BOUND_LOWER)
: (tte->type() & BOUND_UPPER)))
{
ss->currentMove = ttMove; // Can be MOVE_NONE
return ttValue;
@ -1419,20 +1424,6 @@ split_point_start: // At split points actual search starts from here
}
// can_return_tt() returns true if a transposition table score can be used to
// cut-off at a given point in search.
bool can_return_tt(const TTEntry* tte, Depth depth, Value v, Value beta) {
return ( tte->depth() >= depth
|| v >= std::max(VALUE_MATE_IN_MAX_PLY, beta)
|| v < std::min(VALUE_MATED_IN_MAX_PLY, beta))
&& ( ((tte->type() & BOUND_LOWER) && v >= beta)
|| ((tte->type() & BOUND_UPPER) && v < beta));
}
// refine_eval() returns the transposition table score if possible, otherwise
// falls back on static position evaluation.