From 807844eab194adc7c5378575f81d28ce9ca66287 Mon Sep 17 00:00:00 2001 From: Marco Costalba Date: Fri, 1 Jan 2010 14:28:09 +0100 Subject: [PATCH] Introduce refine_eval() Try to get a position evaluation better then the quick one with the help of the TT table. This allows the null search conditions and chosen reductions to be more accurate. After 908 games at 1+0 Mod vs Orig +209 =526 -173 +14 ELO Functionality Signature: 16627355 Signed-off-by: Marco Costalba --- src/search.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/search.cpp b/src/search.cpp index 5fc9be36..09b483cf 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -288,6 +288,7 @@ namespace { bool ok_to_do_nullmove(const Position& pos); bool ok_to_prune(const Position& pos, Move m, Move threat); bool ok_to_use_TT(const TTEntry* tte, Depth depth, Value beta, int ply); + Value refine_eval(const TTEntry* tte, Value defaultEval, int ply); void update_history(const Position& pos, Move move, Depth depth, Move movesSearched[], int moveCount); void update_killers(Move m, SearchStack& ss); @@ -1360,7 +1361,7 @@ namespace { return value_from_tt(tte->value(), ply); } - approximateEval = quick_evaluate(pos); + approximateEval = refine_eval(tte, quick_evaluate(pos), ply); isCheck = pos.is_check(); // Null move search @@ -2474,6 +2475,23 @@ namespace { } + // refine_eval() returns the transposition table score if + // possible otherwise falls back on static position evaluation. + + Value refine_eval(const TTEntry* tte, Value defaultEval, int ply) { + + if (!tte) + return defaultEval; + + Value v = value_from_tt(tte->value(), ply); + + if ( (is_lower_bound(tte->type()) && v >= defaultEval) + || (is_upper_bound(tte->type()) && v < defaultEval)) + return v; + + return defaultEval; + } + // update_history() registers a good move that produced a beta-cutoff // in history and marks as failures all the other moves of that ply. -- 2.39.2