struct IterationInfoType {
- IterationInfoType(Value v = Value(0), Value sv = Value(0), bool fh = false, bool fl = false)
- : value(v), speculatedValue(sv), failHigh(fh), failLow(fl) {}
+ IterationInfoType(Value v = Value(0), Value sv = Value(0))
+ : value(v), speculatedValue(sv) {}
Value value, speculatedValue;
- bool failHigh, failLow;
};
// Search to the current depth
Value value = root_search(p, ss, rml, alpha, beta);
- if (AbortSearch)
- break; // Value cannot be trusted. Break out immediately!
// Write PV to transposition table, in case the relevant entries have
// been overwritten during the search.
TT.insert_pv(p, ss[0].pv);
+ if (AbortSearch)
+ break; // Value cannot be trusted. Break out immediately!
+
//Save info about search result
Value speculatedValue;
bool fHigh = false;
}
else if (value <= alpha)
{
+ assert(value == alpha);
assert(delta < 0);
fLow = true;
speculatedValue = value;
speculatedValue = Min(Max(speculatedValue, -VALUE_INFINITE), VALUE_INFINITE);
- IterationInfo[Iteration] = IterationInfoType(value, speculatedValue, fHigh, fLow);
+ IterationInfo[Iteration] = IterationInfoType(value, speculatedValue);
// Erase the easy move if it differs from the new best move
if (ss[0].pv[0] != EasyMove)
Value root_search(Position &pos, SearchStack ss[], RootMoveList &rml, Value alpha, Value beta) {
- //FIXME: Implement bestValue
Value oldAlpha = alpha;
Value value;
Bitboard dcCandidates = pos.discovered_check_candidates(pos.side_to_move());
{
if (alpha >= beta)
{
+ // We failed high, invalidate and skip next moves, leave node-counters
+ // and beta-counters as they are and quickly return, we will try to do
+ // a research at the next iteration with a bigger aspiration window.
rml.set_move_score(i, -VALUE_INFINITE);
- continue; // Leave node-counters and beta-counters as they are
+ continue;
}
int64_t nodes;
Move move;
rml.set_move_score(i, -VALUE_INFINITE);
else
{
- // New best move!
+ // PV move or new best move!
// Update PV
rml.set_move_score(i, value);
return;
bool overTime = t > AbsoluteMaxSearchTime
- || (RootMoveNumber == 1 && t > MaxSearchTime + ExtraSearchTime && !FailLow) //FIXME: BUG??
+ || (RootMoveNumber == 1 && t > MaxSearchTime + ExtraSearchTime && !FailLow) //FIXME: We are not checking any problem flags, BUG?
|| ( !FailHigh && !FailLow && !fail_high_ply_1() && !Problem
&& t > 6*(MaxSearchTime + ExtraSearchTime));