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();
Position& pos = RootPosition;
Chess960 = pos.is_chess960();
Eval::RootColor = pos.side_to_move();
- Eval::ValueDraw[ Eval::RootColor] = VALUE_DRAW - Eval::ContemptFactor;
- Eval::ValueDraw[~Eval::RootColor] = VALUE_DRAW + Eval::ContemptFactor;
+ int scaledCF = Eval::ContemptFactor * MaterialTable::game_phase(pos) / PHASE_MIDGAME;
+ Eval::ValueDraw[ Eval::RootColor] = VALUE_DRAW - Value(scaledCF);
+ Eval::ValueDraw[~Eval::RootColor] = VALUE_DRAW + Value(scaledCF);
TimeMgr.init(Limits, pos.startpos_ply_counter(), pos.side_to_move());
TT.new_search();
H.clear();
// 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
// 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;
}
- // 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.