mirror of
https://github.com/sockspls/badfish
synced 2025-04-30 16:53:09 +00:00
Use C++ loops in insert_pv_in_tt
Also small tweak to extract_ponder_from_tt No functional change.
This commit is contained in:
parent
bfd0f95f06
commit
45eac9507c
2 changed files with 22 additions and 19 deletions
|
@ -1461,22 +1461,22 @@ string UCI::pv(const Position& pos, Depth depth, Value alpha, Value beta) {
|
||||||
void RootMove::insert_pv_in_tt(Position& pos) {
|
void RootMove::insert_pv_in_tt(Position& pos) {
|
||||||
|
|
||||||
StateInfo state[MAX_PLY], *st = state;
|
StateInfo state[MAX_PLY], *st = state;
|
||||||
size_t idx = 0;
|
|
||||||
|
|
||||||
for ( ; idx < pv.size(); ++idx)
|
|
||||||
{
|
|
||||||
bool ttHit;
|
bool ttHit;
|
||||||
|
|
||||||
|
for (Move m : pv)
|
||||||
|
{
|
||||||
|
assert(MoveList<LEGAL>(pos).contains(m));
|
||||||
|
|
||||||
TTEntry* tte = TT.probe(pos.key(), ttHit);
|
TTEntry* tte = TT.probe(pos.key(), ttHit);
|
||||||
|
|
||||||
if (!ttHit || tte->move() != pv[idx]) // Don't overwrite correct entries
|
if (!ttHit || tte->move() != m) // Don't overwrite correct entries
|
||||||
tte->save(pos.key(), VALUE_NONE, BOUND_NONE, DEPTH_NONE, pv[idx], VALUE_NONE, TT.generation());
|
tte->save(pos.key(), VALUE_NONE, BOUND_NONE, DEPTH_NONE, m, VALUE_NONE, TT.generation());
|
||||||
|
|
||||||
assert(MoveList<LEGAL>(pos).contains(pv[idx]));
|
pos.do_move(m, *st++);
|
||||||
|
|
||||||
pos.do_move(pv[idx], *st++);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
while (idx) pos.undo_move(pv[--idx]);
|
for (size_t i = pv.size(); i > 0; )
|
||||||
|
pos.undo_move(pv[--i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1485,22 +1485,25 @@ void RootMove::insert_pv_in_tt(Position& pos) {
|
||||||
/// root. We try hard to have a ponder move to return to the GUI, otherwise in case of
|
/// root. We try hard to have a ponder move to return to the GUI, otherwise in case of
|
||||||
/// 'ponder on' we have nothing to think on.
|
/// 'ponder on' we have nothing to think on.
|
||||||
|
|
||||||
Move RootMove::extract_ponder_from_tt(Position& pos)
|
bool RootMove::extract_ponder_from_tt(Position& pos)
|
||||||
{
|
{
|
||||||
StateInfo st;
|
StateInfo st;
|
||||||
bool found;
|
bool ttHit;
|
||||||
|
|
||||||
assert(pv.size() == 1);
|
assert(pv.size() == 1);
|
||||||
|
|
||||||
pos.do_move(pv[0], st);
|
pos.do_move(pv[0], st);
|
||||||
TTEntry* tte = TT.probe(pos.key(), found);
|
TTEntry* tte = TT.probe(pos.key(), ttHit);
|
||||||
Move m = found ? tte->move() : MOVE_NONE;
|
|
||||||
if (!MoveList<LEGAL>(pos).contains(m))
|
|
||||||
m = MOVE_NONE;
|
|
||||||
|
|
||||||
pos.undo_move(pv[0]);
|
pos.undo_move(pv[0]);
|
||||||
pv.push_back(m);
|
|
||||||
return m;
|
if (ttHit)
|
||||||
|
{
|
||||||
|
Move m = tte->move(); // Local copy to be SMP safe
|
||||||
|
if (MoveList<LEGAL>(pos).contains(m))
|
||||||
|
return pv.push_back(m), true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -60,7 +60,7 @@ struct RootMove {
|
||||||
bool operator<(const RootMove& m) const { return score > m.score; } // Ascending sort
|
bool operator<(const RootMove& m) const { return score > m.score; } // Ascending sort
|
||||||
bool operator==(const Move& m) const { return pv[0] == m; }
|
bool operator==(const Move& m) const { return pv[0] == m; }
|
||||||
void insert_pv_in_tt(Position& pos);
|
void insert_pv_in_tt(Position& pos);
|
||||||
Move extract_ponder_from_tt(Position& pos);
|
bool extract_ponder_from_tt(Position& pos);
|
||||||
|
|
||||||
Value score;
|
Value score;
|
||||||
Value previousScore;
|
Value previousScore;
|
||||||
|
|
Loading…
Add table
Reference in a new issue