X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Ftt.cpp;h=956184a92576089b14ced36fdd57285babaa944a;hb=6f6f59ea6a066eac291eac5ad0369cd2e0daf739;hp=5c5e10c16b720115ca4b20fabb9c97dbd21ffd99;hpb=00e86078a550631e3d045d882ab27f827d3f2378;p=stockfish diff --git a/src/tt.cpp b/src/tt.cpp index 5c5e10c1..956184a9 100644 --- a/src/tt.cpp +++ b/src/tt.cpp @@ -25,7 +25,7 @@ #include #include -#include "movegen.h" +#include "evaluate.h" #include "tt.h" // The main transposition table @@ -154,57 +154,3 @@ TTEntry* TranspositionTable::retrieve(const Key posKey) const { void TranspositionTable::new_search() { generation++; } - - -/// TranspositionTable::insert_pv() is called at the end of a search -/// iteration, and inserts the PV back into the PV. This makes sure -/// the old PV moves are searched first, even if the old TT entries -/// have been overwritten. - -void TranspositionTable::insert_pv(const Position& pos, Move pv[]) { - - StateInfo st; - Position p(pos, pos.thread()); - - for (int i = 0; pv[i] != MOVE_NONE; i++) - { - TTEntry *tte = retrieve(p.get_key()); - if (!tte || tte->move() != pv[i]) - store(p.get_key(), VALUE_NONE, VALUE_TYPE_NONE, Depth(-127*OnePly), pv[i], VALUE_NONE, VALUE_NONE); - p.do_move(pv[i], st); - } -} - - -/// TranspositionTable::extract_pv() extends a PV by adding moves from the -/// transposition table at the end. This should ensure that the PV is almost -/// always at least two plies long, which is important, because otherwise we -/// will often get single-move PVs when the search stops while failing high, -/// and a single-move PV means that we don't have a ponder move. - -void TranspositionTable::extract_pv(const Position& pos, Move bestMove, Move pv[], const int PLY_MAX) { - - const TTEntry* tte; - StateInfo st; - Position p(pos, pos.thread()); - int ply = 0; - - assert(bestMove != MOVE_NONE); - - pv[ply] = bestMove; - p.do_move(pv[ply++], st); - - // Extract moves from TT when possible. We try hard to always - // get a ponder move, that's the reason of ply < 2 conditions. - while ( (tte = retrieve(p.get_key())) != NULL - && tte->move() != MOVE_NONE - && (tte->type() == VALUE_TYPE_EXACT || ply < 2) - && move_is_legal(p, tte->move()) - && (!p.is_draw() || ply < 2) - && ply < PLY_MAX) - { - pv[ply] = tte->move(); - p.do_move(pv[ply++], st); - } - pv[ply] = MOVE_NONE; -}