mirror of
https://github.com/sockspls/badfish
synced 2025-04-29 16:23:09 +00:00
Better clarify how we use TT depth in qsearch
Namely we use only two types of depth in TT: DEPTH_QS_CHECKS or DEPTH_QS_NO_CHECKS. No functional change. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
parent
201e8d5f87
commit
d55a5a4d81
3 changed files with 15 additions and 14 deletions
|
@ -31,7 +31,10 @@ enum Depth {
|
||||||
|
|
||||||
ONE_PLY = 2,
|
ONE_PLY = 2,
|
||||||
|
|
||||||
DEPTH_ZERO = 0,
|
DEPTH_ZERO = 0 * ONE_PLY,
|
||||||
|
DEPTH_QS_CHECKS = -1 * ONE_PLY,
|
||||||
|
DEPTH_QS_NO_CHECKS = -2 * ONE_PLY,
|
||||||
|
|
||||||
DEPTH_NONE = -127 * ONE_PLY
|
DEPTH_NONE = -127 * ONE_PLY
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -99,7 +99,7 @@ MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const History& h,
|
||||||
|
|
||||||
phasePtr = MainSearchPhaseTable;
|
phasePtr = MainSearchPhaseTable;
|
||||||
}
|
}
|
||||||
else if (d == DEPTH_ZERO)
|
else if (d >= DEPTH_QS_CHECKS)
|
||||||
phasePtr = QsearchWithChecksPhaseTable;
|
phasePtr = QsearchWithChecksPhaseTable;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -1468,6 +1468,7 @@ split_point_start: // At split points actual search starts from here
|
||||||
Value bestValue, value, evalMargin, futilityValue, futilityBase;
|
Value bestValue, value, evalMargin, futilityValue, futilityBase;
|
||||||
bool isCheck, enoughMaterial, moveIsCheck, evasionPrunable;
|
bool isCheck, enoughMaterial, moveIsCheck, evasionPrunable;
|
||||||
const TTEntry* tte;
|
const TTEntry* tte;
|
||||||
|
Depth ttDepth;
|
||||||
Value oldAlpha = alpha;
|
Value oldAlpha = alpha;
|
||||||
|
|
||||||
ss->bestMove = ss->currentMove = MOVE_NONE;
|
ss->bestMove = ss->currentMove = MOVE_NONE;
|
||||||
|
@ -1476,21 +1477,18 @@ split_point_start: // At split points actual search starts from here
|
||||||
if (pos.is_draw() || ply >= PLY_MAX - 1)
|
if (pos.is_draw() || ply >= PLY_MAX - 1)
|
||||||
return VALUE_DRAW;
|
return VALUE_DRAW;
|
||||||
|
|
||||||
// Decide whether or not to include checks
|
// Decide whether or not to include checks, this fixes also the type of
|
||||||
|
// TT entry depth that we are going to use. Note that in qsearch we use
|
||||||
|
// only two types of depth in TT: DEPTH_QS_CHECKS or DEPTH_QS_NO_CHECKS.
|
||||||
isCheck = pos.is_check();
|
isCheck = pos.is_check();
|
||||||
|
ttDepth = (isCheck || depth >= DEPTH_QS_CHECKS ? DEPTH_QS_CHECKS : DEPTH_QS_NO_CHECKS);
|
||||||
Depth d;
|
|
||||||
if (isCheck || depth >= -ONE_PLY)
|
|
||||||
d = DEPTH_ZERO;
|
|
||||||
else
|
|
||||||
d = DEPTH_ZERO - ONE_PLY;
|
|
||||||
|
|
||||||
// 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
|
||||||
// pruning, but only for move ordering.
|
// pruning, but only for move ordering.
|
||||||
tte = TT.retrieve(pos.get_key());
|
tte = TT.retrieve(pos.get_key());
|
||||||
ttMove = (tte ? tte->move() : MOVE_NONE);
|
ttMove = (tte ? tte->move() : MOVE_NONE);
|
||||||
|
|
||||||
if (!PvNode && tte && ok_to_use_TT(tte, d, beta, ply))
|
if (!PvNode && tte && ok_to_use_TT(tte, ttDepth, beta, ply))
|
||||||
{
|
{
|
||||||
ss->bestMove = ttMove; // Can be MOVE_NONE
|
ss->bestMove = ttMove; // Can be MOVE_NONE
|
||||||
return value_from_tt(tte->value(), ply);
|
return value_from_tt(tte->value(), ply);
|
||||||
|
@ -1536,9 +1534,9 @@ split_point_start: // At split points actual search starts from here
|
||||||
|
|
||||||
// Initialize a MovePicker object for the current position, and prepare
|
// Initialize a MovePicker object for the current position, and prepare
|
||||||
// to search the moves. Because the depth is <= 0 here, only captures,
|
// to search the moves. Because the depth is <= 0 here, only captures,
|
||||||
// queen promotions and checks (only if depth == 0 or depth == -ONE_PLY
|
// queen promotions and checks (only if depth >= DEPTH_QS_CHECKS) will
|
||||||
// and we are near beta) will be generated.
|
// be generated.
|
||||||
MovePicker mp = MovePicker(pos, ttMove, d, H);
|
MovePicker mp = MovePicker(pos, ttMove, depth, H);
|
||||||
CheckInfo ci(pos);
|
CheckInfo ci(pos);
|
||||||
|
|
||||||
// Loop through the moves until no moves remain or a beta cutoff occurs
|
// Loop through the moves until no moves remain or a beta cutoff occurs
|
||||||
|
@ -1628,7 +1626,7 @@ split_point_start: // At split points actual search starts from here
|
||||||
|
|
||||||
// Update transposition table
|
// Update transposition table
|
||||||
ValueType vt = (bestValue <= oldAlpha ? VALUE_TYPE_UPPER : bestValue >= beta ? VALUE_TYPE_LOWER : VALUE_TYPE_EXACT);
|
ValueType vt = (bestValue <= oldAlpha ? VALUE_TYPE_UPPER : bestValue >= beta ? VALUE_TYPE_LOWER : VALUE_TYPE_EXACT);
|
||||||
TT.store(pos.get_key(), value_to_tt(bestValue, ply), vt, d, ss->bestMove, ss->eval, evalMargin);
|
TT.store(pos.get_key(), value_to_tt(bestValue, ply), vt, ttDepth, ss->bestMove, ss->eval, evalMargin);
|
||||||
|
|
||||||
assert(bestValue > -VALUE_INFINITE && bestValue < VALUE_INFINITE);
|
assert(bestValue > -VALUE_INFINITE && bestValue < VALUE_INFINITE);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue